@mailwoman/registry 10.0.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +11 -14
  2. package/lib/address-key.ts +14 -10
  3. package/lib/geocode-handler.ts +7 -5
  4. package/lib/geojson.ts +13 -7
  5. package/lib/ingest.ts +70 -92
  6. package/lib/learned-scorer.ts +38 -44
  7. package/lib/map-html.ts +26 -72
  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 -54
  12. package/lib/resolve.ts +187 -130
  13. package/lib/types.ts +35 -29
  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 +7 -5
  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 -7
  25. package/out/geojson.js.map +1 -1
  26. package/out/ingest.d.ts +49 -76
  27. package/out/ingest.d.ts.map +1 -1
  28. package/out/ingest.js +37 -62
  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 +11 -64
  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 +36 -50
  51. package/out/reconcile.d.ts.map +1 -1
  52. package/out/reconcile.js +18 -42
  53. package/out/reconcile.js.map +1 -1
  54. package/out/resolve.d.ts +152 -91
  55. package/out/resolve.d.ts.map +1 -1
  56. package/out/resolve.js +67 -68
  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 +23 -27
  63. package/out/tools/cross/dataset-correlation.d.ts.map +1 -1
  64. package/out/tools/cross/dataset-correlation.js +9 -61
  65. package/out/tools/cross/dataset-correlation.js.map +1 -1
  66. package/out/tools/cross/source-threshold-sweep.d.ts +20 -26
  67. package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -1
  68. package/out/tools/cross/source-threshold-sweep.js +14 -40
  69. package/out/tools/cross/source-threshold-sweep.js.map +1 -1
  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 +25 -16
  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 +9 -8
  79. package/out/tools/geocoder/namesake-probe.d.ts.map +1 -1
  80. package/out/tools/geocoder/namesake-probe.js +6 -7
  81. package/out/tools/geocoder/namesake-probe.js.map +1 -1
  82. package/out/tools/geocoder/vs-provided-coords.d.ts +18 -15
  83. package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -1
  84. package/out/tools/geocoder/vs-provided-coords.js +30 -27
  85. package/out/tools/geocoder/vs-provided-coords.js.map +1 -1
  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 +30 -27
  91. package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -1
  92. package/out/tools/learned/scorer/clustering-eval.js +28 -38
  93. package/out/tools/learned/scorer/clustering-eval.js.map +1 -1
  94. package/out/tools/learned/scorer/crossstate-eval.d.ts +24 -18
  95. package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -1
  96. package/out/tools/learned/scorer/crossstate-eval.js +19 -25
  97. package/out/tools/learned/scorer/crossstate-eval.js.map +1 -1
  98. package/out/tools/learned/scorer/eval.d.ts +26 -39
  99. package/out/tools/learned/scorer/eval.d.ts.map +1 -1
  100. package/out/tools/learned/scorer/eval.js +11 -71
  101. package/out/tools/learned/scorer/eval.js.map +1 -1
  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 +22 -41
  107. package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -1
  108. package/out/tools/nppes/dedup-benchmark.js +21 -67
  109. package/out/tools/nppes/dedup-benchmark.js.map +1 -1
  110. package/out/tools/nppes/org-name.d.ts +5 -11
  111. package/out/tools/nppes/org-name.d.ts.map +1 -1
  112. package/out/tools/nppes/org-name.js +2 -9
  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 +6 -7
  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 +29 -18
  123. package/out/tools/nppes/sample.d.ts.map +1 -1
  124. package/out/tools/nppes/sample.js +24 -28
  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 +68 -72
  139. package/out/tools/shared.d.ts.map +1 -1
  140. package/out/tools/shared.js +50 -67
  141. package/out/tools/shared.js.map +1 -1
  142. package/out/tools/train/cross-gbt.d.ts +37 -26
  143. package/out/tools/train/cross-gbt.d.ts.map +1 -1
  144. package/out/tools/train/cross-gbt.js +14 -25
  145. package/out/tools/train/cross-gbt.js.map +1 -1
  146. package/out/tools/train/gbt.d.ts +36 -20
  147. package/out/tools/train/gbt.d.ts.map +1 -1
  148. package/out/tools/train/gbt.js +27 -31
  149. package/out/tools/train/gbt.js.map +1 -1
  150. package/out/tools/train/org-cross-gbt.d.ts +38 -24
  151. package/out/tools/train/org-cross-gbt.d.ts.map +1 -1
  152. package/out/tools/train/org-cross-gbt.js +18 -22
  153. package/out/tools/train/org-cross-gbt.js.map +1 -1
  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 +11 -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 +5 -5
  171. package/out/tools/viz/render/map.d.ts.map +1 -1
  172. package/out/tools/viz/render/map.js +6 -5
  173. package/out/tools/viz/render/map.js.map +1 -1
  174. package/out/tools/viz/{render/index.d.ts → render.d.ts} +13 -9
  175. package/out/tools/viz/render.d.ts.map +1 -0
  176. package/out/tools/viz/{render/index.js → render.js} +9 -8
  177. package/out/tools/viz/render.js.map +1 -0
  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 +35 -29
  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 +42 -185
  191. package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
  192. package/{lib/tools → tools}/cross/dataset-correlation.ts +35 -73
  193. package/{lib/tools → tools}/cross/source-threshold-sweep.ts +29 -46
  194. package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
  195. package/tools/eval-geocoder.ts +77 -0
  196. package/{lib/tools → tools}/geocoder/namesake-probe.ts +9 -8
  197. package/{lib/tools → tools}/geocoder/vs-provided-coords.ts +40 -31
  198. package/{lib/tools → tools}/gold-set-sample.ts +35 -29
  199. package/{lib/tools → tools}/learned/scorer/clustering-eval.ts +49 -45
  200. package/{lib/tools → tools}/learned/scorer/crossstate-eval.ts +34 -30
  201. package/{lib/tools → tools}/learned/scorer/eval.ts +39 -78
  202. package/{lib/tools → tools}/matcher-scale.ts +21 -33
  203. package/{lib/tools → tools}/nppes/dedup-benchmark.ts +39 -83
  204. package/tools/nppes/org-name.ts +15 -0
  205. package/{lib/tools → tools}/nppes/overmerge-packet.ts +16 -12
  206. package/{lib/tools → tools}/nppes/report.ts +32 -25
  207. package/{lib/tools → tools}/nppes/sample.ts +43 -38
  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 +79 -98
  212. package/{lib/tools → tools}/train/cross-gbt.ts +39 -34
  213. package/{lib/tools → tools}/train/gbt.ts +55 -41
  214. package/{lib/tools → tools}/train/org-cross-gbt.ts +40 -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 +29 -17
  219. package/{lib/tools → tools}/viz/render/map.ts +7 -6
  220. package/{lib/tools/viz/render/index.ts → 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/lib/tools/nppes/org-name.ts +0 -23
  226. package/out/tools/index.d.ts +0 -31
  227. package/out/tools/index.d.ts.map +0 -1
  228. package/out/tools/index.js +0 -31
  229. package/out/tools/index.js.map +0 -1
  230. package/out/tools/viz/render/index.d.ts.map +0 -1
  231. package/out/tools/viz/render/index.js.map +0 -1
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Jaccard floor at or above which two {@linkcode orgTokens} sets count as the
3
+ * same organization — the gold-set threshold.
4
+ */
5
+ export const ORG_TAU = 0.7
6
+
7
+ /**
8
+ * An NPI's primary registry identity: the org-name token set plus the address key of its practice location.
9
+ *
10
+ * Every grain of the org-name truth blocks on a location and filters on the tokens.
11
+ */
12
+ export interface NPIPrimary {
13
+ tokens: Set<string>
14
+ addrKey: string
15
+ }
@@ -2,46 +2,50 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- * @file The gold-set adjudication packet — the org-name-grain over-merged clusters, with every matcher-visible field,
6
- * formatted for human review.
5
+ * @file Writes the over-merged NPPES clusters with every matcher-visible field for human adjudication.
7
6
  */
8
7
 
9
8
  import { writeLocalTextFile } from "@mailwoman/core/fs/writers"
10
9
  import { formatPersonName } from "@mailwoman/record/name"
10
+ import type { PathBuilderLike } from "path-ts"
11
11
 
12
12
  import type { ResolvedEntity, SourceRecord } from "#index"
13
13
  import type { MessyRow } from "#tools/nppes/sample"
14
14
  import type { TruthLabel } from "#tools/nppes/truth-grains"
15
15
 
16
16
  /**
17
- * Everything the packet reads.
17
+ * The inputs to {@link writeOvermergePacket}.
18
18
  */
19
19
  export interface OvermergePacketInput {
20
20
  /**
21
- * The clusters to inspect — the SHIPPED config's, since the packet exists to adjudicate what production produces.
21
+ * The clusters to inspect.
22
+ * Callers pass the clusters from the shipped matcher config.
22
23
  */
23
24
  entities: readonly ResolvedEntity[]
24
25
  /**
25
- * The source rows, for the fields that ride as attributes rather than on the record face.
26
+ * The source rows.
27
+ *
28
+ * The packet reads the authorized official and taxonomy from them.
26
29
  */
27
30
  rows: readonly MessyRow[]
28
31
  recordCount: number
29
32
  maxNpis: number
30
33
  /**
31
- * The state the sample was drawn from, so the packet's own header names the run an adjudicator is holding.
34
+ * The state that the sample was drawn from.
35
+ * The packet header prints it.
32
36
  */
33
37
  state: string
34
38
  orgNameLabel: TruthLabel
35
39
  }
36
40
 
37
41
  /**
38
- * Write the packet and return the number of over-merged clusters it holds.
42
+ * Writes the adjudication packet and returns the number of over-merged clusters in it.
39
43
  *
40
- * A cluster qualifies when its members carry more than one org-name label — the matcher fused records the org-name
41
- * truth says belong to different entities. Per-pair human adjudication is the only instrument that separates model
42
- * error from yardstick error once the residual is near the measured irreducible ceiling.
44
+ * A cluster is over-merged when its members have more than one org-name truth label.
45
+ * A reviewer marks each cluster as one real entity or as distinct providers.
46
+ * which separates model error from truth-label error.
43
47
  */
44
- export async function writeOvermergePacket(path: string, input: OvermergePacketInput): Promise<number> {
48
+ export async function writeOvermergePacket(path: PathBuilderLike, input: OvermergePacketInput): Promise<number> {
45
49
  const { entities, rows, recordCount, maxNpis, state, orgNameLabel } = input
46
50
  const rowByID = new Map(rows.map((r) => [r.npi, r]))
47
51
 
@@ -80,7 +84,7 @@ export async function writeOvermergePacket(path: string, input: OvermergePacketI
80
84
  const src = rowByID.get(rec.id)
81
85
 
82
86
  out.push(
83
- ` - npi=${rec.id} · name="${formatPersonName(rec.name, "short")}" · org="${rec.organization?.canonical ?? ""}" · addr="${rec.address?.raw ?? ""}" · auth="${src?.auth ?? ""}" · taxonomy="${src?.taxonomy ?? ""}"`
87
+ ` - npi=${rec.id} · name="${formatPersonName(rec.name ?? null, "short")}" · org="${rec.organization?.canonical ?? ""}" · addr="${rec.address?.raw ?? ""}" · auth="${src?.auth ?? ""}" · taxonomy="${src?.taxonomy ?? ""}"`
84
88
  )
85
89
  }
86
90
  }
@@ -2,8 +2,6 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- * @file The NPPES dedup benchmark's markdown report. Pure: every figure comes from the input, because eval figures are
6
- * never hand-typed into docs.
7
5
  */
8
6
 
9
7
  import type { TermFrequencyTable } from "@mailwoman/match"
@@ -14,9 +12,6 @@ import type { Score } from "#tools/nppes/scoring"
14
12
  import { COLOCATION_KM } from "#tools/nppes/truth-grains"
15
13
  import { pct } from "#tools/shared"
16
14
 
17
- /**
18
- * F1 gap within which two blocking strategies are treated as equivalent.
19
- */
20
15
  const BLOCKING_PARITY_TOLERANCE = 0.015
21
16
 
22
17
  /**
@@ -32,7 +27,7 @@ export interface SettingScore {
32
27
  */
33
28
  export interface SweepArm {
34
29
  /**
35
- * Link threshold, in bits.
30
+ * The link threshold, in bits.
36
31
  */
37
32
  t: number
38
33
  res: Pick<ResolveResult, "candidatePairs" | "droppedBlocks">
@@ -40,36 +35,47 @@ export interface SweepArm {
40
35
  }
41
36
 
42
37
  /**
43
- * Everything the report reads.
38
+ * Inputs consumed by the report.
44
39
  */
45
40
  export interface NPPESReportInput {
46
41
  state: string
42
+
47
43
  /**
48
- * Sampled NPIs — the true-entity count at the NPI grain.
44
+ * The number of sampled NPIs.
45
+ * This is the true entity count at the NPI grain.
49
46
  */
50
47
  keptNpis: number
51
48
  recordCount: number
49
+
52
50
  /**
53
- * Records whose address placed.
51
+ * The number of records whose address was placed.
54
52
  */
55
53
  geocoded: number
56
54
  trainEM: boolean
55
+
57
56
  /**
58
- * The corpus-wide table the progression was fed; only its `total`/`distinct` are reported.
57
+ * The corpus-wide address-frequency table fed to the progression, of
58
+ * which only `total` and `distinct` are reported.
59
59
  */
60
60
  addressFrequency: TermFrequencyTable
61
+
61
62
  /**
62
- * The setting progression in order. The first row is the bare baseline, the last the full stack.
63
+ * The setting progression from the bare baseline to the full stack.
64
+ * The report requires at least four rows.
63
65
  */
64
66
  progression: readonly SettingScore[]
67
+
65
68
  /**
66
- * Zero-config `resolveEntities(records)` — reported apart from the progression because its address-frequency table is
67
- * input-scoped, which on a sub-sample is intentionally sparse.
69
+ * The zero-config `resolveEntities` score, reported apart because its input-scoped
70
+ * frequency table is sparse on a sub-sample.
68
71
  */
69
72
  defaultOutOfBox: Score
70
73
  sweep: readonly SweepArm[]
74
+
71
75
  /**
72
- * The best-F1 arm. Must be an element of {@linkcode sweep} — the table stars it by identity.
76
+ * The best-F1 arm.
77
+ *
78
+ * It must be an element of `sweep` because the table marks it by identity.
73
79
  */
74
80
  best: SweepArm
75
81
  entityCount: number
@@ -85,13 +91,16 @@ export interface NPPESReportInput {
85
91
  gbtOrg: Score
86
92
  gbtOrgCoord: Score
87
93
  gbtOrgH3: Score
94
+
88
95
  /**
89
- * The optional `--candidate` A/B row.
96
+ * The optional `--candidate` A/B row, or `null` when no candidate was given.
90
97
  */
91
98
  candidate: { label: string; npi: Score; entity: Score } | null
92
99
  h3Res: number
100
+
93
101
  /**
94
- * Sampled NPIs whose primary practice address placed — the population the coordinate grain can act on.
102
+ * The number of sampled NPIs whose primary practice address was placed.
103
+ * This bounds what the coordinate grain can act on.
95
104
  */
96
105
  geocodedNpis: number
97
106
  }
@@ -129,12 +138,10 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
129
138
  geocodedNpis,
130
139
  } = input
131
140
 
132
- const baseline = progression[0]! // no settings — the prior-prior behaviour
133
- // The LAST progression row — the whole A1–A5 stack, never compared on F1 against the others. Named for what it
134
- // is: a row called `best` invites reading a stack-wide delta as one setting's marginal effect, which is how the
135
- // authorized-official sentence below came to quote a five-setting number.
141
+ const baseline = progression[0]!
142
+
136
143
  const fullStack = progression.at(-1)!
137
- const base = sweep[0]! // threshold 0, full setting stack
144
+ const base = sweep[0]!
138
145
 
139
146
  const signed = (x: number) => `${x >= 0 ? "+" : ""}${x.toFixed(1)}pp`
140
147
 
@@ -148,7 +155,7 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
148
155
  "",
149
156
  `**Headline — org-name truth (the honest grain):** the shipped ` +
150
157
  `matcher resolves these records at **F1 ${pct(gbtOrg.f1)}%** against org-name entity-truth — not the NPI-level ` +
151
- `${pct(gbtNPI.f1)}%, which mostly measures NPI over-segmentation (one organization holds many subpart NPIs, so ` +
158
+ `${pct(gbtNPI.f1)}%. It mostly measures NPI over-segmentation (one organization holds many subpart NPIs. Therefore, ` +
152
159
  `correct co-located merges are scored as errors). Same clusters, three rulers: ` +
153
160
  `**NPI ${pct(gbtNPI.f1)}% → site ${pct(gbtEntity.f1)}% → org-name ${pct(gbtOrg.f1)}%** ` +
154
161
  `(${keptNpis} NPI → ${entityCount} site → ${orgCount} org-name classes); the climb is the yardstick getting honest, ` +
@@ -189,7 +196,7 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
189
196
  `**${pct(defaultOutOfBox.f1)}%** on this sample — essentially the baseline. The default auto-computes the ` +
190
197
  `address-frequency table over the INPUT records, and this benchmark deliberately sub-samples ${N} records, so ` +
191
198
  `that table is too sparse to carry the inverse-frequency signal (a corpus statistic you can't synthesize from a ` +
192
- `slice). It's **not a regression** (≥ baseline, no over-merge added) — it's the honest floor when the input isn't ` +
199
+ `sample). It's **not a regression**, because it meets the baseline without adding over-merges — it's the honest floor when the input isn't ` +
193
200
  `corpus-scale. Fed the corpus-wide table (the \`+ inverse-address-frequency\` row above, what the CLI builds from ` +
194
201
  `the full source files) the SAME default reaches the **${pct(progression[2]!.score.f1)}%** baseline. On a full-dataset ` +
195
202
  `dedup the input IS the corpus, so zero-config reaches the baseline on its own.`
@@ -214,7 +221,7 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
214
221
  lines.push(
215
222
  best.t === 0
216
223
  ? `Best F1 is at the **default threshold** (${pct(base.score.f1)}%): raising it only trades recall away faster ` +
217
- `than it buys precision. So the threshold knob alone can't separate co-located distinct providers — the ` +
224
+ `than it provides precision. So the threshold knob alone can't separate co-located distinct providers — the ` +
218
225
  `over-merge is structural, in the comparison model, not the cutoff.`
219
226
  : `Best F1 **${pct(best.score.f1)}%** (ARI ${best.score.ari.toFixed(3)}) at threshold ${best.t}, vs **${pct(base.score.f1)}%** at the ` +
220
227
  `default — the threshold knob moves it ${(100 * (best.score.f1 - base.score.f1)).toFixed(0)}pp. Higher thresholds trade recall for precision.`
@@ -334,7 +341,7 @@ export function renderNPPESDedupReport(input: NPPESReportInput): string {
334
341
  lines.push(
335
342
  `Caveats: the programmatic site-truth is CONSERVATIVE (collapses only NPPES-flagged subparts; unflagged same-org pairs still ` +
336
343
  `read as over-merge), so it understates the subpart correction. A hand-adjudicated gold set on the ambiguous co-located + ` +
337
- `two-site slice is the next refinement (#625).`
344
+ `two-site stratum is the next refinement (#625).`
338
345
  )
339
346
 
340
347
  lines.push("")
@@ -2,21 +2,24 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- * @file The NPPES benchmark's input sample: the variation-rich multi-record set per NPI, plus the corpus-wide
6
- * address-frequency table built in the same pass. One registry pass serves any number of states — the cross-state
7
- * eval samples two at once.
5
+ *
6
+ * The NPPES benchmark's input sample: the variation-rich multi-record set per NPI, plus the
7
+ * corpus-wide address-frequency table built in the same pass. One registry pass serves any number
8
+ * of states, so the cross-state eval samples two at once.
8
9
  */
9
10
 
10
11
  import { isPresent } from "@mailwoman/core/objects"
11
12
  import type { TermFrequencyTable } from "@mailwoman/match"
12
13
 
13
14
  import { addressFrequencyKey, streamRows } from "#index"
14
- import { orgTokens, type NPIPrimary } from "#tools/nppes/org-name"
15
- import { addr, MIN_GROUP_SIZE, norm, NPPES_COLUMNS as C } from "#tools/shared"
15
+ import type { NPIPrimary } from "#tools/nppes/org-name"
16
+ import { orgTokens, addr, MIN_GROUP_SIZE, norm, NPPES_COLUMNS as C } from "#tools/shared"
16
17
 
17
18
  /**
18
- * One synthetic input row for the matcher; `npi` is the hidden NPI-level truth, `entityID` the site-level entity-level
19
- * truth (subpart-collapsed).
19
+ * One synthetic input row for the matcher.
20
+ *
21
+ * `npi` is the hidden NPI-level truth.
22
+ * `entityID` is the site-level entity-level truth (subpart-collapsed).
20
23
  */
21
24
  export interface MessyRow extends Record<string, string> {
22
25
  npi: string
@@ -25,19 +28,20 @@ export interface MessyRow extends Record<string, string> {
25
28
  address: string
26
29
  auth: string
27
30
  /**
28
- * Whitespace-joined taxonomy-code set (up to 15 slots) — the #625 code-set discriminator.
31
+ * Whitespace-joined taxonomy-code set, up to 15 slots, used as the code-set discriminator.
29
32
  */
30
33
  taxonomy: string
31
34
  entityID: string
32
35
  }
33
36
 
34
37
  /**
35
- * One state's slice of the sample pass.
38
+ * One state's share of the sample pass.
36
39
  */
37
40
  export interface NPPESStateSample {
38
41
  rows: MessyRow[]
39
42
  /**
40
- * The sampled NPIs — the true-entity count at the NPI grain.
43
+ * The sampled NPIs.
44
+ * Their count is the true-entity count at the NPI grain.
41
45
  */
42
46
  keptNpis: Set<string>
43
47
  /**
@@ -51,8 +55,10 @@ export interface NPPESStateSample {
51
55
  */
52
56
  export interface NPPESSample extends NPPESStateSample {
53
57
  /**
54
- * Corpus-wide address-frequency table — the inverse-frequency signal. Counted over EVERY practice address in the
55
- * registry, not just the sample, so the sharing structure is a corpus statistic rather than a slice artifact.
58
+ * Corpus-wide address-frequency table, the inverse-frequency signal.
59
+ *
60
+ * Counted over every practice address in the registry rather than just the sample,
61
+ * so the sharing structure is a corpus statistic rather than a sampling artifact.
56
62
  */
57
63
  addressFrequency: TermFrequencyTable
58
64
  }
@@ -64,20 +70,23 @@ export interface NPPESSampleOptions {
64
70
  registryPath: string
65
71
  otherNamesPath: string
66
72
  /**
67
- * Already upper-cased; compared against the practice-location state column.
73
+ * Already upper-cased.
74
+ * Compared against the practice-location state column.
68
75
  */
69
76
  state: string
70
77
  maxNpis: number
71
78
  }
72
79
 
73
80
  /**
74
- * The multi-state shape of {@linkcode NPPESSampleOptions} — one registry pass fills every state's bucket.
81
+ * The multi-state shape of {@linkcode NPPESSampleOptions}, where one registry
82
+ * pass fills every state's bucket.
75
83
  */
76
84
  export interface NPPESMultiSampleOptions {
77
85
  registryPath: string
78
86
  otherNamesPath: string
79
87
  /**
80
- * Already upper-cased; compared against the practice-location state column.
88
+ * Already upper-cased.
89
+ * Compared against the practice-location state column.
81
90
  */
82
91
  states: readonly string[]
83
92
  maxNpisPerState: number
@@ -86,9 +95,11 @@ export interface NPPESMultiSampleOptions {
86
95
  /**
87
96
  * Build the benchmark's input records from the real registry, one bucket per requested state.
88
97
  *
89
- * Two passes over two files, and the SECOND one cannot break early: the address-frequency table needs every registry
90
- * row even after the sample is full, so the per-bucket `keptNpis.size < maxNpisPerState` test bounds only the sample
91
- * branch.
98
+ * Two passes read the two files.
99
+ * The second pass cannot break early because the address-frequency table needs
100
+ * every registry row even after the sample is full.
101
+ *
102
+ * The per-bucket `keptNpis.size < maxNpisPerState` test bounds only the sample branch.
92
103
  */
93
104
  export async function buildNPPESStateSamples(
94
105
  options: NPPESMultiSampleOptions,
@@ -96,7 +107,6 @@ export async function buildNPPESStateSamples(
96
107
  ): Promise<{ byState: Map<string, NPPESStateSample>; addressFrequency: TermFrequencyTable }> {
97
108
  const { registryPath, otherNamesPath, states, maxNpisPerState } = options
98
109
 
99
- // Select NPIs with at least one alternate organization name.
100
110
  report?.("[A] streaming other-names…")
101
111
  const altNames = new Map<string, string[]>()
102
112
 
@@ -117,8 +127,8 @@ export async function buildNPPESStateSamples(
117
127
 
118
128
  report?.(` ${altNames.size} NPIs with ≥1 alternate name`)
119
129
 
120
- // Make one full registry pass to build the global address-frequency table.
121
- // address, so the sharing structure is corpus-wide, not sample-biased) AND collect every state's sample. ---
130
+ // One full registry pass builds the global address-frequency table and collects every state's sample.
131
+ // Each row contributes to the corpus-wide sharing structure, independent of the state sample.
122
132
  report?.(`[B] full registry pass: address-frequency table + ${maxNpisPerState} × ${states.join("/")} sample…`)
123
133
 
124
134
  const byState = new Map<string, NPPESStateSample>(
@@ -137,7 +147,6 @@ export async function buildNPPESStateSamples(
137
147
 
138
148
  const practice = addr(r[C.pAddr]!, r[C.pCity]!, r[C.pState]!, r[C.pZip]!)
139
149
 
140
- // Global address-frequency: count every practice address (one row ≈ one distinct NPI).
141
150
  if (practice) {
142
151
  const k = addressFrequencyKey(practice)
143
152
  addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1)
@@ -145,8 +154,7 @@ export async function buildNPPESStateSamples(
145
154
  addrTotal++
146
155
  }
147
156
 
148
- // Sample: in-state NPIs with ≥1 alternate name, up to maxNpisPerState — NO early break (the table
149
- // needs the full pass).
157
+ // No early break here, since the table needs the full pass.
150
158
  const npi = norm(r[C.npi])
151
159
  const bucket = byState.get(norm(r[C.pState]).toUpperCase())
152
160
 
@@ -165,20 +173,20 @@ export async function buildNPPESStateSamples(
165
173
  const org = isOrg ? norm(r[C.orgLegal]) : ""
166
174
  const auth = `${norm(r[C.authFirst])} ${norm(r[C.authLast])}`.trim()
167
175
 
168
- // the NPI's registrant — shared across its records
169
- // #625: the taxonomy-code set (up to 15 slots), whitespace-joined — identical across the NPI's
170
- // records by construction (it's a per-NPI registry attribute), so it NEVER splits one entity;
171
- // it only separates co-located DISTINCT providers whose sets are disjoint.
176
+ // The taxonomy-code set (up to 15 slots) is whitespace-joined and identical
177
+ // across the NPI's records by construction, so it never splits one entity.
178
+ // It only separates co-located distinct providers whose sets are disjoint.
172
179
  const taxonomy = C.taxonomy
173
180
  .map((col) => norm(r[col]))
174
181
  .filter(isPresent)
175
182
  .join(" ")
176
183
 
177
- // Entity-level (site) truth: same org + same physical address. Subparts (NPPES
178
- // "Is Organization Subpart" + parent LBN/TIN) collapse to their PARENT, so the matcher isn't
179
- // charged for correctly fusing one org's many subpart-NPIs at a site; an NPI's mailing-vs-
180
- // practice records stay DISTINCT sites. orgKey = parent identity for subparts, else the NPI
181
- // (independent orgs sharing an address stay distinct — the conservative choice).
184
+ // Entity-level (site) truth is the same org and the same physical address.
185
+ // Subparts (NPPES "Is Organization Subpart" plus parent LBN/TIN) collapse to their parent,
186
+ // so the matcher is not charged for correctly fusing one org's many subpart-NPIs at a site.
187
+ // An NPI's mailing and practice records stay distinct sites.
188
+ // `orgKey` is the parent identity for a subpart, else the NPI,
189
+ // so independent orgs sharing an address stay distinct.
182
190
  const isSubpart = norm(r[C.isSubpart]).toUpperCase() === "Y"
183
191
  const parentKey = `${norm(r[C.parentLBN])}|${norm(r[C.parentTIN])}`.toLowerCase()
184
192
  const orgKey = isSubpart && parentKey !== "|" ? `p:${parentKey}` : `n:${npi}`
@@ -193,22 +201,19 @@ export async function buildNPPESStateSamples(
193
201
  keptTotal++
194
202
  bucket.rows.push({ npi, name: primaryName, org, address: practice, auth, taxonomy, entityID: eid(practice) })
195
203
 
196
- // primary
197
204
  for (const alt of altNames.get(npi)!) {
198
205
  bucket.rows.push({ npi, name: alt, org: alt, address: practice, auth, taxonomy, entityID: eid(practice) })
199
206
  }
200
207
 
201
- // name drift
202
208
  const mailing = addr(r[C.mAddr]!, r[C.mCity]!, r[C.mState]!, r[C.mZip]!)
203
209
 
204
210
  if (mailing && mailing !== practice) {
205
211
  bucket.rows.push({ npi, name: primaryName, org, address: mailing, auth, taxonomy, entityID: eid(mailing) })
206
- } // address variation
212
+ }
207
213
  }
208
214
  }
209
215
  }
210
216
 
211
- // Corpus-wide address-frequency table — the inverse-frequency signal (#617 fix per the DeepSeek consult).
212
217
  const addressFrequency: TermFrequencyTable = {
213
218
  total: addrTotal,
214
219
  distinct: addrCounts.size,
@@ -225,7 +230,7 @@ export async function buildNPPESStateSamples(
225
230
  }
226
231
 
227
232
  /**
228
- * Build one state's benchmark input records — {@linkcode buildNPPESStateSamples} with a single bucket.
233
+ * Build one state's benchmark input records using {@linkcode buildNPPESStateSamples} with a single bucket.
229
234
  */
230
235
  export async function buildNPPESSample(
231
236
  options: NPPESSampleOptions,
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  * @file Pairwise cluster scoring for the NPPES benchmark — precision/recall/F1 and adjusted Rand of recovered clusters
6
- * against a truth labelling, plus the over-merge / under-merge shape counts.
6
+ * against a truth labeling, plus the over-merge / under-merge shape counts.
7
7
  */
8
8
 
9
9
  import type { ResolvedEntity, SourceRecord } from "#index"
@@ -14,7 +14,7 @@ import type { ResolvedEntity, SourceRecord } from "#index"
14
14
  export const choose2 = (n: number): number => (n * (n - 1)) / 2
15
15
 
16
16
  /**
17
- * One clustering scored against one truth labelling.
17
+ * One clustering scored against one truth labeling.
18
18
  */
19
19
  export interface Score {
20
20
  precision: number
@@ -30,11 +30,12 @@ export interface Score {
30
30
  }
31
31
 
32
32
  /**
33
- * Score recovered clusters against a truth labelling.
33
+ * Score recovered clusters against a truth labeling.
34
34
  *
35
- * Pairwise, not set-matching: a true pair is two records carrying the same `labelOf`, a predicted pair is two records
36
- * in the same entity. `totalRecords` is the labelled population and only feeds the adjusted-Rand expectation, so it
37
- * must be the whole record set rather than the clustered subset — a smaller value inflates ARI.
35
+ * Pairwise rather than set-matching: a true pair is two records carrying the same `labelOf`,
36
+ * a predicted pair is two records in the same entity.
37
+ * `totalRecords` is the labeled population and only feeds the adjusted-Rand expectation,
38
+ * so it must be the whole record set rather than the clustered subset — a smaller value inflates ARI.
38
39
  */
39
40
  export function scoreEntities(
40
41
  entities: readonly ResolvedEntity[],
@@ -2,8 +2,9 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- * @file The comparison-model setting progression the NPPES benchmark walks — each row turns one setting on so its marginal
6
- * effect is isolated.
5
+ *
6
+ * The comparison-model setting progression the NPPES benchmark walks, where each row turns one
7
+ * setting on so its marginal effect is isolated.
7
8
  */
8
9
 
9
10
  import type { TermFrequencyTable } from "@mailwoman/match"
@@ -32,11 +33,13 @@ export interface Setting {
32
33
  /**
33
34
  * Build the progression against a corpus-wide address-frequency table.
34
35
  *
35
- * Every row sets BOTH `collapseSpatial` and `addressFrequency` EXPLICITLY, because the proven settings are default-on
36
- * in `resolveEntities`: leave either implicit and the flipped default silently rides the `+ inverse-address-frequency`
37
- * row, making the A1 delta read as 0. Every row is fed the corpus-wide table — the realistic deployment, where the CLI
38
- * builds it from the full source files — so the zero-config default, whose input-scoped table is intentionally sparse
39
- * on a sub-sample, has to be measured separately.
36
+ * Every row sets both `collapseSpatial` and `addressFrequency` explicitly,
37
+ * because the proven settings are default-on in `resolveEntities`.
38
+ * Leave either implicit and the flipped default silently follows the inverse-address-frequency row.
39
+ * That makes the delta read as 0.
40
+ *
41
+ * Every row is fed the corpus-wide table, the realistic deployment, so the zero-config
42
+ * default with its input-scoped table has to be measured separately.
40
43
  */
41
44
  export function buildSettings(addressFrequency: TermFrequencyTable): Setting[] {
42
45
  return [
@@ -50,10 +53,8 @@ export function buildSettings(addressFrequency: TermFrequencyTable): Setting[] {
50
53
  label: "+ authorized-official discriminator (#625)",
51
54
  config: { collapseSpatial: true, addressFrequency, discriminators: ["authorizedOfficial"] },
52
55
  },
53
- // A2–A4 (#625): the built-but-unmeasured over-merge settings. Each builds on the A1 + discriminator
54
- // stack so the marginal effect is isolated. A2 (require name/org corroboration) is the direct
55
- // over-merge precision setting; A3 (phone) is the recall-tail corroborator that should keep A2 from
56
- // killing name-drift links; A4 (average-linkage) splits a component joined only by a weak bridge.
56
+ // The over-merge settings each build on the collapsed-spatial and discriminator stack,
57
+ // so the marginal effect of each is isolated.
57
58
  {
58
59
  label: "+ require name/org corroboration (A2, #625)",
59
60
  config: {
@@ -84,11 +85,10 @@ export function buildSettings(addressFrequency: TermFrequencyTable): Setting[] {
84
85
  linkage: "average",
85
86
  },
86
87
  },
87
- // A5 (#625): the taxonomy code-set discriminator — set-overlap agreement over the NPI's 15 taxonomy
88
- // slots. The named "still-more-distinctive identifier" from the 2026-06-16 report: co-located
89
- // DISTINCT providers usually have disjoint sets (the over-merge separator) while an entity's own
90
- // records always share theirs (never splits). Stacked on the BEST prior classical config (A1 +
91
- // authorized-official; A3 phone + A4 avg-linkage were measured neutral-to-negative and are left off).
88
+ // The taxonomy code-set discriminator uses set-overlap agreement over the NPI's 15 taxonomy slots.
89
+ // Co-located distinct providers usually have disjoint sets, while an entity's
90
+ // own records always share theirs.
91
+ // It is stacked on the best prior classical config.
92
92
  {
93
93
  label: "+ taxonomy code-set discriminator (A5, #625)",
94
94
  config: {