@mailwoman/entity-resolution 11.0.0 → 11.1.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 +2 -2
- 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,184 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
/**
|
|
4
|
+
* Grades duplicate-detection arms against an adjudicated address pair set, per stratum.
|
|
5
|
+
*
|
|
6
|
+
* An arm predicts, for each pair, whether the lower-ranked row repeats the
|
|
7
|
+
* higher-ranked row's delivery point and may be dropped.
|
|
8
|
+
* Each arm reads the unit as a precondition: two rows whose unit identifiers differ,
|
|
9
|
+
* or of which one states a unit and the other none, are different delivery points,
|
|
10
|
+
* because dropping the unit row would lose the unit.
|
|
11
|
+
*
|
|
12
|
+
* - `rule` is the deterministic rule the layer build applies: the same postcode key,
|
|
13
|
+
* the same unit text, and points within 0.002 degrees.
|
|
14
|
+
* - `rule-unit-identifier` is that rule with the unit compared by identifier, so `#2` and `UNIT 2` agree.
|
|
15
|
+
* - `fellegi-sunter` scores the postcode, locality and distance with `@mailwoman/match`.
|
|
16
|
+
* Its `m` and `u` are fitted by EM on an unlabeled population of candidate pairs, never on the labels.
|
|
17
|
+
* A point a source shares among more than five addresses locates none of them,
|
|
18
|
+
* so a pair touching one has no distance evidence.
|
|
19
|
+
*
|
|
20
|
+
* A pair adjudicated `unsure` is left out of every count.
|
|
21
|
+
*/
|
|
22
|
+
import { usUnitIdentifier } from "@mailwoman/codex/us/unit/designator";
|
|
23
|
+
import { agreementPattern, distanceComparison, estimateParameters, scorePair, } from "@mailwoman/match";
|
|
24
|
+
import { ADDRESS_DUPLICATE_STACK_LIMIT, addressLocalityKeys } from "@mailwoman/resolver-wof-sqlite/address/duplicate";
|
|
25
|
+
import { RULE_DEGREES, } from "#tools/address-pairs/sample";
|
|
26
|
+
/**
|
|
27
|
+
* A record's unit identifier, read again from its unit text against its own number and street.
|
|
28
|
+
*/
|
|
29
|
+
export function unitIdentifierOf(record) {
|
|
30
|
+
return usUnitIdentifier(record.unit, { number: record.number, street: record.streetRaw });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Whether two records state the same unit by identifier, or neither states one.
|
|
34
|
+
*/
|
|
35
|
+
export function unitsAgree(a, b) {
|
|
36
|
+
return unitIdentifierOf(a) === unitIdentifierOf(b);
|
|
37
|
+
}
|
|
38
|
+
function grade(outcomes) {
|
|
39
|
+
let truePositive = 0;
|
|
40
|
+
let falsePositive = 0;
|
|
41
|
+
let falseNegative = 0;
|
|
42
|
+
let trueNegative = 0;
|
|
43
|
+
for (const { predicted, label } of outcomes) {
|
|
44
|
+
if (predicted && label) {
|
|
45
|
+
truePositive++;
|
|
46
|
+
}
|
|
47
|
+
else if (predicted) {
|
|
48
|
+
falsePositive++;
|
|
49
|
+
}
|
|
50
|
+
else if (label) {
|
|
51
|
+
falseNegative++;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
trueNegative++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
truePositive,
|
|
59
|
+
falsePositive,
|
|
60
|
+
falseNegative,
|
|
61
|
+
trueNegative,
|
|
62
|
+
precision: truePositive + falsePositive ? truePositive / (truePositive + falsePositive) : null,
|
|
63
|
+
recall: truePositive + falseNegative ? truePositive / (truePositive + falseNegative) : null,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function gradeArm(arm, pairs, predict) {
|
|
67
|
+
const rows = pairs.map((pair) => ({ pair, label: pair.adjudication === "same-address", ...predict(pair) }));
|
|
68
|
+
const strata = new Set(rows.map((row) => row.pair.stratum));
|
|
69
|
+
return {
|
|
70
|
+
arm,
|
|
71
|
+
overall: grade(rows),
|
|
72
|
+
byStratum: Object.fromEntries([...strata].map((stratum) => [stratum, grade(rows.filter((row) => row.pair.stratum === stratum))])),
|
|
73
|
+
errors: rows
|
|
74
|
+
.filter((row) => row.predicted !== row.label)
|
|
75
|
+
.map((row) => ({
|
|
76
|
+
pairID: row.pair.pairID,
|
|
77
|
+
stratum: row.pair.stratum,
|
|
78
|
+
predicted: row.predicted,
|
|
79
|
+
label: row.label,
|
|
80
|
+
score: row.score,
|
|
81
|
+
})),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const postcodeComparison = {
|
|
85
|
+
name: "postcode",
|
|
86
|
+
levels: [
|
|
87
|
+
{ label: "same", m: 0.9, u: 0.5 },
|
|
88
|
+
{ label: "different", m: 0.1, u: 0.5 },
|
|
89
|
+
],
|
|
90
|
+
assess: (a, b) => a.postcode && b.postcode && a.postcode !== "0" && b.postcode !== "0" ? (a.postcode === b.postcode ? 0 : 1) : -1,
|
|
91
|
+
};
|
|
92
|
+
const localityKeys = (record) => addressLocalityKeys(record.localities);
|
|
93
|
+
const localityComparison = {
|
|
94
|
+
name: "locality",
|
|
95
|
+
levels: [
|
|
96
|
+
{ label: "shared-name", m: 0.85, u: 0.3 },
|
|
97
|
+
{ label: "no-shared-name", m: 0.15, u: 0.7 },
|
|
98
|
+
],
|
|
99
|
+
assess(a, b) {
|
|
100
|
+
const ka = localityKeys(a);
|
|
101
|
+
const kb = localityKeys(b);
|
|
102
|
+
if (!ka.size || !kb.size)
|
|
103
|
+
return -1;
|
|
104
|
+
return [...ka].some((name) => kb.has(name)) ? 0 : 1;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Seed distance levels for address points: one building, one block, one neighborhood, one town, and farther.
|
|
109
|
+
*/
|
|
110
|
+
export const ADDRESS_POINT_DISTANCE_LEVELS = [
|
|
111
|
+
{ label: "same-building", maxKm: 0.05, m: 0.6, u: 0.05 },
|
|
112
|
+
{ label: "same-block", maxKm: 0.5, m: 0.3, u: 0.15 },
|
|
113
|
+
{ label: "same-neighborhood", maxKm: 2, m: 0.07, u: 0.2 },
|
|
114
|
+
{ label: "same-town", maxKm: 10, m: 0.02, u: 0.3 },
|
|
115
|
+
{ label: "far", m: 0.01, u: 0.3 },
|
|
116
|
+
];
|
|
117
|
+
/**
|
|
118
|
+
* Builds the address-point Fellegi-Sunter model over postcode, locality and distance.
|
|
119
|
+
*
|
|
120
|
+
* The house number is left out: every pair of a postcode key group shares it, so it gives no evidence.
|
|
121
|
+
*/
|
|
122
|
+
export function addressPointModel() {
|
|
123
|
+
const distance = distanceComparison({
|
|
124
|
+
name: "distance",
|
|
125
|
+
extract: (r) => ({ latitude: r.lat, longitude: r.lon }),
|
|
126
|
+
levels: ADDRESS_POINT_DISTANCE_LEVELS.map((level) => ({ ...level })),
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
lambda: 0.5,
|
|
130
|
+
comparisons: [
|
|
131
|
+
postcodeComparison,
|
|
132
|
+
localityComparison,
|
|
133
|
+
{
|
|
134
|
+
...distance,
|
|
135
|
+
assess: (a, b) => a.stack > ADDRESS_DUPLICATE_STACK_LIMIT || b.stack > ADDRESS_DUPLICATE_STACK_LIMIT
|
|
136
|
+
? -1
|
|
137
|
+
: distance.assess(a, b),
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Fits the address-point model by EM on the population pairs whose units agree, the pairs the model decides.
|
|
144
|
+
*/
|
|
145
|
+
export function fitAddressPointModel(population) {
|
|
146
|
+
const base = addressPointModel();
|
|
147
|
+
const decided = population.filter((pair) => unitsAgree(pair.higher, pair.lower));
|
|
148
|
+
const patterns = decided.map((pair) => agreementPattern(base.comparisons, pair.higher, pair.lower));
|
|
149
|
+
const fitted = estimateParameters(base, patterns);
|
|
150
|
+
return { model: fitted.model, lambda: fitted.lambda, converged: fitted.converged, fittedOn: decided.length };
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Grades the three arms over the adjudicated pairs.
|
|
154
|
+
*
|
|
155
|
+
* @param population The unlabeled candidate pairs EM is fitted on.
|
|
156
|
+
* @param threshold The match probability at or above which the Fellegi-Sunter arm drops the lower row.
|
|
157
|
+
*/
|
|
158
|
+
export function gradeAddressPairs(pairs, population, threshold = 0.5) {
|
|
159
|
+
const graded = pairs.filter((pair) => pair.adjudication === "same-address" || pair.adjudication === "different-address");
|
|
160
|
+
const fitted = fitAddressPointModel(population);
|
|
161
|
+
const sameKey = (pair) => pair.stratum !== "postcode-differs";
|
|
162
|
+
const degrees = (pair) => Math.max(Math.abs(pair.higher.lat - pair.lower.lat), Math.abs(pair.higher.lon - pair.lower.lon));
|
|
163
|
+
const arms = [
|
|
164
|
+
gradeArm("rule", graded, (pair) => ({ predicted: pair.ruleDrops, score: null })),
|
|
165
|
+
gradeArm("rule-unit-identifier", graded, (pair) => ({
|
|
166
|
+
predicted: sameKey(pair) && unitsAgree(pair.higher, pair.lower) && degrees(pair) <= RULE_DEGREES,
|
|
167
|
+
score: null,
|
|
168
|
+
})),
|
|
169
|
+
gradeArm("fellegi-sunter", graded, (pair) => {
|
|
170
|
+
const { probability } = scorePair(fitted.model, pair.higher, pair.lower);
|
|
171
|
+
return { predicted: unitsAgree(pair.higher, pair.lower) && probability >= threshold, score: probability };
|
|
172
|
+
}),
|
|
173
|
+
];
|
|
174
|
+
return {
|
|
175
|
+
arms,
|
|
176
|
+
model: fitted.model,
|
|
177
|
+
lambda: fitted.lambda,
|
|
178
|
+
converged: fitted.converged,
|
|
179
|
+
fittedOn: fitted.fittedOn,
|
|
180
|
+
graded: graded.length,
|
|
181
|
+
unsure: pairs.length - graded.length,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=grade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grade.js","sourceRoot":"","sources":["../../../tools/address-pairs/grade.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EACN,gBAAgB,EAGhB,kBAAkB,EAClB,kBAAkB,EAElB,SAAS,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAA;AAErH,OAAO,EAIN,YAAY,GACZ,MAAM,6BAA6B,CAAA;AAiCpC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAyB;IACzD,OAAO,gBAAgB,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,E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MAAM;KACpC,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { PathBuilderLike } from "path-ts";
|
|
2
|
+
/**
|
|
3
|
+
* The failure shapes a pair is sampled by, in the order a pair is assigned to them.
|
|
4
|
+
*/
|
|
5
|
+
export declare const AddressPairStratum: {
|
|
6
|
+
/**
|
|
7
|
+
* Either point holds 100 or more distinct street-and-number pairs from its source.
|
|
8
|
+
*/
|
|
9
|
+
readonly StackedPoint: "stacked-point";
|
|
10
|
+
/**
|
|
11
|
+
* The two rows share a locality, street and number but state different postcodes.
|
|
12
|
+
*/
|
|
13
|
+
readonly PostcodeDiffers: "postcode-differs";
|
|
14
|
+
/**
|
|
15
|
+
* One row states a unit and the other states none.
|
|
16
|
+
*/
|
|
17
|
+
readonly UnitAgainstNone: "unit-against-none";
|
|
18
|
+
/**
|
|
19
|
+
* Both rows state a unit, and the identifiers differ.
|
|
20
|
+
*/
|
|
21
|
+
readonly UnitDiffers: "unit-differs";
|
|
22
|
+
/**
|
|
23
|
+
* Both rows state a unit written differently whose identifiers agree, such as `#2` and `UNIT 2`.
|
|
24
|
+
*/
|
|
25
|
+
readonly UnitSpelling: "unit-spelling";
|
|
26
|
+
/**
|
|
27
|
+
* The units agree and the points lie farther apart than the deterministic rule's 0.002 degrees.
|
|
28
|
+
*/
|
|
29
|
+
readonly Distant: "distant";
|
|
30
|
+
/**
|
|
31
|
+
* The units agree and the points lie within 0.002 degrees.
|
|
32
|
+
*/
|
|
33
|
+
readonly Coincident: "coincident";
|
|
34
|
+
};
|
|
35
|
+
export type AddressPairStratum = (typeof AddressPairStratum)[keyof typeof AddressPairStratum];
|
|
36
|
+
/**
|
|
37
|
+
* One address point as the pair set records it.
|
|
38
|
+
*/
|
|
39
|
+
export interface AddressPairRecord {
|
|
40
|
+
source: string;
|
|
41
|
+
rank: number;
|
|
42
|
+
sourceRecordID: string;
|
|
43
|
+
authority: string | null;
|
|
44
|
+
number: string;
|
|
45
|
+
unit: string | null;
|
|
46
|
+
unitIdentifier: string | null;
|
|
47
|
+
streetRaw: string;
|
|
48
|
+
postcode: string | null;
|
|
49
|
+
localities: string[];
|
|
50
|
+
placement: string | null;
|
|
51
|
+
lat: number;
|
|
52
|
+
lon: number;
|
|
53
|
+
/**
|
|
54
|
+
* Distinct street-and-number pairs this record's source places at the same point, rounded to 1e-5 degrees.
|
|
55
|
+
*/
|
|
56
|
+
stack: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One sampled pair, with the evidence an adjudicator reads and the fields the adjudicator fills.
|
|
60
|
+
*/
|
|
61
|
+
export interface AddressPair {
|
|
62
|
+
pairID: string;
|
|
63
|
+
region: string;
|
|
64
|
+
stratum: AddressPairStratum;
|
|
65
|
+
higher: AddressPairRecord;
|
|
66
|
+
lower: AddressPairRecord;
|
|
67
|
+
distanceMeters: number;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the deterministic rule drops the lower row: same postcode key,
|
|
70
|
+
* same raw unit, points within 0.002°.
|
|
71
|
+
*/
|
|
72
|
+
ruleDrops: boolean;
|
|
73
|
+
adjudication: "same-address" | "different-address" | "unsure" | null;
|
|
74
|
+
adjudicator: string | null;
|
|
75
|
+
rationale: string | null;
|
|
76
|
+
}
|
|
77
|
+
export interface AddressPairSampleOptions {
|
|
78
|
+
/**
|
|
79
|
+
* The directory holding `addresses/<region>/<version>/`.
|
|
80
|
+
*/
|
|
81
|
+
root: PathBuilderLike;
|
|
82
|
+
version: string;
|
|
83
|
+
regions: readonly string[];
|
|
84
|
+
/**
|
|
85
|
+
* The pairs kept per stratum across all regions.
|
|
86
|
+
*
|
|
87
|
+
* @defaultValue `60`
|
|
88
|
+
*/
|
|
89
|
+
perStratum?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Selects which key groups are read.
|
|
92
|
+
* The same seed over the same layer samples the same pairs.
|
|
93
|
+
*
|
|
94
|
+
* @defaultValue `1`
|
|
95
|
+
*/
|
|
96
|
+
seed?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Rows of each region's key table to read, at most, before the region's sample closes.
|
|
99
|
+
*
|
|
100
|
+
* @defaultValue `400_000`
|
|
101
|
+
*/
|
|
102
|
+
rowsPerRegion?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Draws the unlabeled population EM is fitted on instead of the stratified set:
|
|
105
|
+
* every candidate pair of each sampled key group is kept, without strata caps,
|
|
106
|
+
* until a region has yielded this number of pairs.
|
|
107
|
+
*/
|
|
108
|
+
populationPerRegion?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Pair ids left out of the sample, such as an earlier set's, so a held-out set shares no pair with it.
|
|
111
|
+
*/
|
|
112
|
+
exclude?: ReadonlySet<string>;
|
|
113
|
+
outJSONL?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface AddressPairSampleResult {
|
|
116
|
+
pairs: AddressPair[];
|
|
117
|
+
/**
|
|
118
|
+
* Pairs kept per stratum.
|
|
119
|
+
*/
|
|
120
|
+
strata: Record<AddressPairStratum, number>;
|
|
121
|
+
/**
|
|
122
|
+
* Candidate pairs seen per stratum before the caps applied.
|
|
123
|
+
*/
|
|
124
|
+
candidates: Record<AddressPairStratum, number>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* How far apart, in degrees on each axis, the deterministic rule the layer build applied
|
|
128
|
+
* before #2978 let two points of one address lie.
|
|
129
|
+
* The `rule` arm of the grade reads it from here.
|
|
130
|
+
*/
|
|
131
|
+
export declare const RULE_DEGREES = 0.002;
|
|
132
|
+
/**
|
|
133
|
+
* Samples cross-source pairs from each region and keeps up to `perStratum`
|
|
134
|
+
* per stratum, taking regions in turn.
|
|
135
|
+
*/
|
|
136
|
+
export declare function addressPairSample(options: AddressPairSampleOptions, log?: (line: string) => void): Promise<AddressPairSampleResult>;
|
|
137
|
+
//# sourceMappingURL=sample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample.d.ts","sourceRoot":"","sources":["../../../tools/address-pairs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only OR LicenseRef-Commercial
|
|
3
|
+
/**
|
|
4
|
+
* Samples cross-source address-point pairs from a built address layer for adjudication.
|
|
5
|
+
*
|
|
6
|
+
* A pair joins a row from a higher-ranked source with a row from a lower-ranked one:
|
|
7
|
+
* `usgov-nad`, then the OpenAddresses runs read directly, then Overture's datasets.
|
|
8
|
+
* Pairs come from two kinds of key group.
|
|
9
|
+
*
|
|
10
|
+
* A postcode key group holds rows that share a postcode, street key and house number.
|
|
11
|
+
* A locality key group holds rows that share a locality, street key and number
|
|
12
|
+
* but state different postcodes.
|
|
13
|
+
* A wrong postcode on one side shows there.
|
|
14
|
+
*
|
|
15
|
+
* Each pair lands in one stratum by its failure shape.
|
|
16
|
+
* Each stratum is capped per region, so every region in the run contributes pairs
|
|
17
|
+
* and the densest region cannot fill a stratum.
|
|
18
|
+
*
|
|
19
|
+
* Every row stores both records in full, the measured evidence
|
|
20
|
+
* (the distance, each unit's identifier, each point's stack size) and the verdict
|
|
21
|
+
* of the deterministic rule the layer build applies.
|
|
22
|
+
* The adjudication fields stay `null` for a human or a flagged LLM judge to fill.
|
|
23
|
+
*
|
|
24
|
+
* Run: `mailwoman registry address-pair-sample --layer-version 2026-11-08 [--regions us-ny,us-co] [--per-stratum 60]
|
|
25
|
+
* [--seed 1] --out-jsonl <path>`
|
|
26
|
+
*/
|
|
27
|
+
import { usUnitIdentifier } from "@mailwoman/codex/us/unit/designator";
|
|
28
|
+
import { hashFNV1a } from "@mailwoman/core/coarse-placer/fnv-hash";
|
|
29
|
+
import { writeLocalJSONLFile } from "@mailwoman/core/fs/writers";
|
|
30
|
+
import { parseJSONStrict } from "@mailwoman/core/json";
|
|
31
|
+
import { addressLayerFiles } from "@mailwoman/resolver-wof-sqlite/address/keys/layout";
|
|
32
|
+
import { addressPointStacksSQL } from "@mailwoman/resolver-wof-sqlite/address/stack";
|
|
33
|
+
import { haversine } from "@mailwoman/spatial/geometries/point/distance";
|
|
34
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
35
|
+
/**
|
|
36
|
+
* The failure shapes a pair is sampled by, in the order a pair is assigned to them.
|
|
37
|
+
*/
|
|
38
|
+
export const AddressPairStratum = {
|
|
39
|
+
/**
|
|
40
|
+
* Either point holds 100 or more distinct street-and-number pairs from its source.
|
|
41
|
+
*/
|
|
42
|
+
StackedPoint: "stacked-point",
|
|
43
|
+
/**
|
|
44
|
+
* The two rows share a locality, street and number but state different postcodes.
|
|
45
|
+
*/
|
|
46
|
+
PostcodeDiffers: "postcode-differs",
|
|
47
|
+
/**
|
|
48
|
+
* One row states a unit and the other states none.
|
|
49
|
+
*/
|
|
50
|
+
UnitAgainstNone: "unit-against-none",
|
|
51
|
+
/**
|
|
52
|
+
* Both rows state a unit, and the identifiers differ.
|
|
53
|
+
*/
|
|
54
|
+
UnitDiffers: "unit-differs",
|
|
55
|
+
/**
|
|
56
|
+
* Both rows state a unit written differently whose identifiers agree, such as `#2` and `UNIT 2`.
|
|
57
|
+
*/
|
|
58
|
+
UnitSpelling: "unit-spelling",
|
|
59
|
+
/**
|
|
60
|
+
* The units agree and the points lie farther apart than the deterministic rule's 0.002 degrees.
|
|
61
|
+
*/
|
|
62
|
+
Distant: "distant",
|
|
63
|
+
/**
|
|
64
|
+
* The units agree and the points lie within 0.002 degrees.
|
|
65
|
+
*/
|
|
66
|
+
Coincident: "coincident",
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The stack size from which a pair lands in the stacked-point stratum.
|
|
70
|
+
*
|
|
71
|
+
* Every record's stack is recorded exactly, whatever its size, so the rule the layer
|
|
72
|
+
* build applies to smaller stacks grades on the same values.
|
|
73
|
+
*/
|
|
74
|
+
const STACK_MIN_ADDRESSES = 100;
|
|
75
|
+
/**
|
|
76
|
+
* How far apart, in degrees on each axis, the deterministic rule the layer build applied
|
|
77
|
+
* before #2978 let two points of one address lie.
|
|
78
|
+
* The `rule` arm of the grade reads it from here.
|
|
79
|
+
*/
|
|
80
|
+
export const RULE_DEGREES = 0.002;
|
|
81
|
+
const POSTCODE_NEAR_DEGREES = 0.005;
|
|
82
|
+
function sourceRank(name) {
|
|
83
|
+
if (name === "usgov-nad")
|
|
84
|
+
return 0;
|
|
85
|
+
return name.startsWith("openaddresses:") ? 1 : 2;
|
|
86
|
+
}
|
|
87
|
+
function strataRecord(value) {
|
|
88
|
+
return Object.fromEntries(Object.values(AddressPairStratum).map((stratum) => [stratum, value()]));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Samples cross-source pairs from each region and keeps up to `perStratum`
|
|
92
|
+
* per stratum, taking regions in turn.
|
|
93
|
+
*/
|
|
94
|
+
export async function addressPairSample(options, log = () => { }) {
|
|
95
|
+
const perStratum = options.perStratum ?? 60;
|
|
96
|
+
const seed = options.seed ?? 1;
|
|
97
|
+
const rowsPerRegion = options.rowsPerRegion ?? 400_000;
|
|
98
|
+
const population = options.populationPerRegion;
|
|
99
|
+
const regionCap = population ?? Math.ceil(perStratum / options.regions.length) + 2;
|
|
100
|
+
const byRegion = [];
|
|
101
|
+
const candidates = strataRecord(() => 0);
|
|
102
|
+
const seenPairs = new Set();
|
|
103
|
+
for (const region of options.regions) {
|
|
104
|
+
const files = addressLayerFiles(options.root, region, options.version);
|
|
105
|
+
using lookup = new DatabaseClient(files.lookup, { readOnly: true });
|
|
106
|
+
using detail = new DatabaseClient(files.detail, { readOnly: true });
|
|
107
|
+
const sources = new Map(lookup.prepare("SELECT source_id, name FROM source").all().map((row) => [row.source_id, row.name]));
|
|
108
|
+
const stacks = new Map();
|
|
109
|
+
// The detail read below rounds each record's point in SQLite too, so the keys of both sides agree.
|
|
110
|
+
for (const row of detail.prepare(addressPointStacksSQL(1)).all()) {
|
|
111
|
+
stacks.set(`${row.source_id}@${row.la},${row.lo}`, row.n);
|
|
112
|
+
}
|
|
113
|
+
const readDetail = detail.prepare(`SELECT address_id, source_id, source_record_id, number, unit, street_raw, postcode, names, lat, lon, placement,
|
|
114
|
+
authority, round(lat, 5) AS la, round(lon, 5) AS lo FROM address WHERE address_id = ?`);
|
|
115
|
+
const record = (id) => {
|
|
116
|
+
const row = readDetail.get(id);
|
|
117
|
+
if (!row)
|
|
118
|
+
throw new Error(`${files.detail} holds no address ${id}, which ${files.lookup} keys`);
|
|
119
|
+
const source = sources.get(row.source_id) ?? `source:${row.source_id}`;
|
|
120
|
+
const names = parseJSONStrict(row.names);
|
|
121
|
+
return {
|
|
122
|
+
source,
|
|
123
|
+
rank: sourceRank(source),
|
|
124
|
+
sourceRecordID: row.source_record_id,
|
|
125
|
+
authority: row.authority,
|
|
126
|
+
number: row.number,
|
|
127
|
+
unit: row.unit,
|
|
128
|
+
unitIdentifier: usUnitIdentifier(row.unit, { number: row.number, street: row.street_raw }),
|
|
129
|
+
streetRaw: row.street_raw,
|
|
130
|
+
postcode: row.postcode,
|
|
131
|
+
localities: names.filter((name) => name.level === "locality").map((name) => name.value),
|
|
132
|
+
placement: row.placement,
|
|
133
|
+
lat: row.lat,
|
|
134
|
+
lon: row.lon,
|
|
135
|
+
stack: stacks.get(`${row.source_id}@${row.la},${row.lo}`) ?? 1,
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
const kept = strataRecord(() => []);
|
|
139
|
+
const regionTotal = () => Object.values(kept).reduce((sum, pairs) => sum + pairs.length, 0);
|
|
140
|
+
const totalRows = lookup.prepare("SELECT sum(records) AS n FROM source").get().n;
|
|
141
|
+
const stride = Math.max(1, Math.round(totalRows / rowsPerRegion));
|
|
142
|
+
const consider = (group, fromLocality) => {
|
|
143
|
+
const ranked = group.map((row) => ({ row, rank: sourceRank(sources.get(row.source_id) ?? "") }));
|
|
144
|
+
for (const low of ranked) {
|
|
145
|
+
for (const high of ranked) {
|
|
146
|
+
if (high.rank >= low.rank)
|
|
147
|
+
continue;
|
|
148
|
+
const higher = record(high.row.address_id);
|
|
149
|
+
const lower = record(low.row.address_id);
|
|
150
|
+
if (fromLocality && higher.postcode === lower.postcode)
|
|
151
|
+
continue;
|
|
152
|
+
const degrees = Math.max(Math.abs(higher.lat - lower.lat), Math.abs(higher.lon - lower.lon));
|
|
153
|
+
if (fromLocality && degrees > POSTCODE_NEAR_DEGREES)
|
|
154
|
+
continue;
|
|
155
|
+
const pairID = `${region}:${higher.sourceRecordID}:${lower.sourceRecordID}`;
|
|
156
|
+
// A key group can hold one record twice under one source id.
|
|
157
|
+
// The second copy would repeat the pair.
|
|
158
|
+
if (options.exclude?.has(pairID) || seenPairs.has(pairID))
|
|
159
|
+
continue;
|
|
160
|
+
seenPairs.add(pairID);
|
|
161
|
+
const stratum = addressPairStratum(higher, lower, degrees, fromLocality);
|
|
162
|
+
candidates[stratum]++;
|
|
163
|
+
if (population ? regionTotal() >= population : kept[stratum].length >= regionCap)
|
|
164
|
+
continue;
|
|
165
|
+
kept[stratum].push({
|
|
166
|
+
pairID,
|
|
167
|
+
region,
|
|
168
|
+
stratum,
|
|
169
|
+
higher,
|
|
170
|
+
lower,
|
|
171
|
+
distanceMeters: Math.round(haversine(higher.lat, higher.lon, lower.lat, lower.lon) * 1000 * 10) / 10,
|
|
172
|
+
ruleDrops: !fromLocality && higher.unit === lower.unit && degrees <= RULE_DEGREES,
|
|
173
|
+
adjudication: null,
|
|
174
|
+
adjudicator: null,
|
|
175
|
+
rationale: null,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
// A postcode key group fills every stratum but postcode-differs, and a locality key group
|
|
181
|
+
// fills only that one, so each pass stops once the strata it can fill are at the region's cap.
|
|
182
|
+
// A population draw instead stops once the region has yielded its quota.
|
|
183
|
+
const filled = (fromLocality) => population
|
|
184
|
+
? regionTotal() >= population
|
|
185
|
+
: Object.values(AddressPairStratum)
|
|
186
|
+
.filter((stratum) => (stratum === AddressPairStratum.PostcodeDiffers) === fromLocality)
|
|
187
|
+
.every((stratum) => stratum === AddressPairStratum.StackedPoint || kept[stratum].length >= regionCap);
|
|
188
|
+
for (const [table, fromLocality] of [
|
|
189
|
+
["key_postcode", false],
|
|
190
|
+
["key_locality", true],
|
|
191
|
+
]) {
|
|
192
|
+
let group = [];
|
|
193
|
+
let read = 0;
|
|
194
|
+
for (const row of lookup
|
|
195
|
+
.prepare(`SELECT scope, street, number, address_id, source_id FROM ${table}`)
|
|
196
|
+
.iterate()) {
|
|
197
|
+
if (++read > rowsPerRegion * stride || filled(fromLocality))
|
|
198
|
+
break;
|
|
199
|
+
const last = group[0];
|
|
200
|
+
if (last && (last.scope !== row.scope || last.street !== row.street || last.number !== row.number)) {
|
|
201
|
+
if (new Set(group.map((member) => member.source_id)).size > 1) {
|
|
202
|
+
consider(group, fromLocality);
|
|
203
|
+
}
|
|
204
|
+
group = [];
|
|
205
|
+
}
|
|
206
|
+
if (group.length || hashFNV1a(`${row.scope}|${row.street}|${row.number}`, seed) % stride === 0) {
|
|
207
|
+
group.push(row);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (new Set(group.map((member) => member.source_id)).size > 1) {
|
|
211
|
+
consider(group, fromLocality);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
byRegion.push(kept);
|
|
215
|
+
log(`${region}: ${Object.entries(kept)
|
|
216
|
+
.map(([stratum, pairs]) => `${stratum} ${pairs.length}`)
|
|
217
|
+
.join(", ")}`);
|
|
218
|
+
}
|
|
219
|
+
const pairs = [];
|
|
220
|
+
const strata = strataRecord(() => 0);
|
|
221
|
+
for (const stratum of population ? [] : Object.values(AddressPairStratum)) {
|
|
222
|
+
for (let index = 0; strata[stratum] < perStratum; index++) {
|
|
223
|
+
let added = false;
|
|
224
|
+
for (const kept of byRegion) {
|
|
225
|
+
const pair = kept[stratum][index];
|
|
226
|
+
if (pair && strata[stratum] < perStratum) {
|
|
227
|
+
pairs.push(pair);
|
|
228
|
+
strata[stratum]++;
|
|
229
|
+
added = true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (!added)
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (population) {
|
|
237
|
+
for (const kept of byRegion) {
|
|
238
|
+
for (const [stratum, list] of Object.entries(kept)) {
|
|
239
|
+
pairs.push(...list);
|
|
240
|
+
strata[stratum] += list.length;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (options.outJSONL) {
|
|
245
|
+
await writeLocalJSONLFile(pairs, options.outJSONL);
|
|
246
|
+
}
|
|
247
|
+
return { pairs, strata, candidates };
|
|
248
|
+
}
|
|
249
|
+
function addressPairStratum(higher, lower, degrees, fromLocality) {
|
|
250
|
+
if (higher.stack >= STACK_MIN_ADDRESSES || lower.stack >= STACK_MIN_ADDRESSES)
|
|
251
|
+
return AddressPairStratum.StackedPoint;
|
|
252
|
+
if (fromLocality)
|
|
253
|
+
return AddressPairStratum.PostcodeDiffers;
|
|
254
|
+
if ((higher.unitIdentifier == null) !== (lower.unitIdentifier == null))
|
|
255
|
+
return AddressPairStratum.UnitAgainstNone;
|
|
256
|
+
if (higher.unitIdentifier !== lower.unitIdentifier)
|
|
257
|
+
return AddressPairStratum.UnitDiffers;
|
|
258
|
+
if (higher.unit !== lower.unit)
|
|
259
|
+
return AddressPairStratum.UnitSpelling;
|
|
260
|
+
return degrees > RULE_DEGREES ? AddressPairStratum.Distant : AddressPairStratum.Coincident;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=sample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample.js","sourceRoot":"","sources":["../../../tools/address-pairs/sample.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;A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,CAAC,CAAA;gBACnB,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,CAAA;YAC/B,CAAC;QACF,CAAC;IACF,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACtB,MAAM,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA;AACrC,CAAC;AAED,SAAS,kBAAkB,CAC1B,MAAyB,EACzB,KAAwB,EACxB,OAAe,EACf,YAAqB;IAErB,IAAI,MAAM,CAAC,KAAK,IAAI,mBAAmB,IAAI,KAAK,CAAC,KAAK,IAAI,mBAAmB;QAAE,OAAO,kBAAkB,CAAC,YAAY,CAAA;IAErH,IAAI,YAAY;QAAE,OAAO,kBAAkB,CAAC,eAAe,CAAA;IAE3D,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC;QAAE,OAAO,kBAAkB,CAAC,eAAe,CAAA;IAEjH,IAAI,MAAM,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;QAAE,OAAO,kBAAkB,CAAC,WAAW,CAAA;IAEzF,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI;QAAE,OAAO,kBAAkB,CAAC,YAAY,CAAA;IAEtE,OAAO,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAA;AAC3F,CAAC"}
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Coverage reconciliation, the product output that replaces inspecting the map by eye.
|
|
7
|
-
*
|
|
8
|
-
* Each resolved entity is classified by the kind of source its records come from. An eligibility
|
|
9
|
-
* source holds providers and facilities, such as NPPES org NPIs or TX HHSC nursing facilities. A
|
|
10
|
-
* funding source holds entities enrolled in a funding program, such as FCC Rural Health Care
|
|
11
|
-
* filings.
|
|
12
|
-
*
|
|
13
|
-
* The buckets are enrolled (both an eligibility and a funding record), eligible rather than
|
|
14
|
-
* enrolled (an eligibility record with no funding record resolving to it), and funded rather than
|
|
15
|
-
* in the eligibility set (a funding record with no eligibility record resolving to it).
|
|
16
|
-
*
|
|
17
|
-
* This is strictly a set-membership reconciliation, never an allegation.
|
|
18
|
-
*
|
|
19
|
-
* Run: `mailwoman registry scorer-eval coverage-reconciliation [--cap 2000] [--wof <admin.db>]
|
|
20
|
-
* [--data-root <dir>] [--out-md <md>] [--out-geojson <geojson>]`
|
|
21
|
-
*/
|
|
22
1
|
import type { EvalGeocoderFactory } from "#tools/eval-geocoder";
|
|
23
2
|
/**
|
|
24
3
|
* Options for {@linkcode coverageReconciliation}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage-reconciliation.d.ts","sourceRoot":"","sources":["../../tools/coverage-reconciliation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coverage-reconciliation.d.ts","sourceRoot":"","sources":["../../tools/coverage-reconciliation.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAG/D;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;;;OAIG;IACH,cAAc,EAAE,mBAAmB,CAAA;IACnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAQD;;;GAGG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,6BAA6B,EACtC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAqG/B"}
|