@mailwoman/registry 9.4.0 → 10.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 +10 -10
- package/lib/address-key.ts +14 -10
- package/lib/geocode-handler.ts +6 -4
- package/lib/geojson.ts +13 -17
- package/lib/ingest.ts +57 -83
- package/lib/learned-scorer.ts +38 -44
- package/lib/map-html.ts +24 -70
- package/lib/models/crosssource-gbt-en-us.ts +9 -7
- package/lib/models/dedup-gbt-en-us.ts +9 -8
- package/lib/models/org-crosssource-gbt-en-us.ts +10 -8
- package/lib/reconcile.ts +45 -55
- package/lib/resolve.ts +180 -124
- package/lib/types.ts +18 -12
- package/out/address-key.d.ts +14 -10
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js +14 -10
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +6 -4
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +6 -4
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +9 -5
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +13 -15
- package/out/geojson.js.map +1 -1
- package/out/ingest.d.ts +46 -75
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +27 -54
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +29 -26
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js +31 -39
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +13 -32
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +9 -62
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts +9 -7
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js +9 -7
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts +9 -8
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js +9 -8
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts +10 -8
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js +10 -8
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts +35 -50
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +19 -43
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +150 -90
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +62 -63
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.d.ts +23 -23
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +15 -26
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross/dataset-correlation.d.ts +58 -0
- package/out/tools/cross/dataset-correlation.d.ts.map +1 -0
- package/out/tools/{cross-dataset-correlation.js → cross/dataset-correlation.js} +10 -62
- package/out/tools/cross/dataset-correlation.js.map +1 -0
- package/out/tools/cross/source-threshold-sweep.d.ts +60 -0
- package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -0
- package/out/tools/{cross-source-threshold-sweep.js → cross/source-threshold-sweep.js} +15 -41
- package/out/tools/cross/source-threshold-sweep.js.map +1 -0
- package/out/tools/dedup-ceiling.d.ts +23 -26
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +22 -41
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +22 -15
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +5 -6
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder/namesake-probe.d.ts +33 -0
- package/out/tools/geocoder/namesake-probe.d.ts.map +1 -0
- package/out/tools/{geocoder-namesake-probe.js → geocoder/namesake-probe.js} +7 -8
- package/out/tools/geocoder/namesake-probe.js.map +1 -0
- package/out/tools/geocoder/vs-provided-coords.d.ts +53 -0
- package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -0
- package/out/tools/{geocoder-vs-provided-coords.js → geocoder/vs-provided-coords.js} +31 -28
- package/out/tools/geocoder/vs-provided-coords.js.map +1 -0
- package/out/tools/gold-set-sample.d.ts +27 -18
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +18 -22
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.d.ts +77 -0
- package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -0
- package/out/tools/{learned-scorer-clustering-eval.js → learned/scorer/clustering-eval.js} +29 -39
- package/out/tools/learned/scorer/clustering-eval.js.map +1 -0
- package/out/tools/learned/scorer/crossstate-eval.d.ts +65 -0
- package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -0
- package/out/tools/{learned-scorer-crossstate-eval.js → learned/scorer/crossstate-eval.js} +20 -26
- package/out/tools/learned/scorer/crossstate-eval.js.map +1 -0
- package/out/tools/learned/scorer/eval.d.ts +60 -0
- package/out/tools/learned/scorer/eval.d.ts.map +1 -0
- package/out/tools/{learned-scorer-eval.js → learned/scorer/eval.js} +12 -72
- package/out/tools/learned/scorer/eval.js.map +1 -0
- package/out/tools/matcher-scale.d.ts +12 -17
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +11 -29
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/dedup-benchmark.d.ts +81 -0
- package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -0
- package/out/tools/{nppes-dedup-benchmark.js → nppes/dedup-benchmark.js} +21 -67
- package/out/tools/nppes/dedup-benchmark.js.map +1 -0
- package/out/tools/nppes/org-name.d.ts +5 -4
- package/out/tools/nppes/org-name.d.ts.map +1 -1
- package/out/tools/nppes/org-name.js +2 -2
- package/out/tools/nppes/org-name.js.map +1 -1
- package/out/tools/nppes/overmerge-packet.d.ts +15 -11
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
- package/out/tools/nppes/overmerge-packet.js +7 -8
- package/out/tools/nppes/overmerge-packet.js.map +1 -1
- package/out/tools/nppes/report.d.ts +17 -13
- package/out/tools/nppes/report.d.ts.map +1 -1
- package/out/tools/nppes/report.js +6 -14
- package/out/tools/nppes/report.js.map +1 -1
- package/out/tools/nppes/sample.d.ts +28 -17
- package/out/tools/nppes/sample.d.ts.map +1 -1
- package/out/tools/nppes/sample.js +23 -26
- package/out/tools/nppes/sample.js.map +1 -1
- package/out/tools/nppes/scoring.d.ts +7 -6
- package/out/tools/nppes/scoring.d.ts.map +1 -1
- package/out/tools/nppes/scoring.js +6 -5
- package/out/tools/nppes/scoring.js.map +1 -1
- package/out/tools/nppes/settings.d.ts +10 -7
- package/out/tools/nppes/settings.d.ts.map +1 -1
- package/out/tools/nppes/settings.js +16 -16
- package/out/tools/nppes/settings.js.map +1 -1
- package/out/tools/nppes/truth-grains.d.ts +36 -23
- package/out/tools/nppes/truth-grains.d.ts.map +1 -1
- package/out/tools/nppes/truth-grains.js +36 -20
- package/out/tools/nppes/truth-grains.js.map +1 -1
- package/out/tools/shared.d.ts +63 -59
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +49 -66
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train/cross-gbt.d.ts +88 -0
- package/out/tools/train/cross-gbt.d.ts.map +1 -0
- package/out/tools/{train-cross-gbt.js → train/cross-gbt.js} +15 -26
- package/out/tools/train/cross-gbt.js.map +1 -0
- package/out/tools/train/gbt.d.ts +85 -0
- package/out/tools/train/gbt.d.ts.map +1 -0
- package/out/tools/{train-gbt.js → train/gbt.js} +28 -32
- package/out/tools/train/gbt.js.map +1 -0
- package/out/tools/train/org-cross-gbt.d.ts +84 -0
- package/out/tools/train/org-cross-gbt.d.ts.map +1 -0
- package/out/tools/{train-org-cross-gbt.js → train/org-cross-gbt.js} +19 -23
- package/out/tools/train/org-cross-gbt.js.map +1 -0
- package/out/tools/txhhsc-to-oarow.d.ts +14 -9
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +16 -15
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +6 -5
- package/out/tools/viz/browser.d.ts.map +1 -1
- package/out/tools/viz/browser.js +6 -5
- package/out/tools/viz/browser.js.map +1 -1
- package/out/tools/viz/cross-dataset-map.d.ts +7 -4
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +9 -6
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +10 -5
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +16 -11
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/{render-map.d.ts → render/map.d.ts} +6 -6
- package/out/tools/viz/render/map.d.ts.map +1 -0
- package/out/tools/viz/{render-map.js → render/map.js} +7 -6
- package/out/tools/viz/render/map.js.map +1 -0
- package/out/tools/viz/render.d.ts +12 -8
- package/out/tools/viz/render.d.ts.map +1 -1
- package/out/tools/viz/render.js +8 -7
- package/out/tools/viz/render.js.map +1 -1
- package/out/tools/viz/source-provenance-map.d.ts +19 -7
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +11 -8
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +2 -21
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +3 -39
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts +17 -11
- package/out/types.d.ts.map +1 -1
- package/out/types.js +2 -2
- package/out/types.js.map +1 -1
- package/package.json +41 -184
- package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
- package/{lib/tools/cross-dataset-correlation.ts → tools/cross/dataset-correlation.ts} +31 -72
- package/{lib/tools/cross-source-threshold-sweep.ts → tools/cross/source-threshold-sweep.ts} +29 -46
- package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
- package/tools/eval-geocoder.ts +74 -0
- package/{lib/tools/geocoder-namesake-probe.ts → tools/geocoder/namesake-probe.ts} +9 -8
- package/{lib/tools/geocoder-vs-provided-coords.ts → tools/geocoder/vs-provided-coords.ts} +39 -30
- package/{lib/tools → tools}/gold-set-sample.ts +35 -29
- package/{lib/tools/learned-scorer-clustering-eval.ts → tools/learned/scorer/clustering-eval.ts} +49 -45
- package/{lib/tools/learned-scorer-crossstate-eval.ts → tools/learned/scorer/crossstate-eval.ts} +34 -30
- package/{lib/tools/learned-scorer-eval.ts → tools/learned/scorer/eval.ts} +35 -78
- package/{lib/tools → tools}/matcher-scale.ts +21 -33
- package/{lib/tools/nppes-dedup-benchmark.ts → tools/nppes/dedup-benchmark.ts} +37 -82
- package/{lib/tools → tools}/nppes/org-name.ts +5 -4
- package/{lib/tools → tools}/nppes/overmerge-packet.ts +17 -13
- package/{lib/tools → tools}/nppes/report.ts +32 -25
- package/{lib/tools → tools}/nppes/sample.ts +41 -36
- package/{lib/tools → tools}/nppes/scoring.ts +7 -6
- package/{lib/tools → tools}/nppes/settings.ts +16 -16
- package/{lib/tools → tools}/nppes/truth-grains.ts +46 -26
- package/{lib/tools → tools}/shared.ts +73 -83
- package/{lib/tools/train-cross-gbt.ts → tools/train/cross-gbt.ts} +38 -34
- package/{lib/tools/train-gbt.ts → tools/train/gbt.ts} +55 -41
- package/{lib/tools/train-org-cross-gbt.ts → tools/train/org-cross-gbt.ts} +39 -30
- package/{lib/tools → tools}/txhhsc-to-oarow.ts +24 -18
- package/{lib/tools → tools}/viz/browser.ts +6 -5
- package/{lib/tools → tools}/viz/cross-dataset-map.ts +15 -9
- package/{lib/tools → tools}/viz/geocode-first-surface.ts +28 -17
- package/{lib/tools/viz/render-map.ts → tools/viz/render/map.ts} +7 -6
- package/{lib/tools → tools}/viz/render.ts +16 -11
- package/{lib/tools → tools}/viz/source-provenance-map.ts +30 -15
- package/{lib/tools → tools}/viz/yardstick-figure.ts +6 -43
- package/lib/tools/eval-geocoder.ts +0 -67
- package/lib/tools/index.ts +0 -31
- package/out/tools/cross-dataset-correlation.d.ts +0 -65
- package/out/tools/cross-dataset-correlation.d.ts.map +0 -1
- package/out/tools/cross-dataset-correlation.js.map +0 -1
- package/out/tools/cross-source-threshold-sweep.d.ts +0 -66
- package/out/tools/cross-source-threshold-sweep.d.ts.map +0 -1
- package/out/tools/cross-source-threshold-sweep.js.map +0 -1
- package/out/tools/geocoder-namesake-probe.d.ts +0 -32
- package/out/tools/geocoder-namesake-probe.d.ts.map +0 -1
- package/out/tools/geocoder-namesake-probe.js.map +0 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts +0 -50
- package/out/tools/geocoder-vs-provided-coords.d.ts.map +0 -1
- package/out/tools/geocoder-vs-provided-coords.js.map +0 -1
- package/out/tools/index.d.ts +0 -31
- package/out/tools/index.d.ts.map +0 -1
- package/out/tools/index.js +0 -31
- package/out/tools/index.js.map +0 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts +0 -74
- package/out/tools/learned-scorer-clustering-eval.d.ts.map +0 -1
- package/out/tools/learned-scorer-clustering-eval.js.map +0 -1
- package/out/tools/learned-scorer-crossstate-eval.d.ts +0 -59
- package/out/tools/learned-scorer-crossstate-eval.d.ts.map +0 -1
- package/out/tools/learned-scorer-crossstate-eval.js.map +0 -1
- package/out/tools/learned-scorer-eval.d.ts +0 -77
- package/out/tools/learned-scorer-eval.d.ts.map +0 -1
- package/out/tools/learned-scorer-eval.js.map +0 -1
- package/out/tools/nppes-dedup-benchmark.d.ts +0 -101
- package/out/tools/nppes-dedup-benchmark.d.ts.map +0 -1
- package/out/tools/nppes-dedup-benchmark.js.map +0 -1
- package/out/tools/train-cross-gbt.d.ts +0 -78
- package/out/tools/train-cross-gbt.d.ts.map +0 -1
- package/out/tools/train-cross-gbt.js.map +0 -1
- package/out/tools/train-gbt.d.ts +0 -69
- package/out/tools/train-gbt.d.ts.map +0 -1
- package/out/tools/train-gbt.js.map +0 -1
- package/out/tools/train-org-cross-gbt.d.ts +0 -71
- package/out/tools/train-org-cross-gbt.d.ts.map +0 -1
- package/out/tools/train-org-cross-gbt.js.map +0 -1
- package/out/tools/viz/render-map.d.ts.map +0 -1
- package/out/tools/viz/render-map.js.map +0 -1
package/lib/resolve.ts
CHANGED
|
@@ -3,18 +3,9 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* The resolve pipeline
|
|
7
|
-
* (geo-first) → score (Fellegi-Sunter) → cluster → canonical entities.
|
|
6
|
+
* The resolve pipeline wires the matching modules over concrete contact and organization records.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
* phone / email; score on name, organization, address key, and great-circle distance — and can
|
|
11
|
-
* fit the scorer's `m`/`u` to the data with EM (`trainEM`), so it runs with no labels and no
|
|
12
|
-
* per-dataset tuning. Everything is overridable: pass your own model, blocking keys, or
|
|
13
|
-
* threshold.
|
|
14
|
-
*
|
|
15
|
-
* Geocoding is assumed already done upstream (each `address` carries its coordinate + canonical
|
|
16
|
-
* key). Wiring mailwoman's parser + geocoder to turn raw rows into `SourceRecord`s is the ingest
|
|
17
|
-
* layer that sits in front of this.
|
|
8
|
+
* The upstream pipeline geocodes each `address` and supplies its coordinate and canonical key.
|
|
18
9
|
*/
|
|
19
10
|
|
|
20
11
|
import {
|
|
@@ -46,11 +37,14 @@ import { DEDUP_GBT_META, DEDUP_GBT_MODEL } from "#models/dedup-gbt-en-us"
|
|
|
46
37
|
import type { ResolvedEntity, SourceRecord } from "#types"
|
|
47
38
|
|
|
48
39
|
/**
|
|
49
|
-
* Cheap, parse-free normalization for the address-frequency key
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
40
|
+
* Cheap, parse-free normalization for the address-frequency key: uppercase,
|
|
41
|
+
* collapse whitespace, drop punctuation.
|
|
42
|
+
*
|
|
43
|
+
* The count covers distinct entities that share an address.
|
|
44
|
+
* It is computable over millions of rows without geocoding.
|
|
45
|
+
*
|
|
46
|
+
* A crowded clinic or billing address is weak identity evidence.
|
|
47
|
+
* A lonely address is strong.
|
|
54
48
|
*/
|
|
55
49
|
export function addressFrequencyKey(raw: string): string {
|
|
56
50
|
return raw
|
|
@@ -61,7 +55,9 @@ export function addressFrequencyKey(raw: string): string {
|
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
/**
|
|
64
|
-
* Default tiered levels for a name-like text field.
|
|
58
|
+
* Default tiered levels for a name-like text field.
|
|
59
|
+
*
|
|
60
|
+
* `m`/`u` are EM-estimable seeds.
|
|
65
61
|
*/
|
|
66
62
|
const NAME_LEVELS: ComparisonLevel[] = [
|
|
67
63
|
{ label: "exact", minSimilarity: 1, m: 0.8, u: 0.01 },
|
|
@@ -70,7 +66,9 @@ const NAME_LEVELS: ComparisonLevel[] = [
|
|
|
70
66
|
]
|
|
71
67
|
|
|
72
68
|
/**
|
|
73
|
-
* Exact-vs-different levels for a normalized phone.
|
|
69
|
+
* Exact-vs-different levels for a normalized phone.
|
|
70
|
+
*
|
|
71
|
+
* A shared line is strong, rarely-coincidental evidence.
|
|
74
72
|
*/
|
|
75
73
|
const PHONE_LEVELS: ComparisonLevel[] = [
|
|
76
74
|
{ label: "exact", minSimilarity: 1, m: 0.6, u: 0.002 },
|
|
@@ -78,24 +76,24 @@ const PHONE_LEVELS: ComparisonLevel[] = [
|
|
|
78
76
|
]
|
|
79
77
|
|
|
80
78
|
/**
|
|
81
|
-
* Exact-vs-different levels for a closed-vocabulary code
|
|
82
|
-
*
|
|
83
|
-
*
|
|
79
|
+
* Exact-vs-different levels for a closed-vocabulary code set
|
|
80
|
+
* ({@link DefaultModelOptions.exactDiscriminators}), such as NPPES taxonomy codes or license numbers.
|
|
81
|
+
*
|
|
82
|
+
* These are seeds only, since EM refits.
|
|
83
|
+
* `u` starts well above phone's 0.002, because two random providers share a
|
|
84
|
+
* specialty far more often than a phone line.
|
|
84
85
|
*/
|
|
85
86
|
const CODE_SET_LEVELS: ComparisonLevel[] = [
|
|
86
87
|
{ label: "exact", minSimilarity: 1, m: 0.75, u: 0.08 },
|
|
87
88
|
{ label: "different", minSimilarity: 0, m: 0.25, u: 0.92 },
|
|
88
89
|
]
|
|
89
90
|
|
|
90
|
-
/**
|
|
91
|
-
* 1 when the whitespace-joined code sets share ANY code, else 0 (order/count-insensitive, case-folded).
|
|
92
|
-
*/
|
|
93
91
|
function codeSetOverlap(a: string, b: string): number {
|
|
94
92
|
const sa = new Set(
|
|
95
93
|
a
|
|
96
94
|
.toUpperCase()
|
|
97
95
|
.split(/\s+/)
|
|
98
|
-
.filter((value) => value.length
|
|
96
|
+
.filter((value) => value.length)
|
|
99
97
|
)
|
|
100
98
|
|
|
101
99
|
for (const t of b.toUpperCase().split(/\s+/)) if (t && sa.has(t)) return 1
|
|
@@ -104,9 +102,11 @@ function codeSetOverlap(a: string, b: string): number {
|
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
/**
|
|
107
|
-
* Last-10-
|
|
108
|
-
*
|
|
109
|
-
*
|
|
105
|
+
* Last-10-digit normalization for phone agreement, dropping country code, punctuation and extensions.
|
|
106
|
+
*
|
|
107
|
+
* A shorter digit string is kept as-is, since partial agreement still contributes
|
|
108
|
+
* weight in the comparison model.
|
|
109
|
+
* `null` means no digits at all.
|
|
110
110
|
*/
|
|
111
111
|
export function normalizePhone(raw: string | null | undefined): string | null {
|
|
112
112
|
if (!raw) return null
|
|
@@ -116,9 +116,12 @@ export function normalizePhone(raw: string | null | undefined): string | null {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* {@link normalizePhone} under the probes' stricter
|
|
120
|
-
*
|
|
121
|
-
*
|
|
119
|
+
* {@link normalizePhone} under the probes' stricter interface, where only a full line counts.
|
|
120
|
+
*
|
|
121
|
+
* Returns the last 10 digits when the input contains at least 10.
|
|
122
|
+
* Returns `""` for shorter input, so callers never receive a partial digit string.
|
|
123
|
+
*
|
|
124
|
+
* Callers guard on truthiness, so `""` reads as no comparable phone rather than a weaker key.
|
|
122
125
|
*/
|
|
123
126
|
export function normalizePhoneStrict(raw: string | null | undefined): string {
|
|
124
127
|
const digits = normalizePhone(raw)
|
|
@@ -127,56 +130,75 @@ export function normalizePhoneStrict(raw: string | null | undefined): string {
|
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
/**
|
|
130
|
-
* The identity-corroborating comparisons
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
133
|
+
* The identity-corroborating comparisons: person name, organization and phone.
|
|
134
|
+
*
|
|
135
|
+
* At least one must positively agree before a pair may link, since a shared
|
|
136
|
+
* address provides no identity evidence by itself.
|
|
137
|
+
* Phone is the secondary identifier that rescues a true same-entity link across name drift.
|
|
134
138
|
*/
|
|
135
139
|
const CORROBORATING_FIELDS = new Set(["given", "family", "organization", "phone"])
|
|
136
140
|
|
|
137
141
|
/**
|
|
138
|
-
* Options for {@link buildDefaultModel}.
|
|
142
|
+
* Options for {@link buildDefaultModel}.
|
|
143
|
+
*
|
|
144
|
+
* Each change is default-off, so the base model is byte-stable.
|
|
139
145
|
*/
|
|
140
146
|
export interface DefaultModelOptions {
|
|
141
147
|
/**
|
|
142
|
-
* Corpus-wide address-frequency table
|
|
143
|
-
*
|
|
144
|
-
*
|
|
148
|
+
* Corpus-wide address-frequency table over {@link addressFrequencyKey}, which makes
|
|
149
|
+
* the address agreement weight inverse to how shared the address is.
|
|
150
|
+
*
|
|
151
|
+
* A building with 50 providers makes a same-address match near-worthless evidence.
|
|
152
|
+
*
|
|
153
|
+
* The table's `value` is the record's raw address string.
|
|
145
154
|
*/
|
|
146
155
|
addressFrequency?: TermFrequencyTable
|
|
147
156
|
/**
|
|
148
|
-
*
|
|
149
|
-
* {@link spatialComparison spatial-agreement} signal
|
|
150
|
-
*
|
|
151
|
-
*
|
|
157
|
+
* Collapse the redundant address-key and great-circle-distance comparisons into one
|
|
158
|
+
* {@link spatialComparison spatial-agreement} signal, an exact-key tier over distance buckets.
|
|
159
|
+
*
|
|
160
|
+
* Removes the double-count that over-merges co-located providers, since an
|
|
161
|
+
* exact key match already implies distance ≈ 0.
|
|
152
162
|
*/
|
|
153
163
|
collapseSpatial?: boolean
|
|
154
164
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
165
|
+
* Add a normalized-phone exact-match comparison.
|
|
166
|
+
*
|
|
167
|
+
* A shared line is strong evidence and the secondary corroborator that lets a
|
|
168
|
+
* true same-entity link survive name drift.
|
|
157
169
|
*/
|
|
158
170
|
usePhone?: boolean
|
|
159
171
|
/**
|
|
160
|
-
* Extra secondary-identifier comparisons drawn from {@link SourceRecord.attributes}
|
|
161
|
-
*
|
|
162
|
-
*
|
|
172
|
+
* Extra secondary-identifier comparisons drawn from {@link SourceRecord.attributes},
|
|
173
|
+
* such as `["authorizedOfficial"]`.
|
|
174
|
+
*
|
|
175
|
+
* Each becomes an `attr:<key>` comparison and counts toward corroboration.
|
|
176
|
+
* It is a more reliable discriminator than phone where the data has one.
|
|
163
177
|
*/
|
|
164
178
|
discriminators?: string[]
|
|
165
179
|
/**
|
|
166
|
-
* Closed-vocabulary
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
180
|
+
* Closed-vocabulary code-set discriminators drawn from {@link SourceRecord.attributes},
|
|
181
|
+
* such as NPPES taxonomy codes or license numbers.
|
|
182
|
+
*
|
|
183
|
+
* The attribute value is a whitespace-joined set of codes.
|
|
184
|
+
* Any shared code counts as agreement.
|
|
185
|
+
*
|
|
186
|
+
* This is set overlap rather than string similarity, since `207R00000X`
|
|
187
|
+
* and `207Q00000X` are different specialties despite near-identical text.
|
|
188
|
+
*
|
|
189
|
+
* Similarity scores mis-rank that case because the codes identify different specialties.
|
|
190
|
+
* The over-merge separator: two co-located records of one entity nearly always share
|
|
191
|
+
* a code, while two distinct co-located providers usually do not.
|
|
171
192
|
*/
|
|
172
193
|
exactDiscriminators?: string[]
|
|
173
194
|
}
|
|
174
195
|
|
|
175
196
|
/**
|
|
176
|
-
* The default geocode-first scoring model: name
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
197
|
+
* The default geocode-first scoring model: name, organization and a spatial signal.
|
|
198
|
+
*
|
|
199
|
+
* The spatial signal is either two comparisons (address-key similarity and great-circle distance)
|
|
200
|
+
* or, with {@link DefaultModelOptions.collapseSpatial}, one collapsed {@link spatialComparison}.
|
|
201
|
+
* `addressFrequency` down-weights agreement on a crowded address either way.
|
|
180
202
|
*/
|
|
181
203
|
export function buildDefaultModel(opts: DefaultModelOptions = {}): FellegiSunterModel<SourceRecord> {
|
|
182
204
|
const identity = [
|
|
@@ -194,7 +216,7 @@ export function buildDefaultModel(opts: DefaultModelOptions = {}): FellegiSunter
|
|
|
194
216
|
similarityComparison<SourceRecord>({
|
|
195
217
|
name: "phone",
|
|
196
218
|
extract: (r) => normalizePhone(r.phone),
|
|
197
|
-
similarity: (a, b) => (a === b ? 1 : 0),
|
|
219
|
+
similarity: (a, b) => (a === b ? 1 : 0),
|
|
198
220
|
levels: PHONE_LEVELS,
|
|
199
221
|
})
|
|
200
222
|
)
|
|
@@ -215,7 +237,7 @@ export function buildDefaultModel(opts: DefaultModelOptions = {}): FellegiSunter
|
|
|
215
237
|
similarityComparison<SourceRecord>({
|
|
216
238
|
name: `attr:${key}`,
|
|
217
239
|
extract: (r) => r.attributes?.[key],
|
|
218
|
-
similarity: codeSetOverlap,
|
|
240
|
+
similarity: codeSetOverlap,
|
|
219
241
|
levels: CODE_SET_LEVELS,
|
|
220
242
|
})
|
|
221
243
|
)
|
|
@@ -233,14 +255,13 @@ export function buildDefaultModel(opts: DefaultModelOptions = {}): FellegiSunter
|
|
|
233
255
|
spatial = withTermFrequency(spatial, {
|
|
234
256
|
table: opts.addressFrequency,
|
|
235
257
|
value: (a) => a.address?.raw ?? null,
|
|
236
|
-
levels: [0],
|
|
258
|
+
levels: [0],
|
|
237
259
|
})
|
|
238
260
|
}
|
|
239
261
|
|
|
240
262
|
return { lambda: 0.0001, comparisons: [...identity, spatial] }
|
|
241
263
|
}
|
|
242
264
|
|
|
243
|
-
// Legacy two-signal spatial: address-key similarity + great-circle distance (redundant; A1 collapses it).
|
|
244
265
|
let address = similarityComparison<SourceRecord>({
|
|
245
266
|
name: "address",
|
|
246
267
|
extract: (r) => r.address?.canonicalKey,
|
|
@@ -266,7 +287,8 @@ export function buildDefaultModel(opts: DefaultModelOptions = {}): FellegiSunter
|
|
|
266
287
|
}
|
|
267
288
|
|
|
268
289
|
/**
|
|
269
|
-
* The default blocking keys
|
|
290
|
+
* The default blocking keys include location and canonical address.
|
|
291
|
+
* They also include phone and email.
|
|
270
292
|
*/
|
|
271
293
|
export function defaultBlockingKeys(): BlockingKey<SourceRecord>[] {
|
|
272
294
|
return [
|
|
@@ -282,15 +304,21 @@ export function defaultBlockingKeys(): BlockingKey<SourceRecord>[] {
|
|
|
282
304
|
*/
|
|
283
305
|
export interface ResolveConfig {
|
|
284
306
|
/**
|
|
285
|
-
*
|
|
307
|
+
* The model used to score candidate pairs.
|
|
308
|
+
*
|
|
309
|
+
* Default {@link buildDefaultModel}.
|
|
286
310
|
*/
|
|
287
311
|
model?: FellegiSunterModel<SourceRecord>
|
|
288
312
|
/**
|
|
289
|
-
*
|
|
313
|
+
* The blocking keys whose union forms the candidate set.
|
|
314
|
+
*
|
|
315
|
+
* Default {@link defaultBlockingKeys}.
|
|
290
316
|
*/
|
|
291
317
|
blockingKeys?: BlockingKey<SourceRecord>[]
|
|
292
318
|
/**
|
|
293
|
-
* Link two records into the same entity at or above this match weight (bits).
|
|
319
|
+
* Link two records into the same entity at or above this match weight (bits).
|
|
320
|
+
*
|
|
321
|
+
* Default 0.
|
|
294
322
|
*/
|
|
295
323
|
threshold?: number
|
|
296
324
|
/**
|
|
@@ -298,74 +326,108 @@ export interface ResolveConfig {
|
|
|
298
326
|
*/
|
|
299
327
|
maxBlockSize?: number
|
|
300
328
|
/**
|
|
301
|
-
* Fit the model's `m`/`u` to the candidate pairs with EM before scoring (label-free).
|
|
329
|
+
* Fit the model's `m`/`u` to the candidate pairs with EM before scoring (label-free).
|
|
330
|
+
*
|
|
331
|
+
* Default false.
|
|
302
332
|
*/
|
|
303
333
|
trainEM?: boolean
|
|
304
334
|
/**
|
|
305
|
-
* Address-frequency table
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
335
|
+
* Address-frequency table over {@link addressFrequencyKey}, which down-weights address
|
|
336
|
+
* agreement by how shared the address is. **Default-on:** when omitted, `resolveEntities`
|
|
337
|
+
* computes the table over the input records' addresses, the right scope for a single dataset.
|
|
338
|
+
*
|
|
339
|
+
* Pass your own {@link TermFrequencyTable} (for example a corpus-wide one) to override,
|
|
340
|
+
* or `false` to disable (the legacy bare baseline).
|
|
341
|
+
* Ignored if `model` is supplied.
|
|
310
342
|
*/
|
|
311
343
|
addressFrequency?: TermFrequencyTable | false
|
|
312
344
|
/**
|
|
313
|
-
*
|
|
314
|
-
* (true)**
|
|
315
|
-
*
|
|
345
|
+
* Collapse the redundant address-key and distance pair into one {@link spatialComparison}.
|
|
346
|
+
* **Default-on (true)** is the cleaner, less-over-merging spatial model.
|
|
347
|
+
*
|
|
348
|
+
* Set `false` for the legacy two-signal baseline.
|
|
349
|
+
* Ignored if `model` is supplied.
|
|
316
350
|
*/
|
|
317
351
|
collapseSpatial?: boolean
|
|
318
352
|
/**
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
353
|
+
* Require positive name or organization corroboration ({@link CORROBORATING_FIELDS}) for
|
|
354
|
+
* a link, so a shared address cannot merge two records without that corroboration.
|
|
355
|
+
*
|
|
356
|
+
* Suppresses the spatial-only links that fuse distinct co-located providers.
|
|
357
|
+
* Default false.
|
|
322
358
|
*/
|
|
323
359
|
requireCorroboration?: boolean
|
|
324
360
|
/**
|
|
325
|
-
*
|
|
326
|
-
*
|
|
361
|
+
* Add a normalized-phone comparison to the default model.
|
|
362
|
+
*
|
|
363
|
+
* Phone agreement provides strong secondary evidence when entity names have drifted.
|
|
364
|
+
*
|
|
365
|
+
* Ignored if `model` is supplied.
|
|
327
366
|
*/
|
|
328
367
|
usePhone?: boolean
|
|
329
368
|
/**
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
369
|
+
* The linkage method used for clustering.
|
|
370
|
+
*
|
|
371
|
+
* `"single"` (default) is connected components, while `"average"` is an average-linkage
|
|
372
|
+
* refinement that splits a component whose sub-clusters are joined only by a weak bridge.
|
|
333
373
|
*/
|
|
334
374
|
linkage?: "single" | "average"
|
|
335
375
|
/**
|
|
336
|
-
* Extra secondary-identifier keys
|
|
337
|
-
* `["authorizedOfficial"]`.
|
|
376
|
+
* Extra secondary-identifier keys from {@link SourceRecord.attributes} to add as
|
|
377
|
+
* comparisons and corroborators, for example `["authorizedOfficial"]`.
|
|
378
|
+
*
|
|
379
|
+
* Ignored if `model` is supplied.
|
|
338
380
|
*/
|
|
339
381
|
discriminators?: string[]
|
|
340
382
|
/**
|
|
341
|
-
* Closed-vocabulary code-
|
|
342
|
-
*
|
|
383
|
+
* Closed-vocabulary code-set discriminator keys ({@link DefaultModelOptions.exactDiscriminators}),
|
|
384
|
+
* which use set-overlap agreement.
|
|
385
|
+
* An example is `["taxonomy"]`.
|
|
386
|
+
*
|
|
387
|
+
* Also corroborators.
|
|
388
|
+
* Ignored if `model` is supplied.
|
|
343
389
|
*/
|
|
344
390
|
exactDiscriminators?: string[]
|
|
345
391
|
/**
|
|
346
|
-
* Override the Fellegi-Sunter link weight with a
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
392
|
+
* Override the Fellegi-Sunter link weight with a learned score.
|
|
393
|
+
*
|
|
394
|
+
* When set, a candidate pair's match weight is this function's return value instead of
|
|
395
|
+
* {@link scorePair}'s, in the same threshold-comparable units as the FS weight.
|
|
396
|
+
* Default is undefined (pure FS).
|
|
397
|
+
*
|
|
398
|
+
* The blocking and clustering are unchanged, so a trained scorer can be A/B tested
|
|
399
|
+
* against the FS baseline on the identical pipeline.
|
|
400
|
+
* The function is responsible for its own feature computation, such as the
|
|
401
|
+
* agreement pattern plus any corpus statistics it captured.
|
|
351
402
|
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
403
|
+
* The corroboration check is independent of the learned score and is still evaluated on
|
|
404
|
+
* the Fellegi-Sunter `contributions`, so a learned-high pair with no positive FS name,
|
|
405
|
+
* organization or phone agreement is still held out.
|
|
406
|
+
*
|
|
407
|
+
* A learned scorer is normally trained to subsume corroboration, so use one or the other.
|
|
408
|
+
* The independent FS check can veto the learned score when both checks run.
|
|
357
409
|
*/
|
|
358
410
|
scorer?: (a: SourceRecord, b: SourceRecord) => number
|
|
359
411
|
/**
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
412
|
+
* The learned gradient-boosted-tree scorer, default-on.
|
|
413
|
+
*
|
|
414
|
+
* Omitted or `true` uses the bundled {@link DEDUP_GBT_MODEL}, which was trained on
|
|
415
|
+
* the NPPES NPI-truth set and beats the Fellegi-Sunter baseline by roughly +5pp dedup
|
|
416
|
+
* F1 held-out within a state and +22pp on states it never trained on.
|
|
417
|
+
*
|
|
418
|
+
* `false` opts out to the pure FS baseline.
|
|
419
|
+
* Pass your own {@link GBT} for a custom model.
|
|
420
|
+
*
|
|
421
|
+
* The scorer is built over the same collapsed-spatial and address-frequency feature
|
|
422
|
+
* model as training, independent of this call's comparison config.
|
|
423
|
+
* An explicit {@link scorer} takes precedence.
|
|
424
|
+
*
|
|
425
|
+
* When the bundled model is active and no {@link threshold} is set,
|
|
426
|
+
* its calibrated link threshold ({@link DEDUP_GBT_META}.recommendedThreshold) is used,
|
|
427
|
+
* because the GBT logit is not in FS-weight units and 0 would over-merge.
|
|
428
|
+
*
|
|
429
|
+
* The model is NPPES/US-trained.
|
|
430
|
+
* For a very different domain, A/B it or pass `false`.
|
|
369
431
|
*/
|
|
370
432
|
learnedScorer?: boolean | GBT
|
|
371
433
|
}
|
|
@@ -386,13 +448,12 @@ export interface ResolveResult {
|
|
|
386
448
|
}
|
|
387
449
|
|
|
388
450
|
/**
|
|
389
|
-
* Resolve source records into canonical entities: block
|
|
390
|
-
*
|
|
451
|
+
* Resolve source records into canonical entities: block, score, cluster.
|
|
452
|
+
*
|
|
453
|
+
* Every record belongs to exactly one entity.
|
|
454
|
+
* A record without a confident link forms a singleton entity.
|
|
391
455
|
*/
|
|
392
456
|
export function resolveEntities(records: readonly SourceRecord[], config: ResolveConfig = {}): ResolveResult {
|
|
393
|
-
// The proven changes are DEFAULT-ON (#625): the address-frequency down-weight (auto-computed over the
|
|
394
|
-
// input records when not supplied; `false` disables) + the collapsed spatial signal (A1). A new
|
|
395
|
-
// caller gets the strong config out of the box; pass explicit values to override.
|
|
396
457
|
const addressFrequency =
|
|
397
458
|
config.addressFrequency === false
|
|
398
459
|
? undefined
|
|
@@ -416,11 +477,6 @@ export function resolveEntities(records: readonly SourceRecord[], config: Resolv
|
|
|
416
477
|
|
|
417
478
|
const blockingKeys = config.blockingKeys ?? defaultBlockingKeys()
|
|
418
479
|
|
|
419
|
-
// #603: the learned scorer is DEFAULT-ON. An explicit `scorer` overrides everything; otherwise
|
|
420
|
-
// `learnedScorer === false` opts out to the FS baseline, a GBT supplies a custom model, and
|
|
421
|
-
// `true`/omitted uses the bundled DEDUP_GBT_MODEL. The scorer is built over the FIXED
|
|
422
|
-
// collapsed-spatial + address-frequency feature model (matching training, independent of this call's
|
|
423
|
-
// comparison config), using the resolved address-frequency table.
|
|
424
480
|
let scorer = config.scorer
|
|
425
481
|
let usingBundledModel = false
|
|
426
482
|
|
|
@@ -437,8 +493,10 @@ export function resolveEntities(records: readonly SourceRecord[], config: Resolv
|
|
|
437
493
|
})
|
|
438
494
|
}
|
|
439
495
|
|
|
440
|
-
//
|
|
441
|
-
//
|
|
496
|
+
// An explicit threshold wins.
|
|
497
|
+
// Otherwise the bundled model uses its calibrated threshold, because its logit
|
|
498
|
+
// is not in FS-weight units and 0 would over-merge.
|
|
499
|
+
// The FS baseline or a custom model uses 0.
|
|
442
500
|
const threshold = config.threshold ?? (usingBundledModel ? DEDUP_GBT_META.recommendedThreshold : 0)
|
|
443
501
|
|
|
444
502
|
const { pairs, droppedBlocks } = block(records, blockingKeys, { maxBlockSize: config.maxBlockSize })
|
|
@@ -452,12 +510,10 @@ export function resolveEntities(records: readonly SourceRecord[], config: Resolv
|
|
|
452
510
|
|
|
453
511
|
const links: ScoredLink<SourceRecord>[] = pairs.map(([a, b]) => {
|
|
454
512
|
const score = scorePair(scoringModel, a, b)
|
|
455
|
-
// #603: a learned scorer (explicit `scorer` or the opt-in `learnedScorer`) replaces the FS weight
|
|
456
|
-
// (same clustering + threshold semantics).
|
|
457
513
|
let weight = scorer ? scorer(a, b) : score.weight
|
|
458
514
|
|
|
459
|
-
//
|
|
460
|
-
// address
|
|
515
|
+
// A link requires positive name or organization corroboration, since a shared
|
|
516
|
+
// address provides no identity evidence by itself.
|
|
461
517
|
if (config.requireCorroboration) {
|
|
462
518
|
const corroborated = score.contributions.some(
|
|
463
519
|
(c) => (CORROBORATING_FIELDS.has(c.name) || c.name.startsWith("attr:")) && c.weight > 0
|
|
@@ -473,9 +529,9 @@ export function resolveEntities(records: readonly SourceRecord[], config: Resolv
|
|
|
473
529
|
|
|
474
530
|
const clusters = cluster(records, links, { threshold, linkage: config.linkage })
|
|
475
531
|
|
|
476
|
-
// Cohesion
|
|
477
|
-
// in
|
|
478
|
-
//
|
|
532
|
+
// Cohesion is the weakest within-cluster link weight.
|
|
533
|
+
// Compute it in one pass over links with a record-to-cluster index, because filtering
|
|
534
|
+
// every link for every cluster is O(clusters x links) and dominates the resolve at scale.
|
|
479
535
|
const clusterOf = new Map<SourceRecord, number>()
|
|
480
536
|
|
|
481
537
|
clusters.forEach((group, i) => {
|
package/lib/types.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* The application's data shapes — the messy record that goes in
|
|
6
|
+
* The application's data shapes — the messy record that goes in and the canonical entity that
|
|
7
7
|
* comes out. Plain interfaces over the `@mailwoman/record` types.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { ResolutionTier } from "@mailwoman/annotations/geo"
|
|
11
|
+
import type { OrganizationName, PersonName, PostalAddress } from "@mailwoman/record"
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* A single source record: one row of a messy contact/organization dataset, after normalization.
|
|
@@ -36,10 +37,13 @@ export interface SourceRecord {
|
|
|
36
37
|
phone?: string | null
|
|
37
38
|
email?: string | null
|
|
38
39
|
/**
|
|
39
|
-
* Additional secondary-identifier fields, normalized
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* Additional secondary-identifier fields, normalized.
|
|
41
|
+
*
|
|
42
|
+
* Anything that helps tell two records apart or confirm they're the same beyond
|
|
43
|
+
* name/org/address/phone (an authorized-official name, a provider taxonomy, a license number…).
|
|
44
|
+
*
|
|
45
|
+
* Used as extra comparisons + corroborators when the model is built with matching `discriminators`.
|
|
46
|
+
* Keyed by a stable field name the model references.
|
|
43
47
|
*/
|
|
44
48
|
attributes?: Record<string, string>
|
|
45
49
|
/**
|
|
@@ -93,12 +97,14 @@ export interface EntityGeoData {
|
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
/**
|
|
96
|
-
* Feature properties the map renderer consumes — {@link EntityGeoData} with every
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
100
|
+
* Feature properties the map renderer consumes — {@link EntityGeoData} with every
|
|
101
|
+
* field optional, plus an unconstrained `bucket`.
|
|
102
|
+
*
|
|
103
|
+
* The renderer assigns a color per distinct bucket value in first-seen order and builds
|
|
104
|
+
* its legend from that set, so a bucket is any categorical label rather than only a
|
|
105
|
+
* {@link ReconciliationBucket}; and a collection assembled from something other than resolved
|
|
106
|
+
* entities (raw address points, links read back from a file) have no entity id or display name.
|
|
101
107
|
*/
|
|
102
108
|
export type MapFeatureData = Partial<Omit<EntityGeoData, "bucket">> & { bucket?: string }
|
|
103
109
|
|
|
104
|
-
|
|
110
|
+
// #endregion
|
package/out/address-key.d.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* The address-id consumer for the matcher
|
|
7
|
-
* resolved {@link SourceRecord} and exposes it as a blocking key
|
|
6
|
+
* The address-id consumer for the matcher. Derives a stable {@link PostalAddressID} from a
|
|
7
|
+
* resolved {@link SourceRecord} and exposes it as a blocking key, the deterministic
|
|
8
8
|
* exact-canonical-address complement to the fuzzy Fellegi-Sunter / GBT scoring. Two uses:
|
|
9
9
|
*
|
|
10
|
-
* - **As a pre-dedup / join key:** `
|
|
11
|
-
* to the same place
|
|
12
|
-
*
|
|
10
|
+
* - **As a pre-dedup / join key:** `group BY postalAddressID(record)` collapses records that resolve
|
|
11
|
+
* to the same place and share a canonical address with no scoring at all. That is the cheap,
|
|
12
|
+
* certain part of dedup before the matcher does the fuzzy rest.
|
|
13
13
|
* - **As a blocking key:** {@link addressIDBlockingKey} adds the address-id to the blocking union, so
|
|
14
14
|
* records sharing one are guaranteed to be compared.
|
|
15
15
|
*/
|
|
@@ -17,14 +17,18 @@ import { type PostalAddressID } from "@mailwoman/address-id";
|
|
|
17
17
|
import { type BlockingKey } from "@mailwoman/match";
|
|
18
18
|
import type { SourceRecord } from "#types";
|
|
19
19
|
/**
|
|
20
|
-
* The stable address primary key for a record, or null when it
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* The stable address primary key for a record, or null when it is not geocoded
|
|
21
|
+
* (no coordinate means no locality cell) or includes no raw address to hash.
|
|
22
|
+
*
|
|
23
|
+
* The state prefix is plucked from the address when present.
|
|
23
24
|
*/
|
|
24
25
|
export declare function postalAddressID(record: SourceRecord): PostalAddressID | null;
|
|
25
26
|
/**
|
|
26
|
-
* A blocking key on the {@link postalAddressID}
|
|
27
|
-
*
|
|
27
|
+
* A blocking key on the {@link postalAddressID}.
|
|
28
|
+
*
|
|
29
|
+
* Records that resolve to the same place with the same canonical address block together.
|
|
30
|
+
*
|
|
31
|
+
* Add it to {@link defaultBlockingKeys}'s union when an exact address join should never be missed.
|
|
28
32
|
*/
|
|
29
33
|
export declare function addressIDBlockingKey(): BlockingKey<SourceRecord>;
|
|
30
34
|
//# sourceMappingURL=address-key.d.ts.map
|
package/out/address-key.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-key.d.ts","sourceRoot":"","sources":["../lib/address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,kBAAkB,CAAA;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C
|
|
1
|
+
{"version":3,"file":"address-key.d.ts","sourceRoot":"","sources":["../lib/address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,kBAAkB,CAAA;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,GAAG,IAAI,CAO5E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAAC,YAAY,CAAC,CAEhE"}
|