@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.
Files changed (263) hide show
  1. package/README.md +10 -10
  2. package/lib/address-key.ts +14 -10
  3. package/lib/geocode-handler.ts +6 -4
  4. package/lib/geojson.ts +13 -17
  5. package/lib/ingest.ts +57 -83
  6. package/lib/learned-scorer.ts +38 -44
  7. package/lib/map-html.ts +24 -70
  8. package/lib/models/crosssource-gbt-en-us.ts +9 -7
  9. package/lib/models/dedup-gbt-en-us.ts +9 -8
  10. package/lib/models/org-crosssource-gbt-en-us.ts +10 -8
  11. package/lib/reconcile.ts +45 -55
  12. package/lib/resolve.ts +180 -124
  13. package/lib/types.ts +18 -12
  14. package/out/address-key.d.ts +14 -10
  15. package/out/address-key.d.ts.map +1 -1
  16. package/out/address-key.js +14 -10
  17. package/out/address-key.js.map +1 -1
  18. package/out/geocode-handler.d.ts +6 -4
  19. package/out/geocode-handler.d.ts.map +1 -1
  20. package/out/geocode-handler.js +6 -4
  21. package/out/geocode-handler.js.map +1 -1
  22. package/out/geojson.d.ts +9 -5
  23. package/out/geojson.d.ts.map +1 -1
  24. package/out/geojson.js +13 -15
  25. package/out/geojson.js.map +1 -1
  26. package/out/ingest.d.ts +46 -75
  27. package/out/ingest.d.ts.map +1 -1
  28. package/out/ingest.js +27 -54
  29. package/out/ingest.js.map +1 -1
  30. package/out/learned-scorer.d.ts +29 -26
  31. package/out/learned-scorer.d.ts.map +1 -1
  32. package/out/learned-scorer.js +31 -39
  33. package/out/learned-scorer.js.map +1 -1
  34. package/out/map-html.d.ts +13 -32
  35. package/out/map-html.d.ts.map +1 -1
  36. package/out/map-html.js +9 -62
  37. package/out/map-html.js.map +1 -1
  38. package/out/models/crosssource-gbt-en-us.d.ts +9 -7
  39. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
  40. package/out/models/crosssource-gbt-en-us.js +9 -7
  41. package/out/models/crosssource-gbt-en-us.js.map +1 -1
  42. package/out/models/dedup-gbt-en-us.d.ts +9 -8
  43. package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
  44. package/out/models/dedup-gbt-en-us.js +9 -8
  45. package/out/models/dedup-gbt-en-us.js.map +1 -1
  46. package/out/models/org-crosssource-gbt-en-us.d.ts +10 -8
  47. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
  48. package/out/models/org-crosssource-gbt-en-us.js +10 -8
  49. package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
  50. package/out/reconcile.d.ts +35 -50
  51. package/out/reconcile.d.ts.map +1 -1
  52. package/out/reconcile.js +19 -43
  53. package/out/reconcile.js.map +1 -1
  54. package/out/resolve.d.ts +150 -90
  55. package/out/resolve.d.ts.map +1 -1
  56. package/out/resolve.js +62 -63
  57. package/out/resolve.js.map +1 -1
  58. package/out/tools/coverage-reconciliation.d.ts +23 -23
  59. package/out/tools/coverage-reconciliation.d.ts.map +1 -1
  60. package/out/tools/coverage-reconciliation.js +15 -26
  61. package/out/tools/coverage-reconciliation.js.map +1 -1
  62. package/out/tools/cross/dataset-correlation.d.ts +58 -0
  63. package/out/tools/cross/dataset-correlation.d.ts.map +1 -0
  64. package/out/tools/{cross-dataset-correlation.js → cross/dataset-correlation.js} +10 -62
  65. package/out/tools/cross/dataset-correlation.js.map +1 -0
  66. package/out/tools/cross/source-threshold-sweep.d.ts +60 -0
  67. package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -0
  68. package/out/tools/{cross-source-threshold-sweep.js → cross/source-threshold-sweep.js} +15 -41
  69. package/out/tools/cross/source-threshold-sweep.js.map +1 -0
  70. package/out/tools/dedup-ceiling.d.ts +23 -26
  71. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  72. package/out/tools/dedup-ceiling.js +22 -41
  73. package/out/tools/dedup-ceiling.js.map +1 -1
  74. package/out/tools/eval-geocoder.d.ts +22 -15
  75. package/out/tools/eval-geocoder.d.ts.map +1 -1
  76. package/out/tools/eval-geocoder.js +5 -6
  77. package/out/tools/eval-geocoder.js.map +1 -1
  78. package/out/tools/geocoder/namesake-probe.d.ts +33 -0
  79. package/out/tools/geocoder/namesake-probe.d.ts.map +1 -0
  80. package/out/tools/{geocoder-namesake-probe.js → geocoder/namesake-probe.js} +7 -8
  81. package/out/tools/geocoder/namesake-probe.js.map +1 -0
  82. package/out/tools/geocoder/vs-provided-coords.d.ts +53 -0
  83. package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -0
  84. package/out/tools/{geocoder-vs-provided-coords.js → geocoder/vs-provided-coords.js} +31 -28
  85. package/out/tools/geocoder/vs-provided-coords.js.map +1 -0
  86. package/out/tools/gold-set-sample.d.ts +27 -18
  87. package/out/tools/gold-set-sample.d.ts.map +1 -1
  88. package/out/tools/gold-set-sample.js +18 -22
  89. package/out/tools/gold-set-sample.js.map +1 -1
  90. package/out/tools/learned/scorer/clustering-eval.d.ts +77 -0
  91. package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -0
  92. package/out/tools/{learned-scorer-clustering-eval.js → learned/scorer/clustering-eval.js} +29 -39
  93. package/out/tools/learned/scorer/clustering-eval.js.map +1 -0
  94. package/out/tools/learned/scorer/crossstate-eval.d.ts +65 -0
  95. package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -0
  96. package/out/tools/{learned-scorer-crossstate-eval.js → learned/scorer/crossstate-eval.js} +20 -26
  97. package/out/tools/learned/scorer/crossstate-eval.js.map +1 -0
  98. package/out/tools/learned/scorer/eval.d.ts +60 -0
  99. package/out/tools/learned/scorer/eval.d.ts.map +1 -0
  100. package/out/tools/{learned-scorer-eval.js → learned/scorer/eval.js} +12 -72
  101. package/out/tools/learned/scorer/eval.js.map +1 -0
  102. package/out/tools/matcher-scale.d.ts +12 -17
  103. package/out/tools/matcher-scale.d.ts.map +1 -1
  104. package/out/tools/matcher-scale.js +11 -29
  105. package/out/tools/matcher-scale.js.map +1 -1
  106. package/out/tools/nppes/dedup-benchmark.d.ts +81 -0
  107. package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -0
  108. package/out/tools/{nppes-dedup-benchmark.js → nppes/dedup-benchmark.js} +21 -67
  109. package/out/tools/nppes/dedup-benchmark.js.map +1 -0
  110. package/out/tools/nppes/org-name.d.ts +5 -4
  111. package/out/tools/nppes/org-name.d.ts.map +1 -1
  112. package/out/tools/nppes/org-name.js +2 -2
  113. package/out/tools/nppes/org-name.js.map +1 -1
  114. package/out/tools/nppes/overmerge-packet.d.ts +15 -11
  115. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
  116. package/out/tools/nppes/overmerge-packet.js +7 -8
  117. package/out/tools/nppes/overmerge-packet.js.map +1 -1
  118. package/out/tools/nppes/report.d.ts +17 -13
  119. package/out/tools/nppes/report.d.ts.map +1 -1
  120. package/out/tools/nppes/report.js +6 -14
  121. package/out/tools/nppes/report.js.map +1 -1
  122. package/out/tools/nppes/sample.d.ts +28 -17
  123. package/out/tools/nppes/sample.d.ts.map +1 -1
  124. package/out/tools/nppes/sample.js +23 -26
  125. package/out/tools/nppes/sample.js.map +1 -1
  126. package/out/tools/nppes/scoring.d.ts +7 -6
  127. package/out/tools/nppes/scoring.d.ts.map +1 -1
  128. package/out/tools/nppes/scoring.js +6 -5
  129. package/out/tools/nppes/scoring.js.map +1 -1
  130. package/out/tools/nppes/settings.d.ts +10 -7
  131. package/out/tools/nppes/settings.d.ts.map +1 -1
  132. package/out/tools/nppes/settings.js +16 -16
  133. package/out/tools/nppes/settings.js.map +1 -1
  134. package/out/tools/nppes/truth-grains.d.ts +36 -23
  135. package/out/tools/nppes/truth-grains.d.ts.map +1 -1
  136. package/out/tools/nppes/truth-grains.js +36 -20
  137. package/out/tools/nppes/truth-grains.js.map +1 -1
  138. package/out/tools/shared.d.ts +63 -59
  139. package/out/tools/shared.d.ts.map +1 -1
  140. package/out/tools/shared.js +49 -66
  141. package/out/tools/shared.js.map +1 -1
  142. package/out/tools/train/cross-gbt.d.ts +88 -0
  143. package/out/tools/train/cross-gbt.d.ts.map +1 -0
  144. package/out/tools/{train-cross-gbt.js → train/cross-gbt.js} +15 -26
  145. package/out/tools/train/cross-gbt.js.map +1 -0
  146. package/out/tools/train/gbt.d.ts +85 -0
  147. package/out/tools/train/gbt.d.ts.map +1 -0
  148. package/out/tools/{train-gbt.js → train/gbt.js} +28 -32
  149. package/out/tools/train/gbt.js.map +1 -0
  150. package/out/tools/train/org-cross-gbt.d.ts +84 -0
  151. package/out/tools/train/org-cross-gbt.d.ts.map +1 -0
  152. package/out/tools/{train-org-cross-gbt.js → train/org-cross-gbt.js} +19 -23
  153. package/out/tools/train/org-cross-gbt.js.map +1 -0
  154. package/out/tools/txhhsc-to-oarow.d.ts +14 -9
  155. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  156. package/out/tools/txhhsc-to-oarow.js +16 -15
  157. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  158. package/out/tools/viz/browser.d.ts +6 -5
  159. package/out/tools/viz/browser.d.ts.map +1 -1
  160. package/out/tools/viz/browser.js +6 -5
  161. package/out/tools/viz/browser.js.map +1 -1
  162. package/out/tools/viz/cross-dataset-map.d.ts +7 -4
  163. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  164. package/out/tools/viz/cross-dataset-map.js +9 -6
  165. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  166. package/out/tools/viz/geocode-first-surface.d.ts +10 -5
  167. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  168. package/out/tools/viz/geocode-first-surface.js +16 -11
  169. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  170. package/out/tools/viz/{render-map.d.ts → render/map.d.ts} +6 -6
  171. package/out/tools/viz/render/map.d.ts.map +1 -0
  172. package/out/tools/viz/{render-map.js → render/map.js} +7 -6
  173. package/out/tools/viz/render/map.js.map +1 -0
  174. package/out/tools/viz/render.d.ts +12 -8
  175. package/out/tools/viz/render.d.ts.map +1 -1
  176. package/out/tools/viz/render.js +8 -7
  177. package/out/tools/viz/render.js.map +1 -1
  178. package/out/tools/viz/source-provenance-map.d.ts +19 -7
  179. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  180. package/out/tools/viz/source-provenance-map.js +11 -8
  181. package/out/tools/viz/source-provenance-map.js.map +1 -1
  182. package/out/tools/viz/yardstick-figure.d.ts +2 -21
  183. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  184. package/out/tools/viz/yardstick-figure.js +3 -39
  185. package/out/tools/viz/yardstick-figure.js.map +1 -1
  186. package/out/types.d.ts +17 -11
  187. package/out/types.d.ts.map +1 -1
  188. package/out/types.js +2 -2
  189. package/out/types.js.map +1 -1
  190. package/package.json +41 -184
  191. package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
  192. package/{lib/tools/cross-dataset-correlation.ts → tools/cross/dataset-correlation.ts} +31 -72
  193. package/{lib/tools/cross-source-threshold-sweep.ts → tools/cross/source-threshold-sweep.ts} +29 -46
  194. package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
  195. package/tools/eval-geocoder.ts +74 -0
  196. package/{lib/tools/geocoder-namesake-probe.ts → tools/geocoder/namesake-probe.ts} +9 -8
  197. package/{lib/tools/geocoder-vs-provided-coords.ts → tools/geocoder/vs-provided-coords.ts} +39 -30
  198. package/{lib/tools → tools}/gold-set-sample.ts +35 -29
  199. package/{lib/tools/learned-scorer-clustering-eval.ts → tools/learned/scorer/clustering-eval.ts} +49 -45
  200. package/{lib/tools/learned-scorer-crossstate-eval.ts → tools/learned/scorer/crossstate-eval.ts} +34 -30
  201. package/{lib/tools/learned-scorer-eval.ts → tools/learned/scorer/eval.ts} +35 -78
  202. package/{lib/tools → tools}/matcher-scale.ts +21 -33
  203. package/{lib/tools/nppes-dedup-benchmark.ts → tools/nppes/dedup-benchmark.ts} +37 -82
  204. package/{lib/tools → tools}/nppes/org-name.ts +5 -4
  205. package/{lib/tools → tools}/nppes/overmerge-packet.ts +17 -13
  206. package/{lib/tools → tools}/nppes/report.ts +32 -25
  207. package/{lib/tools → tools}/nppes/sample.ts +41 -36
  208. package/{lib/tools → tools}/nppes/scoring.ts +7 -6
  209. package/{lib/tools → tools}/nppes/settings.ts +16 -16
  210. package/{lib/tools → tools}/nppes/truth-grains.ts +46 -26
  211. package/{lib/tools → tools}/shared.ts +73 -83
  212. package/{lib/tools/train-cross-gbt.ts → tools/train/cross-gbt.ts} +38 -34
  213. package/{lib/tools/train-gbt.ts → tools/train/gbt.ts} +55 -41
  214. package/{lib/tools/train-org-cross-gbt.ts → tools/train/org-cross-gbt.ts} +39 -30
  215. package/{lib/tools → tools}/txhhsc-to-oarow.ts +24 -18
  216. package/{lib/tools → tools}/viz/browser.ts +6 -5
  217. package/{lib/tools → tools}/viz/cross-dataset-map.ts +15 -9
  218. package/{lib/tools → tools}/viz/geocode-first-surface.ts +28 -17
  219. package/{lib/tools/viz/render-map.ts → tools/viz/render/map.ts} +7 -6
  220. package/{lib/tools → tools}/viz/render.ts +16 -11
  221. package/{lib/tools → tools}/viz/source-provenance-map.ts +30 -15
  222. package/{lib/tools → tools}/viz/yardstick-figure.ts +6 -43
  223. package/lib/tools/eval-geocoder.ts +0 -67
  224. package/lib/tools/index.ts +0 -31
  225. package/out/tools/cross-dataset-correlation.d.ts +0 -65
  226. package/out/tools/cross-dataset-correlation.d.ts.map +0 -1
  227. package/out/tools/cross-dataset-correlation.js.map +0 -1
  228. package/out/tools/cross-source-threshold-sweep.d.ts +0 -66
  229. package/out/tools/cross-source-threshold-sweep.d.ts.map +0 -1
  230. package/out/tools/cross-source-threshold-sweep.js.map +0 -1
  231. package/out/tools/geocoder-namesake-probe.d.ts +0 -32
  232. package/out/tools/geocoder-namesake-probe.d.ts.map +0 -1
  233. package/out/tools/geocoder-namesake-probe.js.map +0 -1
  234. package/out/tools/geocoder-vs-provided-coords.d.ts +0 -50
  235. package/out/tools/geocoder-vs-provided-coords.d.ts.map +0 -1
  236. package/out/tools/geocoder-vs-provided-coords.js.map +0 -1
  237. package/out/tools/index.d.ts +0 -31
  238. package/out/tools/index.d.ts.map +0 -1
  239. package/out/tools/index.js +0 -31
  240. package/out/tools/index.js.map +0 -1
  241. package/out/tools/learned-scorer-clustering-eval.d.ts +0 -74
  242. package/out/tools/learned-scorer-clustering-eval.d.ts.map +0 -1
  243. package/out/tools/learned-scorer-clustering-eval.js.map +0 -1
  244. package/out/tools/learned-scorer-crossstate-eval.d.ts +0 -59
  245. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +0 -1
  246. package/out/tools/learned-scorer-crossstate-eval.js.map +0 -1
  247. package/out/tools/learned-scorer-eval.d.ts +0 -77
  248. package/out/tools/learned-scorer-eval.d.ts.map +0 -1
  249. package/out/tools/learned-scorer-eval.js.map +0 -1
  250. package/out/tools/nppes-dedup-benchmark.d.ts +0 -101
  251. package/out/tools/nppes-dedup-benchmark.d.ts.map +0 -1
  252. package/out/tools/nppes-dedup-benchmark.js.map +0 -1
  253. package/out/tools/train-cross-gbt.d.ts +0 -78
  254. package/out/tools/train-cross-gbt.d.ts.map +0 -1
  255. package/out/tools/train-cross-gbt.js.map +0 -1
  256. package/out/tools/train-gbt.d.ts +0 -69
  257. package/out/tools/train-gbt.d.ts.map +0 -1
  258. package/out/tools/train-gbt.js.map +0 -1
  259. package/out/tools/train-org-cross-gbt.d.ts +0 -71
  260. package/out/tools/train-org-cross-gbt.d.ts.map +0 -1
  261. package/out/tools/train-org-cross-gbt.js.map +0 -1
  262. package/out/tools/viz/render-map.d.ts.map +0 -1
  263. 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 — the whole matcher, wired over concrete contact/organization records: block
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
- * `resolveEntities` ships sensible geocode-first defaults — block on location / canonical key /
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 — uppercase, collapse whitespace, drop punctuation.
50
- * Used to count how many distinct entities share an address across the WHOLE corpus (computable over millions of rows
51
- * without geocoding) and to look that frequency up at match time. It's the inverse-frequency signal: a crowded
52
- * clinic/billing address is weak evidence of identity; a lonely address is strong. (See
53
- * docs/articles/evals/matcher-dedup/2026-06-15-nppes-dedup-benchmark.md.)
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. `m`/`u` are EM-estimable seeds.
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. A shared line is strong, rarely-coincidental evidence.
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 SET ({@link DefaultModelOptions.exactDiscriminators} — NPPES
82
- * taxonomy codes, license numbers). Seeds only — EM refits. `u` starts well above phone's 0.002: two RANDOM providers
83
- * share a specialty far more often than a phone line (dermatologists cluster in dermatology buildings).
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 > 0)
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-digits normalization for phone agreement (drops country code, punctuation, extensions). A shorter digit
108
- * string is kept as-is — partial agreement still carries weight in the comparison model; `null` means no digits at
109
- * all.
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 contract: only a FULL line counts — the last 10 digits when the
120
- * input carries at least 10, `""` otherwise (never a partial digit string). Callers guard on truthiness, so `""` reads
121
- * as "no comparable phone" rather than a weaker key.
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 (person name, organization, phone). A2 (#625,
131
- * {@link ResolveConfig.requireCorroboration}) requires at least one of these to _positively_ agree before a pair may
132
- * link — a shared address alone is not identity. Phone (A3) is the secondary identifier that rescues a true same-entity
133
- * link across name drift.
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}. Each change is default-off, so the base model is byte-stable.
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 (over {@link addressFrequencyKey}) — makes the address- agreement weight
143
- * **inverse to how shared the address is** (a building with 50 providers makes "same address" near-worthless
144
- * evidence). The table's `value` is the record's raw address string.
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
- * **A1 (#625):** collapse the redundant address-key + great-circle-distance comparisons into ONE
149
- * {@link spatialComparison spatial-agreement} signal — an exact-key tier (where `addressFrequency`, if set, rides)
150
- * over distance buckets. Removes the double-count that over-merges co-located providers (an exact key match already
151
- * implies distance ≈ 0).
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
- * **A3 (#625):** add a normalized-phone exact-match comparison — a shared line is strong evidence and the secondary
156
- * corroborator that lets a true same-entity link survive name drift under A2.
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} (e.g. `["authorizedOfficial"]`).
161
- * Each becomes an `attr:<key>` comparison AND counts toward A2 corroboration — a more reliable discriminator than
162
- * phone where the data has one (#625).
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 CODE-SET discriminators drawn from {@link SourceRecord.attributes} (#625 taxonomy change). The
167
- * attribute value is a whitespace-joined set of codes (NPPES taxonomy codes, license numbers, …); agreement = ANY
168
- * shared code (set overlap, not string similarity — `207R00000X` vs `207Q00000X` are DIFFERENT specialties despite
169
- * near-identical text, exactly the case string similarity mis-scores). The over-merge separator: two co-located
170
- * records of ONE entity nearly always share a code, two distinct co-located providers usually don't.
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 + organization + a spatial signal. The spatial signal is either two
177
- * comparisons (address-key similarity + great-circle distance — the legacy default, which double-counts) or, with
178
- * {@link DefaultModelOptions.collapseSpatial}, one collapsed {@link spatialComparison}. `addressFrequency` down-weights
179
- * agreement on a crowded address either way.
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), // exact normalized-digit match only
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, // ANY shared code = 1, else 0 — never string similarity (see the config doc)
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], // the exact same-key tier
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: a union of location, canonical address, phone, and email.
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
- * Scoring model. Default {@link buildDefaultModel}.
307
+ * The model used to score candidate pairs.
308
+ *
309
+ * Default {@link buildDefaultModel}.
286
310
  */
287
311
  model?: FellegiSunterModel<SourceRecord>
288
312
  /**
289
- * Blocking keys (their union). Default {@link defaultBlockingKeys}.
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). Default 0.
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). Default false.
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 (over {@link addressFrequencyKey}) — down-weights address agreement by how shared the
306
- * address is (a crowded clinic/billing address is weak identity evidence). **Default-on (#625):** when omitted,
307
- * `resolveEntities` AUTO-COMPUTES the table over the INPUT records' addresses (the right scope for a single dataset —
308
- * a crowded address within the data is down-weighted). Pass your own {@link TermFrequencyTable} (e.g. a corpus-wide
309
- * one) to override, or `false` to disable (the legacy bare baseline). Ignored if `model` is supplied.
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
- * A1 (#625): collapse the redundant address-key + distance pair into one {@link spatialComparison}. **Default-on
314
- * (true)** — the cleaner, less-over-merging spatial model. Set `false` for the legacy two-signal baseline. Ignored if
315
- * `model` is supplied.
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
- * A2 (#625): require positive name OR org corroboration ({@link CORROBORATING_FIELDS}) for a link — a shared address
320
- * alone cannot merge two records. Suppresses the spatial-only links that fuse distinct co-located providers. Default
321
- * false.
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
- * A3 (#625): add a normalized-phone comparison to the default model — strong evidence and the secondary corroborator
326
- * that keeps A2 from killing name-drift recall. Ignored if `model` is supplied.
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
- * A4 (#625): clustering linkage. `"single"` (default) = connected components; `"average"` = average-linkage
331
- * refinement that splits a component whose sub-clusters are joined only by a weak bridge — the principled over-merge
332
- * fix.
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 (from {@link SourceRecord.attributes}) to add as comparisons + corroborators — e.g.
337
- * `["authorizedOfficial"]`. Ignored if `model` is supplied.
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-SET discriminator keys ({@link DefaultModelOptions.exactDiscriminators} — set-overlap
342
- * agreement, e.g. `["taxonomy"]`). Also corroborators. Ignored if `model` is supplied.
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 LEARNED score (#603). When set, a candidate pair's match weight is
347
- * this function's return value (same threshold-comparable units as the FS weight) instead of {@link scorePair}'s.
348
- * Default undefined (pure FS). The blocking + clustering are unchanged, so a trained scorer can be A/B'd against the
349
- * FS baseline on the identical pipeline. The function is responsible for its own feature computation (e.g. the
350
- * agreement pattern, which is EM-independent, plus any corpus statistics it captured).
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
- * INTERACTION with {@link requireCorroboration}: the two are independent and compose, but the corroboration check is
353
- * still evaluated on the Fellegi-Sunter `contributions` (NOT the learned score) — so a learned-high pair with no
354
- * positive FS name/org/phone agreement is still held out. A learned scorer is normally trained to subsume
355
- * corroboration, so use ONE or the other; combining them lets the FS check veto the learned score, which is rarely
356
- * what you want.
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
- * **#603: the LEARNED gradient-boosted-tree scorer — DEFAULT-ON.** Omitted or `true` uses the bundled
361
- * {@link DEDUP_GBT_MODEL} (trained on the NPPES NPI-truth set; beats the Fellegi-Sunter baseline ~+5pp dedup F1
362
- * held-out within a state and ~+22pp on states it never trained on, reducing the co-located over-merge). `false` opts
363
- * out to the pure FS baseline; pass your own {@link GBT} for a custom model. The scorer is built over the SAME
364
- * collapsed-spatial + address-frequency feature model as training (via the resolved {@link addressFrequency}),
365
- * independent of this call's comparison config. An explicit {@link scorer} takes precedence. When the bundled model
366
- * is active and you don't set {@link threshold}, its CALIBRATED link threshold
367
- * ({@link DEDUP_GBT_META}.recommendedThreshold) is used — the GBT logit isn't in FS-weight units, so 0 would
368
- * over-merge. The model is NPPES/US-trained; for a very different domain, A/B it or pass `false`.
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 → score → cluster. Every record lands in exactly one entity (a
390
- * record with no confident link is its own singleton entity).
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
- // Threshold: an explicit value wins; else the bundled model's CALIBRATED threshold when it's active
441
- // (its logit isn't in FS-weight units, so 0 would over-merge); else 0 (FS baseline or a custom model).
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
- // A2 (#625): a link must carry positive name OR org corroboration — a shared (even down-weighted)
460
- // address alone is not identity. Spatial-only pairs are suppressed below any threshold.
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 = the weakest within-cluster link weight (how tightly an entity holds together). Compute it
477
- // in ONE pass over links via a record→cluster index, not by filtering every link for every cluster —
478
- // the latter is O(clusters × links) and dominates the resolve at scale.
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, and the canonical entity that
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 { OrganizationName, PersonName, PostalAddress, ResolutionTier } from "@mailwoman/record"
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 — anything that helps tell two records apart or confirm they're
40
- * the same beyond name/org/address/phone (an authorized-official name, a provider taxonomy, a license number…). Used
41
- * as extra comparisons + corroborators when the model is built with matching `discriminators`. Keyed by a stable
42
- * field name the model references.
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 field optional, plus an unconstrained
97
- * `bucket`. The renderer assigns a color per DISTINCT bucket value in first-seen order and builds its legend from that
98
- * set, so a bucket is any categorical label, not only a {@link ReconciliationBucket}; and a collection assembled from
99
- * something other than resolved entities (raw address points, links read back from a file) carries no entity id or
100
- * display name.
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
- //#endregion
110
+ // #endregion
@@ -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 (#259). Derives a stable {@link PostalAddressID} from a
7
- * resolved {@link SourceRecord} and exposes it as a blocking key — the deterministic,
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:** `GROUP BY postalAddressID(record)` collapses records that resolve
11
- * to the same place AND share a canonical address with NO scoring at all — the cheap, certain
12
- * slice of dedup before the matcher does the fuzzy rest.
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 isn't geocoded (no coordinate → no locality cell) or
21
- * carries no raw address to hash. Uses the resolved coordinate + the raw address; the state prefix is plucked from the
22
- * address when present.
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} — records that resolve to the same place with the same canonical address
27
- * block together. Add it to {@link defaultBlockingKeys}'s union when an exact address join should never be missed.
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
@@ -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;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,GAAG,IAAI,CAO5E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAAC,YAAY,CAAC,CAEhE"}
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"}