@mailwoman/entity-resolution 11.0.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/lib/address-key.ts +14 -12
- package/lib/geocode-handler.ts +6 -5
- package/lib/geojson.ts +8 -8
- package/lib/index.ts +8 -8
- package/lib/ingest.ts +5 -4
- package/lib/learned-scorer.ts +16 -17
- package/lib/map-html.ts +2 -5
- package/lib/models/crosssource-gbt-en-us.ts +8 -7
- package/lib/models/dedup-gbt-en-us.ts +9 -6
- package/lib/models/org-crosssource-gbt-en-us.ts +8 -7
- package/lib/reconcile.ts +3 -0
- package/lib/resolve.ts +5 -6
- package/lib/types.ts +5 -6
- package/out/address-key.d.ts +11 -12
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js +13 -12
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +3 -5
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +5 -5
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +0 -11
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +7 -8
- package/out/geojson.js.map +1 -1
- package/out/index.d.ts +5 -8
- package/out/index.d.ts.map +1 -1
- package/out/index.js +7 -8
- package/out/index.js.map +1 -1
- package/out/ingest.d.ts +0 -7
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +4 -4
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +11 -15
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js +15 -17
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +0 -5
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +2 -5
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts +5 -7
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js +2 -10
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts +6 -6
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js +2 -11
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts +5 -7
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js +2 -10
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +2 -0
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +1 -5
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +3 -5
- package/out/resolve.js.map +1 -1
- package/out/tools/address-pairs/grade.d.ts +74 -0
- package/out/tools/address-pairs/grade.d.ts.map +1 -0
- package/out/tools/address-pairs/grade.js +184 -0
- package/out/tools/address-pairs/grade.js.map +1 -0
- package/out/tools/address-pairs/sample.d.ts +137 -0
- package/out/tools/address-pairs/sample.d.ts.map +1 -0
- package/out/tools/address-pairs/sample.js +262 -0
- package/out/tools/address-pairs/sample.js.map +1 -0
- package/out/tools/coverage-reconciliation.d.ts +0 -21
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +10 -11
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross/dataset-correlation.d.ts +0 -5
- package/out/tools/cross/dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross/dataset-correlation.js +2 -5
- package/out/tools/cross/dataset-correlation.js.map +1 -1
- package/out/tools/cross/source-threshold-sweep.d.ts +0 -12
- package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -1
- package/out/tools/cross/source-threshold-sweep.js +13 -13
- package/out/tools/cross/source-threshold-sweep.js.map +1 -1
- package/out/tools/dedup-ceiling.d.ts +0 -19
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +14 -13
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +6 -8
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +2 -11
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder/namesake-probe.d.ts +0 -13
- package/out/tools/geocoder/namesake-probe.d.ts.map +1 -1
- package/out/tools/geocoder/namesake-probe.js +8 -8
- package/out/tools/geocoder/namesake-probe.js.map +1 -1
- package/out/tools/geocoder/vs-provided-coords.d.ts +0 -17
- package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder/vs-provided-coords.js +10 -10
- package/out/tools/geocoder/vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts +0 -20
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +11 -12
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.d.ts +0 -17
- package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.js +12 -10
- package/out/tools/learned/scorer/clustering-eval.js.map +1 -1
- package/out/tools/learned/scorer/crossstate-eval.d.ts +0 -17
- package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/crossstate-eval.js +11 -10
- package/out/tools/learned/scorer/crossstate-eval.js.map +1 -1
- package/out/tools/learned/scorer/eval.d.ts +0 -5
- package/out/tools/learned/scorer/eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/eval.js +2 -5
- package/out/tools/learned/scorer/eval.js.map +1 -1
- package/out/tools/matcher-scale.d.ts +0 -5
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +2 -5
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/dedup-benchmark.d.ts +0 -10
- package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes/dedup-benchmark.js +10 -10
- package/out/tools/nppes/dedup-benchmark.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts.map +1 -1
- package/out/tools/nppes/org-name.js +2 -0
- package/out/tools/nppes/org-name.js.map +1 -1
- package/out/tools/nppes/overmerge-packet.d.ts +0 -6
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
- package/out/tools/nppes/overmerge-packet.js +2 -3
- package/out/tools/nppes/overmerge-packet.js.map +1 -1
- package/out/tools/nppes/report.d.ts +0 -5
- package/out/tools/nppes/report.d.ts.map +1 -1
- package/out/tools/nppes/report.js +2 -5
- package/out/tools/nppes/report.js.map +1 -1
- package/out/tools/nppes/sample.d.ts +0 -9
- package/out/tools/nppes/sample.d.ts.map +1 -1
- package/out/tools/nppes/sample.js +6 -7
- package/out/tools/nppes/sample.js.map +1 -1
- package/out/tools/nppes/scoring.d.ts +0 -3
- package/out/tools/nppes/scoring.d.ts.map +1 -1
- package/out/tools/nppes/scoring.js +2 -7
- package/out/tools/nppes/scoring.js.map +1 -1
- package/out/tools/nppes/settings.d.ts +2 -6
- package/out/tools/nppes/settings.d.ts.map +1 -1
- package/out/tools/nppes/settings.js +2 -8
- package/out/tools/nppes/settings.js.map +1 -1
- package/out/tools/nppes/truth-grains.d.ts +1 -8
- package/out/tools/nppes/truth-grains.d.ts.map +1 -1
- package/out/tools/nppes/truth-grains.js +3 -4
- package/out/tools/nppes/truth-grains.js.map +1 -1
- package/out/tools/shared.d.ts +0 -7
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +5 -9
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train/cross-gbt.d.ts +0 -25
- package/out/tools/train/cross-gbt.d.ts.map +1 -1
- package/out/tools/train/cross-gbt.js +15 -12
- package/out/tools/train/cross-gbt.js.map +1 -1
- package/out/tools/train/gbt.d.ts +0 -17
- package/out/tools/train/gbt.d.ts.map +1 -1
- package/out/tools/train/gbt.js +15 -14
- package/out/tools/train/gbt.js.map +1 -1
- package/out/tools/train/org-cross-gbt.d.ts +0 -24
- package/out/tools/train/org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train/org-cross-gbt.js +14 -9
- package/out/tools/train/org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.d.ts +0 -15
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +4 -6
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +0 -10
- package/out/tools/viz/browser.d.ts.map +1 -1
- package/out/tools/viz/browser.js +4 -4
- package/out/tools/viz/browser.js.map +1 -1
- package/out/tools/viz/cross-dataset-map.d.ts +0 -8
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +4 -5
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +0 -8
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +5 -5
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render/map.d.ts +0 -21
- package/out/tools/viz/render/map.d.ts.map +1 -1
- package/out/tools/viz/render/map.js +9 -11
- package/out/tools/viz/render/map.js.map +1 -1
- package/out/tools/viz/render.d.ts +0 -13
- package/out/tools/viz/render.d.ts.map +1 -1
- package/out/tools/viz/render.js +9 -9
- package/out/tools/viz/render.js.map +1 -1
- package/out/tools/viz/source-provenance-map.d.ts +0 -8
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +4 -5
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +0 -5
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +2 -5
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts +2 -6
- package/out/types.d.ts.map +1 -1
- package/out/types.js +2 -8
- package/out/types.js.map +1 -1
- package/package.json +10 -9
- package/tools/address-pairs/grade.ts +277 -0
- package/tools/address-pairs/sample.ts +451 -0
- package/tools/coverage-reconciliation.ts +11 -11
- package/tools/cross/dataset-correlation.ts +2 -5
- package/tools/cross/source-threshold-sweep.ts +8 -7
- package/tools/dedup-ceiling.ts +15 -13
- package/tools/eval-geocoder.ts +9 -8
- package/tools/geocoder/namesake-probe.ts +9 -8
- package/tools/geocoder/vs-provided-coords.ts +11 -10
- package/tools/gold-set-sample.ts +12 -12
- package/tools/learned/scorer/clustering-eval.ts +13 -10
- package/tools/learned/scorer/crossstate-eval.ts +12 -10
- package/tools/learned/scorer/eval.ts +2 -5
- package/tools/matcher-scale.ts +2 -5
- package/tools/nppes/dedup-benchmark.ts +6 -5
- package/tools/nppes/org-name.ts +3 -0
- package/tools/nppes/overmerge-packet.ts +3 -3
- package/tools/nppes/report.ts +2 -5
- package/tools/nppes/sample.ts +7 -7
- package/tools/nppes/scoring.ts +3 -3
- package/tools/nppes/settings.ts +5 -6
- package/tools/nppes/truth-grains.ts +4 -4
- package/tools/shared.ts +5 -8
- package/tools/train/cross-gbt.ts +16 -12
- package/tools/train/gbt.ts +15 -13
- package/tools/train/org-cross-gbt.ts +15 -9
- package/tools/txhhsc-to-oarow.ts +5 -6
- package/tools/viz/browser.ts +5 -4
- package/tools/viz/cross-dataset-map.ts +5 -5
- package/tools/viz/geocode-first-surface.ts +6 -5
- package/tools/viz/render/map.ts +10 -11
- package/tools/viz/render.ts +10 -9
- package/tools/viz/source-provenance-map.ts +6 -6
- package/tools/viz/yardstick-figure.ts +2 -5
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Samples cross-source address-point pairs from a built address layer for adjudication.
|
|
6
|
+
*
|
|
7
|
+
* A pair joins a row from a higher-ranked source with a row from a lower-ranked one:
|
|
8
|
+
* `usgov-nad`, then the OpenAddresses runs read directly, then Overture's datasets.
|
|
9
|
+
* Pairs come from two kinds of key group.
|
|
10
|
+
*
|
|
11
|
+
* A postcode key group holds rows that share a postcode, street key and house number.
|
|
12
|
+
* A locality key group holds rows that share a locality, street key and number
|
|
13
|
+
* but state different postcodes.
|
|
14
|
+
* A wrong postcode on one side shows there.
|
|
15
|
+
*
|
|
16
|
+
* Each pair lands in one stratum by its failure shape.
|
|
17
|
+
* Each stratum is capped per region, so every region in the run contributes pairs
|
|
18
|
+
* and the densest region cannot fill a stratum.
|
|
19
|
+
*
|
|
20
|
+
* Every row stores both records in full, the measured evidence
|
|
21
|
+
* (the distance, each unit's identifier, each point's stack size) and the verdict
|
|
22
|
+
* of the deterministic rule the layer build applies.
|
|
23
|
+
* The adjudication fields stay `null` for a human or a flagged LLM judge to fill.
|
|
24
|
+
*
|
|
25
|
+
* Run: `mailwoman registry address-pair-sample --layer-version 2026-11-08 [--regions us-ny,us-co] [--per-stratum 60]
|
|
26
|
+
* [--seed 1] --out-jsonl <path>`
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { usUnitIdentifier } from "@mailwoman/codex/us/unit/designator"
|
|
30
|
+
import { hashFNV1a } from "@mailwoman/core/coarse-placer/fnv-hash"
|
|
31
|
+
import { writeLocalJSONLFile } from "@mailwoman/core/fs/writers"
|
|
32
|
+
import { parseJSONStrict } from "@mailwoman/core/json"
|
|
33
|
+
import { addressLayerFiles } from "@mailwoman/resolver-wof-sqlite/address/keys/layout"
|
|
34
|
+
import { addressPointStacksSQL } from "@mailwoman/resolver-wof-sqlite/address/stack"
|
|
35
|
+
import { haversine } from "@mailwoman/spatial/geometries/point/distance"
|
|
36
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
37
|
+
import type { PathBuilderLike } from "path-ts"
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The failure shapes a pair is sampled by, in the order a pair is assigned to them.
|
|
41
|
+
*/
|
|
42
|
+
export const AddressPairStratum = {
|
|
43
|
+
/**
|
|
44
|
+
* Either point holds 100 or more distinct street-and-number pairs from its source.
|
|
45
|
+
*/
|
|
46
|
+
StackedPoint: "stacked-point",
|
|
47
|
+
/**
|
|
48
|
+
* The two rows share a locality, street and number but state different postcodes.
|
|
49
|
+
*/
|
|
50
|
+
PostcodeDiffers: "postcode-differs",
|
|
51
|
+
/**
|
|
52
|
+
* One row states a unit and the other states none.
|
|
53
|
+
*/
|
|
54
|
+
UnitAgainstNone: "unit-against-none",
|
|
55
|
+
/**
|
|
56
|
+
* Both rows state a unit, and the identifiers differ.
|
|
57
|
+
*/
|
|
58
|
+
UnitDiffers: "unit-differs",
|
|
59
|
+
/**
|
|
60
|
+
* Both rows state a unit written differently whose identifiers agree, such as `#2` and `UNIT 2`.
|
|
61
|
+
*/
|
|
62
|
+
UnitSpelling: "unit-spelling",
|
|
63
|
+
/**
|
|
64
|
+
* The units agree and the points lie farther apart than the deterministic rule's 0.002 degrees.
|
|
65
|
+
*/
|
|
66
|
+
Distant: "distant",
|
|
67
|
+
/**
|
|
68
|
+
* The units agree and the points lie within 0.002 degrees.
|
|
69
|
+
*/
|
|
70
|
+
Coincident: "coincident",
|
|
71
|
+
} as const
|
|
72
|
+
|
|
73
|
+
export type AddressPairStratum = (typeof AddressPairStratum)[keyof typeof AddressPairStratum]
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* One address point as the pair set records it.
|
|
77
|
+
*/
|
|
78
|
+
export interface AddressPairRecord {
|
|
79
|
+
source: string
|
|
80
|
+
rank: number
|
|
81
|
+
sourceRecordID: string
|
|
82
|
+
authority: string | null
|
|
83
|
+
number: string
|
|
84
|
+
unit: string | null
|
|
85
|
+
unitIdentifier: string | null
|
|
86
|
+
streetRaw: string
|
|
87
|
+
postcode: string | null
|
|
88
|
+
localities: string[]
|
|
89
|
+
placement: string | null
|
|
90
|
+
lat: number
|
|
91
|
+
lon: number
|
|
92
|
+
/**
|
|
93
|
+
* Distinct street-and-number pairs this record's source places at the same point, rounded to 1e-5 degrees.
|
|
94
|
+
*/
|
|
95
|
+
stack: number
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* One sampled pair, with the evidence an adjudicator reads and the fields the adjudicator fills.
|
|
100
|
+
*/
|
|
101
|
+
export interface AddressPair {
|
|
102
|
+
pairID: string
|
|
103
|
+
region: string
|
|
104
|
+
stratum: AddressPairStratum
|
|
105
|
+
higher: AddressPairRecord
|
|
106
|
+
lower: AddressPairRecord
|
|
107
|
+
distanceMeters: number
|
|
108
|
+
/**
|
|
109
|
+
* Whether the deterministic rule drops the lower row: same postcode key,
|
|
110
|
+
* same raw unit, points within 0.002°.
|
|
111
|
+
*/
|
|
112
|
+
ruleDrops: boolean
|
|
113
|
+
adjudication: "same-address" | "different-address" | "unsure" | null
|
|
114
|
+
adjudicator: string | null
|
|
115
|
+
rationale: string | null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface AddressPairSampleOptions {
|
|
119
|
+
/**
|
|
120
|
+
* The directory holding `addresses/<region>/<version>/`.
|
|
121
|
+
*/
|
|
122
|
+
root: PathBuilderLike
|
|
123
|
+
version: string
|
|
124
|
+
regions: readonly string[]
|
|
125
|
+
/**
|
|
126
|
+
* The pairs kept per stratum across all regions.
|
|
127
|
+
*
|
|
128
|
+
* @defaultValue `60`
|
|
129
|
+
*/
|
|
130
|
+
perStratum?: number
|
|
131
|
+
/**
|
|
132
|
+
* Selects which key groups are read.
|
|
133
|
+
* The same seed over the same layer samples the same pairs.
|
|
134
|
+
*
|
|
135
|
+
* @defaultValue `1`
|
|
136
|
+
*/
|
|
137
|
+
seed?: number
|
|
138
|
+
/**
|
|
139
|
+
* Rows of each region's key table to read, at most, before the region's sample closes.
|
|
140
|
+
*
|
|
141
|
+
* @defaultValue `400_000`
|
|
142
|
+
*/
|
|
143
|
+
rowsPerRegion?: number
|
|
144
|
+
/**
|
|
145
|
+
* Draws the unlabeled population EM is fitted on instead of the stratified set:
|
|
146
|
+
* every candidate pair of each sampled key group is kept, without strata caps,
|
|
147
|
+
* until a region has yielded this number of pairs.
|
|
148
|
+
*/
|
|
149
|
+
populationPerRegion?: number
|
|
150
|
+
/**
|
|
151
|
+
* Pair ids left out of the sample, such as an earlier set's, so a held-out set shares no pair with it.
|
|
152
|
+
*/
|
|
153
|
+
exclude?: ReadonlySet<string>
|
|
154
|
+
outJSONL?: string
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface AddressPairSampleResult {
|
|
158
|
+
pairs: AddressPair[]
|
|
159
|
+
/**
|
|
160
|
+
* Pairs kept per stratum.
|
|
161
|
+
*/
|
|
162
|
+
strata: Record<AddressPairStratum, number>
|
|
163
|
+
/**
|
|
164
|
+
* Candidate pairs seen per stratum before the caps applied.
|
|
165
|
+
*/
|
|
166
|
+
candidates: Record<AddressPairStratum, number>
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The stack size from which a pair lands in the stacked-point stratum.
|
|
171
|
+
*
|
|
172
|
+
* Every record's stack is recorded exactly, whatever its size, so the rule the layer
|
|
173
|
+
* build applies to smaller stacks grades on the same values.
|
|
174
|
+
*/
|
|
175
|
+
const STACK_MIN_ADDRESSES = 100
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* How far apart, in degrees on each axis, the deterministic rule the layer build applied
|
|
179
|
+
* before #2978 let two points of one address lie.
|
|
180
|
+
* The `rule` arm of the grade reads it from here.
|
|
181
|
+
*/
|
|
182
|
+
export const RULE_DEGREES = 0.002
|
|
183
|
+
const POSTCODE_NEAR_DEGREES = 0.005
|
|
184
|
+
|
|
185
|
+
interface KeyRow {
|
|
186
|
+
scope: string
|
|
187
|
+
street: string
|
|
188
|
+
number: string
|
|
189
|
+
address_id: number
|
|
190
|
+
source_id: number
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface DetailRow {
|
|
194
|
+
address_id: number
|
|
195
|
+
source_id: number
|
|
196
|
+
source_record_id: string
|
|
197
|
+
number: string
|
|
198
|
+
unit: string | null
|
|
199
|
+
street_raw: string
|
|
200
|
+
postcode: string | null
|
|
201
|
+
names: string
|
|
202
|
+
lat: number
|
|
203
|
+
lon: number
|
|
204
|
+
placement: string | null
|
|
205
|
+
authority: string | null
|
|
206
|
+
la: number
|
|
207
|
+
lo: number
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function sourceRank(name: string): number {
|
|
211
|
+
if (name === "usgov-nad") return 0
|
|
212
|
+
|
|
213
|
+
return name.startsWith("openaddresses:") ? 1 : 2
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function strataRecord<T>(value: () => T): Record<AddressPairStratum, T> {
|
|
217
|
+
return Object.fromEntries(Object.values(AddressPairStratum).map((stratum) => [stratum, value()])) as Record<
|
|
218
|
+
AddressPairStratum,
|
|
219
|
+
T
|
|
220
|
+
>
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Samples cross-source pairs from each region and keeps up to `perStratum`
|
|
225
|
+
* per stratum, taking regions in turn.
|
|
226
|
+
*/
|
|
227
|
+
export async function addressPairSample(
|
|
228
|
+
options: AddressPairSampleOptions,
|
|
229
|
+
log: (line: string) => void = () => {}
|
|
230
|
+
): Promise<AddressPairSampleResult> {
|
|
231
|
+
const perStratum = options.perStratum ?? 60
|
|
232
|
+
const seed = options.seed ?? 1
|
|
233
|
+
const rowsPerRegion = options.rowsPerRegion ?? 400_000
|
|
234
|
+
const population = options.populationPerRegion
|
|
235
|
+
const regionCap = population ?? Math.ceil(perStratum / options.regions.length) + 2
|
|
236
|
+
const byRegion: Array<Record<AddressPairStratum, AddressPair[]>> = []
|
|
237
|
+
const candidates = strataRecord(() => 0)
|
|
238
|
+
const seenPairs = new Set<string>()
|
|
239
|
+
|
|
240
|
+
for (const region of options.regions) {
|
|
241
|
+
const files = addressLayerFiles(options.root, region, options.version)
|
|
242
|
+
|
|
243
|
+
using lookup = new DatabaseClient<unknown>(files.lookup, { readOnly: true })
|
|
244
|
+
using detail = new DatabaseClient<unknown>(files.detail, { readOnly: true })
|
|
245
|
+
|
|
246
|
+
const sources = new Map(
|
|
247
|
+
(lookup.prepare("SELECT source_id, name FROM source").all() as Array<{ source_id: number; name: string }>).map(
|
|
248
|
+
(row) => [row.source_id, row.name]
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
const stacks = new Map<string, number>()
|
|
253
|
+
|
|
254
|
+
// The detail read below rounds each record's point in SQLite too, so the keys of both sides agree.
|
|
255
|
+
for (const row of detail.prepare(addressPointStacksSQL(1)).all() as Array<{
|
|
256
|
+
source_id: number
|
|
257
|
+
la: number
|
|
258
|
+
lo: number
|
|
259
|
+
n: number
|
|
260
|
+
}>) {
|
|
261
|
+
stacks.set(`${row.source_id}@${row.la},${row.lo}`, row.n)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const readDetail = detail.prepare(
|
|
265
|
+
`SELECT address_id, source_id, source_record_id, number, unit, street_raw, postcode, names, lat, lon, placement,
|
|
266
|
+
authority, round(lat, 5) AS la, round(lon, 5) AS lo FROM address WHERE address_id = ?`
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
const record = (id: number): AddressPairRecord => {
|
|
270
|
+
const row = readDetail.get(id) as DetailRow | undefined
|
|
271
|
+
|
|
272
|
+
if (!row) throw new Error(`${files.detail} holds no address ${id}, which ${files.lookup} keys`)
|
|
273
|
+
const source = sources.get(row.source_id) ?? `source:${row.source_id}`
|
|
274
|
+
const names = parseJSONStrict<Array<{ level: string; value: string }>>(row.names)
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
source,
|
|
278
|
+
rank: sourceRank(source),
|
|
279
|
+
sourceRecordID: row.source_record_id,
|
|
280
|
+
authority: row.authority,
|
|
281
|
+
number: row.number,
|
|
282
|
+
unit: row.unit,
|
|
283
|
+
unitIdentifier: usUnitIdentifier(row.unit, { number: row.number, street: row.street_raw }),
|
|
284
|
+
streetRaw: row.street_raw,
|
|
285
|
+
postcode: row.postcode,
|
|
286
|
+
localities: names.filter((name) => name.level === "locality").map((name) => name.value),
|
|
287
|
+
placement: row.placement,
|
|
288
|
+
lat: row.lat,
|
|
289
|
+
lon: row.lon,
|
|
290
|
+
stack: stacks.get(`${row.source_id}@${row.la},${row.lo}`) ?? 1,
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const kept = strataRecord<AddressPair[]>(() => [])
|
|
295
|
+
const regionTotal = () => Object.values(kept).reduce((sum, pairs) => sum + pairs.length, 0)
|
|
296
|
+
const totalRows = (lookup.prepare("SELECT sum(records) AS n FROM source").get() as { n: number }).n
|
|
297
|
+
const stride = Math.max(1, Math.round(totalRows / rowsPerRegion))
|
|
298
|
+
|
|
299
|
+
const consider = (group: KeyRow[], fromLocality: boolean) => {
|
|
300
|
+
const ranked = group.map((row) => ({ row, rank: sourceRank(sources.get(row.source_id) ?? "") }))
|
|
301
|
+
|
|
302
|
+
for (const low of ranked) {
|
|
303
|
+
for (const high of ranked) {
|
|
304
|
+
if (high.rank >= low.rank) continue
|
|
305
|
+
|
|
306
|
+
const higher = record(high.row.address_id)
|
|
307
|
+
const lower = record(low.row.address_id)
|
|
308
|
+
|
|
309
|
+
if (fromLocality && higher.postcode === lower.postcode) continue
|
|
310
|
+
|
|
311
|
+
const degrees = Math.max(Math.abs(higher.lat - lower.lat), Math.abs(higher.lon - lower.lon))
|
|
312
|
+
|
|
313
|
+
if (fromLocality && degrees > POSTCODE_NEAR_DEGREES) continue
|
|
314
|
+
|
|
315
|
+
const pairID = `${region}:${higher.sourceRecordID}:${lower.sourceRecordID}`
|
|
316
|
+
|
|
317
|
+
// A key group can hold one record twice under one source id.
|
|
318
|
+
// The second copy would repeat the pair.
|
|
319
|
+
if (options.exclude?.has(pairID) || seenPairs.has(pairID)) continue
|
|
320
|
+
|
|
321
|
+
seenPairs.add(pairID)
|
|
322
|
+
|
|
323
|
+
const stratum = addressPairStratum(higher, lower, degrees, fromLocality)
|
|
324
|
+
|
|
325
|
+
candidates[stratum]++
|
|
326
|
+
|
|
327
|
+
if (population ? regionTotal() >= population : kept[stratum].length >= regionCap) continue
|
|
328
|
+
|
|
329
|
+
kept[stratum].push({
|
|
330
|
+
pairID,
|
|
331
|
+
region,
|
|
332
|
+
stratum,
|
|
333
|
+
higher,
|
|
334
|
+
lower,
|
|
335
|
+
distanceMeters: Math.round(haversine(higher.lat, higher.lon, lower.lat, lower.lon) * 1000 * 10) / 10,
|
|
336
|
+
ruleDrops: !fromLocality && higher.unit === lower.unit && degrees <= RULE_DEGREES,
|
|
337
|
+
adjudication: null,
|
|
338
|
+
adjudicator: null,
|
|
339
|
+
rationale: null,
|
|
340
|
+
})
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// A postcode key group fills every stratum but postcode-differs, and a locality key group
|
|
346
|
+
// fills only that one, so each pass stops once the strata it can fill are at the region's cap.
|
|
347
|
+
// A population draw instead stops once the region has yielded its quota.
|
|
348
|
+
const filled = (fromLocality: boolean) =>
|
|
349
|
+
population
|
|
350
|
+
? regionTotal() >= population
|
|
351
|
+
: Object.values(AddressPairStratum)
|
|
352
|
+
.filter((stratum) => (stratum === AddressPairStratum.PostcodeDiffers) === fromLocality)
|
|
353
|
+
.every((stratum) => stratum === AddressPairStratum.StackedPoint || kept[stratum].length >= regionCap)
|
|
354
|
+
|
|
355
|
+
for (const [table, fromLocality] of [
|
|
356
|
+
["key_postcode", false],
|
|
357
|
+
["key_locality", true],
|
|
358
|
+
] as const) {
|
|
359
|
+
let group: KeyRow[] = []
|
|
360
|
+
let read = 0
|
|
361
|
+
|
|
362
|
+
for (const row of lookup
|
|
363
|
+
.prepare(`SELECT scope, street, number, address_id, source_id FROM ${table}`)
|
|
364
|
+
.iterate() as Iterable<KeyRow>) {
|
|
365
|
+
if (++read > rowsPerRegion * stride || filled(fromLocality)) break
|
|
366
|
+
|
|
367
|
+
const last = group[0]
|
|
368
|
+
|
|
369
|
+
if (last && (last.scope !== row.scope || last.street !== row.street || last.number !== row.number)) {
|
|
370
|
+
if (new Set(group.map((member) => member.source_id)).size > 1) {
|
|
371
|
+
consider(group, fromLocality)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
group = []
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (group.length || hashFNV1a(`${row.scope}|${row.street}|${row.number}`, seed) % stride === 0) {
|
|
378
|
+
group.push(row)
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (new Set(group.map((member) => member.source_id)).size > 1) {
|
|
383
|
+
consider(group, fromLocality)
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
byRegion.push(kept)
|
|
388
|
+
|
|
389
|
+
log(
|
|
390
|
+
`${region}: ${Object.entries(kept)
|
|
391
|
+
.map(([stratum, pairs]) => `${stratum} ${pairs.length}`)
|
|
392
|
+
.join(", ")}`
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const pairs: AddressPair[] = []
|
|
397
|
+
const strata = strataRecord(() => 0)
|
|
398
|
+
|
|
399
|
+
for (const stratum of population ? [] : Object.values(AddressPairStratum)) {
|
|
400
|
+
for (let index = 0; strata[stratum] < perStratum; index++) {
|
|
401
|
+
let added = false
|
|
402
|
+
|
|
403
|
+
for (const kept of byRegion) {
|
|
404
|
+
const pair = kept[stratum][index]
|
|
405
|
+
|
|
406
|
+
if (pair && strata[stratum] < perStratum) {
|
|
407
|
+
pairs.push(pair)
|
|
408
|
+
|
|
409
|
+
strata[stratum]++
|
|
410
|
+
added = true
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (!added) break
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (population) {
|
|
419
|
+
for (const kept of byRegion) {
|
|
420
|
+
for (const [stratum, list] of Object.entries(kept) as Array<[AddressPairStratum, AddressPair[]]>) {
|
|
421
|
+
pairs.push(...list)
|
|
422
|
+
strata[stratum] += list.length
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (options.outJSONL) {
|
|
428
|
+
await writeLocalJSONLFile(pairs, options.outJSONL)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return { pairs, strata, candidates }
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function addressPairStratum(
|
|
435
|
+
higher: AddressPairRecord,
|
|
436
|
+
lower: AddressPairRecord,
|
|
437
|
+
degrees: number,
|
|
438
|
+
fromLocality: boolean
|
|
439
|
+
): AddressPairStratum {
|
|
440
|
+
if (higher.stack >= STACK_MIN_ADDRESSES || lower.stack >= STACK_MIN_ADDRESSES) return AddressPairStratum.StackedPoint
|
|
441
|
+
|
|
442
|
+
if (fromLocality) return AddressPairStratum.PostcodeDiffers
|
|
443
|
+
|
|
444
|
+
if ((higher.unitIdentifier == null) !== (lower.unitIdentifier == null)) return AddressPairStratum.UnitAgainstNone
|
|
445
|
+
|
|
446
|
+
if (higher.unitIdentifier !== lower.unitIdentifier) return AddressPairStratum.UnitDiffers
|
|
447
|
+
|
|
448
|
+
if (higher.unit !== lower.unit) return AddressPairStratum.UnitSpelling
|
|
449
|
+
|
|
450
|
+
return degrees > RULE_DEGREES ? AddressPairStratum.Distant : AddressPairStratum.Coincident
|
|
451
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
5
|
* Coverage reconciliation, the product output that replaces inspecting the map by eye.
|
|
7
6
|
*
|
|
8
|
-
* Each resolved entity is classified by the kind of source its records come from.
|
|
9
|
-
* source holds providers and facilities, such as NPPES org NPIs
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* Each resolved entity is classified by the kind of source its records come from.
|
|
8
|
+
* An eligibility source holds providers and facilities, such as NPPES org NPIs
|
|
9
|
+
* or TX HHSC nursing facilities.
|
|
10
|
+
*
|
|
11
|
+
* A funding source holds entities enrolled in a funding program, such as FCC Rural Health Care filings.
|
|
12
12
|
*
|
|
13
|
-
* The buckets are enrolled (both an eligibility and a funding record), eligible rather
|
|
14
|
-
* enrolled (an eligibility record with no funding record resolving to it), and funded
|
|
15
|
-
* in the eligibility set (a funding record with no eligibility record resolving to it).
|
|
13
|
+
* The buckets are enrolled (both an eligibility and a funding record), eligible rather
|
|
14
|
+
* than enrolled (an eligibility record with no funding record resolving to it), and funded
|
|
15
|
+
* rather than in the eligibility set (a funding record with no eligibility record resolving to it).
|
|
16
16
|
*
|
|
17
17
|
* This is strictly a set-membership reconciliation, never an allegation.
|
|
18
18
|
*
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
6
3
|
|
|
7
4
|
import { dataRootPath } from "@mailwoman/core/data-root"
|
|
8
5
|
import { writeLocalFile, writeLocalJSONFile } from "@mailwoman/core/fs/writers"
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
+
* Cross-source threshold sweep.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Resolve the sources once, then compare the Fellegi-Sunter baseline against the
|
|
8
|
+
* bundled GBT over a fine threshold sweep, scoring each arm on cross-source links,
|
|
9
|
+
* triple-source entities, total entities and phone corroboration.
|
|
9
10
|
*
|
|
10
11
|
* Run: `mailwoman registry scorer-eval threshold-sweep [--cap 2000] [--state TX]
|
|
11
12
|
* [--wof <admin.db>] [--data-root <dir>] [--out-md <md>]`
|
|
@@ -86,7 +87,7 @@ const entitySources = (e: ResolvedEntity): Set<string> =>
|
|
|
86
87
|
* Label-free precision proxy: does this cross-source entity have the same phone
|
|
87
88
|
* in records from two different sources?
|
|
88
89
|
*
|
|
89
|
-
* Phone
|
|
90
|
+
* Phone isn't the join key, so a match is independent corroboration of one facility.
|
|
90
91
|
* Entities without phone numbers on two cross-source records are unknown.
|
|
91
92
|
* Only checkable entities count.
|
|
92
93
|
*/
|
package/tools/dedup-ceiling.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
* Dedup ceiling measurement, answering how good is good enough for dedup from the data
|
|
6
|
+
* rather than from a round number.
|
|
7
|
+
*
|
|
8
|
+
* The residual dedup error is over-merge: distinct co-located providers
|
|
9
|
+
* (different NPIs at one address) fused because a shared address outvotes a disagreeing name.
|
|
10
|
+
* The irreducible part is the set of co-located distinct-NPI pairs whose name text is
|
|
11
|
+
* also near identical, so no name or organization feature can separate them.
|
|
5
12
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* (different NPIs at one address) fused because a shared address outvotes a disagreeing name. The
|
|
9
|
-
* irreducible part is the set of co-located distinct-NPI pairs whose name text is also near
|
|
10
|
-
* identical, so no name or organization feature can separate them.
|
|
13
|
+
* This measures that floor directly and without labels, using NPI as the distinctness truth.
|
|
14
|
+
* It is geocode-free on purpose, so it can run at large N in seconds.
|
|
11
15
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* matcher's own `addressFrequencyKey`, and "same name" uses a normalized token Jaccard over the
|
|
15
|
-
* legal business name.
|
|
16
|
+
* "Same address" uses the matcher's own `addressFrequencyKey`, and "same name"
|
|
17
|
+
* uses a normalized token Jaccard over the legal business name.
|
|
16
18
|
*
|
|
17
19
|
* Run: `mailwoman registry dedup-ceiling [--cap 50000] [--state TX] [--sources <dir>] [--tau 0.7]
|
|
18
20
|
* [--out-md <md>]`
|
|
@@ -136,7 +138,7 @@ export async function dedupCeiling(
|
|
|
136
138
|
// The irreducible false-merge rate among co-located distinct pairs is collide/pairs.
|
|
137
139
|
// Report the collision rate directly with a precision-ceiling band: optimistic counts
|
|
138
140
|
// only `collide`, and conservative counts `collide` plus half of `mid`.
|
|
139
|
-
// Recall
|
|
141
|
+
// Recall isn't binding here, so the F1 ceiling tracks the precision ceiling.
|
|
140
142
|
const pct = formatPercent
|
|
141
143
|
|
|
142
144
|
const lines: string[] = [
|
package/tools/eval-geocoder.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
+
* The injected-geocoder interface for the record-matcher tools.
|
|
5
6
|
*
|
|
6
|
-
* The
|
|
7
|
-
*
|
|
8
|
-
* `@mailwoman/entity-resolution` and the reverse import would cycle the workspace graph.
|
|
9
|
-
* takes an {@linkcode EvalGeocoderFactory} the CLI command constructs
|
|
10
|
-
* `mailwoman/geocode-core` (see `mailwoman/commands/registry/run.tsx`).
|
|
7
|
+
* The registry package never imports the heavy runtime
|
|
8
|
+
* (neural parser, WOF resolver, per-state extracts), since `mailwoman` depends on
|
|
9
|
+
* `@mailwoman/entity-resolution` and the reverse import would cycle the workspace graph.
|
|
10
|
+
* Each tool instead takes an {@linkcode EvalGeocoderFactory} the CLI command constructs
|
|
11
|
+
* from `mailwoman/geocode-core` (see `mailwoman/commands/registry/run.tsx`).
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
import type { CaseNormalization } from "@mailwoman/core/pipeline"
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
+
* Admin-tier wrong-region probe.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* population-dominant foreign namesake instead of the in-state Texas city.
|
|
9
|
-
* set of TX namesake cities, with and without ZIP.
|
|
10
|
-
* box.
|
|
7
|
+
* When no street extract covers an address, the admin cascade can resolve the
|
|
8
|
+
* locality by name and, when the region or postcode constraint is weak, pick the
|
|
9
|
+
* population-dominant foreign namesake instead of the in-state Texas city.
|
|
10
|
+
* This probes a curated set of TX namesake cities, with and without ZIP.
|
|
11
|
+
* It flags any result outside the Texas bounding box.
|
|
11
12
|
*
|
|
12
13
|
* Run: `mailwoman registry scorer-eval namesake-probe`
|
|
13
14
|
*/
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
+
* Geocoder validation against provided coordinates.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* with mailwoman's parser and resolver, then measure the
|
|
9
|
-
* broken down by resolution tier.
|
|
7
|
+
* TX HHSC's nursing-facilities registry ships a `Geo Location` (`lat,lon`) per
|
|
8
|
+
* facility alongside its physical address.
|
|
9
|
+
* Geocode the address with mailwoman's parser and resolver, then measure the
|
|
10
|
+
* great-circle delta to the provided point, broken down by resolution tier.
|
|
10
11
|
*
|
|
11
|
-
* The provided coordinate is treated as ground truth for this eval, with the caveat
|
|
12
|
-
* itself a third-party geocode of unknown provenance.
|
|
13
|
-
* rather than automatically our error.
|
|
12
|
+
* The provided coordinate is treated as ground truth for this eval, with the caveat
|
|
13
|
+
* that it is itself a third-party geocode of unknown provenance.
|
|
14
|
+
* A large delta is a discrepancy to inspect rather than automatically our error.
|
|
14
15
|
*
|
|
15
16
|
* Run: `mailwoman registry scorer-eval vs-provided-coords [--max 1176] [--wof <admin.db>]
|
|
16
17
|
* [--data-root <dir>] [--out-md docs/articles/evals/resolver-geo/<date>-...md]`
|
package/tools/gold-set-sample.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
+
* Gold-set sampling for adjudication.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* (
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* adjudicated gold set must cover.
|
|
7
|
+
* The programmatic entity truth (`nppes-dedup-benchmark.ts`) collapses only NPPES-flagged subparts
|
|
8
|
+
* (Is-Subpart plus parent LBN/TIN), so it cannot settle the ambiguous co-located collisions:
|
|
9
|
+
* distinct NPIs at one address with near-identical name text and no subpart flag for the same parent.
|
|
10
|
+
* NPI truth and programmatic rules may disagree on these pairs.
|
|
11
|
+
* A frozen adjudicated gold set must cover.
|
|
12
12
|
*
|
|
13
13
|
* This scans the full TX registry without geocoding and writes each pair as a JSONL row containing
|
|
14
|
-
* both records' fields (org name, address, authorized official, taxonomy, subpart and parent
|
|
15
|
-
*
|
|
16
|
-
* can then label same real-world entity or not.
|
|
14
|
+
* both records' fields (org name, address, authorized official, taxonomy, subpart and parent flags)
|
|
15
|
+
* plus the programmatic verdict.
|
|
16
|
+
* An adjudicator (human or LLM-as-judge, flagged as such) can then label same real-world entity or not.
|
|
17
17
|
*
|
|
18
18
|
* Run: `mailwoman registry gold-set-sample [--cap 200000] [--state TX] [--tau 0.7] [--n 300]
|
|
19
19
|
* [--out-jsonl <path>]`
|