@mailwoman/entity-resolution 0.0.0-stage → 10.8.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 (227) hide show
  1. package/README.md +114 -2
  2. package/lib/address-key.ts +46 -0
  3. package/lib/geocode-handler.ts +37 -0
  4. package/lib/geojson.ts +72 -0
  5. package/lib/index.ts +23 -0
  6. package/lib/ingest.ts +349 -0
  7. package/lib/learned-scorer.ts +134 -0
  8. package/lib/map-html.ts +287 -0
  9. package/lib/models/crosssource-gbt-en-us.ts +43 -0
  10. package/lib/models/dedup-gbt-en-us.ts +47 -0
  11. package/lib/models/org-crosssource-gbt-en-us.ts +43 -0
  12. package/lib/reconcile.ts +239 -0
  13. package/lib/resolve.ts +569 -0
  14. package/lib/types.ts +110 -0
  15. package/out/address-key.d.ts +34 -0
  16. package/out/address-key.d.ts.map +1 -0
  17. package/out/address-key.js +41 -0
  18. package/out/address-key.js.map +1 -0
  19. package/out/geocode-handler.d.ts +20 -0
  20. package/out/geocode-handler.d.ts.map +1 -0
  21. package/out/geocode-handler.js +29 -0
  22. package/out/geocode-handler.js.map +1 -0
  23. package/out/geojson.d.ts +28 -0
  24. package/out/geojson.d.ts.map +1 -0
  25. package/out/geojson.js +62 -0
  26. package/out/geojson.js.map +1 -0
  27. package/out/index.d.ts +23 -0
  28. package/out/index.d.ts.map +1 -0
  29. package/out/index.js +23 -0
  30. package/out/index.js.map +1 -0
  31. package/out/ingest.d.ts +173 -0
  32. package/out/ingest.d.ts.map +1 -0
  33. package/out/ingest.js +185 -0
  34. package/out/ingest.js.map +1 -0
  35. package/out/learned-scorer.d.ts +61 -0
  36. package/out/learned-scorer.d.ts.map +1 -0
  37. package/out/learned-scorer.js +91 -0
  38. package/out/learned-scorer.js.map +1 -0
  39. package/out/map-html.d.ts +39 -0
  40. package/out/map-html.d.ts.map +1 -0
  41. package/out/map-html.js +220 -0
  42. package/out/map-html.js.map +1 -0
  43. package/out/models/crosssource-gbt-en-us.d.ts +45 -0
  44. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -0
  45. package/out/models/crosssource-gbt-en-us.js +40 -0
  46. package/out/models/crosssource-gbt-en-us.js.map +1 -0
  47. package/out/models/dedup-gbt-en-us.d.ts +44 -0
  48. package/out/models/dedup-gbt-en-us.d.ts.map +1 -0
  49. package/out/models/dedup-gbt-en-us.js +44 -0
  50. package/out/models/dedup-gbt-en-us.js.map +1 -0
  51. package/out/models/org-crosssource-gbt-en-us.d.ts +45 -0
  52. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -0
  53. package/out/models/org-crosssource-gbt-en-us.js +40 -0
  54. package/out/models/org-crosssource-gbt-en-us.js.map +1 -0
  55. package/out/reconcile.d.ts +96 -0
  56. package/out/reconcile.d.ts.map +1 -0
  57. package/out/reconcile.js +127 -0
  58. package/out/reconcile.js.map +1 -0
  59. package/out/resolve.d.ts +264 -0
  60. package/out/resolve.d.ts.map +1 -0
  61. package/out/resolve.js +282 -0
  62. package/out/resolve.js.map +1 -0
  63. package/out/tools/coverage-reconciliation.d.ts +67 -0
  64. package/out/tools/coverage-reconciliation.d.ts.map +1 -0
  65. package/out/tools/coverage-reconciliation.js +113 -0
  66. package/out/tools/coverage-reconciliation.js.map +1 -0
  67. package/out/tools/cross/dataset-correlation.d.ts +61 -0
  68. package/out/tools/cross/dataset-correlation.d.ts.map +1 -0
  69. package/out/tools/cross/dataset-correlation.js +244 -0
  70. package/out/tools/cross/dataset-correlation.js.map +1 -0
  71. package/out/tools/cross/source-threshold-sweep.d.ts +60 -0
  72. package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -0
  73. package/out/tools/cross/source-threshold-sweep.js +264 -0
  74. package/out/tools/cross/source-threshold-sweep.js.map +1 -0
  75. package/out/tools/dedup-ceiling.d.ts +62 -0
  76. package/out/tools/dedup-ceiling.d.ts.map +1 -0
  77. package/out/tools/dedup-ceiling.js +171 -0
  78. package/out/tools/dedup-ceiling.js.map +1 -0
  79. package/out/tools/eval-geocoder.d.ts +68 -0
  80. package/out/tools/eval-geocoder.d.ts.map +1 -0
  81. package/out/tools/eval-geocoder.js +13 -0
  82. package/out/tools/eval-geocoder.js.map +1 -0
  83. package/out/tools/geocoder/namesake-probe.d.ts +33 -0
  84. package/out/tools/geocoder/namesake-probe.d.ts.map +1 -0
  85. package/out/tools/geocoder/namesake-probe.js +60 -0
  86. package/out/tools/geocoder/namesake-probe.js.map +1 -0
  87. package/out/tools/geocoder/vs-provided-coords.d.ts +53 -0
  88. package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -0
  89. package/out/tools/geocoder/vs-provided-coords.js +161 -0
  90. package/out/tools/geocoder/vs-provided-coords.js.map +1 -0
  91. package/out/tools/gold-set-sample.d.ts +67 -0
  92. package/out/tools/gold-set-sample.d.ts.map +1 -0
  93. package/out/tools/gold-set-sample.js +81 -0
  94. package/out/tools/gold-set-sample.js.map +1 -0
  95. package/out/tools/learned/scorer/clustering-eval.d.ts +77 -0
  96. package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -0
  97. package/out/tools/learned/scorer/clustering-eval.js +207 -0
  98. package/out/tools/learned/scorer/clustering-eval.js.map +1 -0
  99. package/out/tools/learned/scorer/crossstate-eval.d.ts +65 -0
  100. package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -0
  101. package/out/tools/learned/scorer/crossstate-eval.js +168 -0
  102. package/out/tools/learned/scorer/crossstate-eval.js.map +1 -0
  103. package/out/tools/learned/scorer/eval.d.ts +64 -0
  104. package/out/tools/learned/scorer/eval.d.ts.map +1 -0
  105. package/out/tools/learned/scorer/eval.js +275 -0
  106. package/out/tools/learned/scorer/eval.js.map +1 -0
  107. package/out/tools/matcher-scale.d.ts +40 -0
  108. package/out/tools/matcher-scale.d.ts.map +1 -0
  109. package/out/tools/matcher-scale.js +111 -0
  110. package/out/tools/matcher-scale.js.map +1 -0
  111. package/out/tools/nppes/dedup-benchmark.d.ts +82 -0
  112. package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -0
  113. package/out/tools/nppes/dedup-benchmark.js +226 -0
  114. package/out/tools/nppes/dedup-benchmark.js.map +1 -0
  115. package/out/tools/nppes/org-name.d.ts +15 -0
  116. package/out/tools/nppes/org-name.d.ts.map +1 -0
  117. package/out/tools/nppes/org-name.js +6 -0
  118. package/out/tools/nppes/org-name.js.map +1 -0
  119. package/out/tools/nppes/overmerge-packet.d.ts +43 -0
  120. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -0
  121. package/out/tools/nppes/overmerge-packet.js +54 -0
  122. package/out/tools/nppes/overmerge-packet.js.map +1 -0
  123. package/out/tools/nppes/report.d.ts +97 -0
  124. package/out/tools/nppes/report.d.ts.map +1 -0
  125. package/out/tools/nppes/report.js +178 -0
  126. package/out/tools/nppes/report.js.map +1 -0
  127. package/out/tools/nppes/sample.d.ts +101 -0
  128. package/out/tools/nppes/sample.d.ts.map +1 -0
  129. package/out/tools/nppes/sample.js +127 -0
  130. package/out/tools/nppes/sample.js.map +1 -0
  131. package/out/tools/nppes/scoring.d.ts +37 -0
  132. package/out/tools/nppes/scoring.d.ts.map +1 -0
  133. package/out/tools/nppes/scoring.js +81 -0
  134. package/out/tools/nppes/scoring.js.map +1 -0
  135. package/out/tools/nppes/settings.d.ts +41 -0
  136. package/out/tools/nppes/settings.d.ts.map +1 -0
  137. package/out/tools/nppes/settings.js +79 -0
  138. package/out/tools/nppes/settings.js.map +1 -0
  139. package/out/tools/nppes/truth-grains.d.ts +63 -0
  140. package/out/tools/nppes/truth-grains.d.ts.map +1 -0
  141. package/out/tools/nppes/truth-grains.js +142 -0
  142. package/out/tools/nppes/truth-grains.js.map +1 -0
  143. package/out/tools/shared.d.ts +325 -0
  144. package/out/tools/shared.d.ts.map +1 -0
  145. package/out/tools/shared.js +453 -0
  146. package/out/tools/shared.js.map +1 -0
  147. package/out/tools/train/cross-gbt.d.ts +89 -0
  148. package/out/tools/train/cross-gbt.d.ts.map +1 -0
  149. package/out/tools/train/cross-gbt.js +132 -0
  150. package/out/tools/train/cross-gbt.js.map +1 -0
  151. package/out/tools/train/gbt.d.ts +85 -0
  152. package/out/tools/train/gbt.d.ts.map +1 -0
  153. package/out/tools/train/gbt.js +155 -0
  154. package/out/tools/train/gbt.js.map +1 -0
  155. package/out/tools/train/org-cross-gbt.d.ts +85 -0
  156. package/out/tools/train/org-cross-gbt.d.ts.map +1 -0
  157. package/out/tools/train/org-cross-gbt.js +122 -0
  158. package/out/tools/train/org-cross-gbt.js.map +1 -0
  159. package/out/tools/txhhsc-to-oarow.d.ts +42 -0
  160. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -0
  161. package/out/tools/txhhsc-to-oarow.js +78 -0
  162. package/out/tools/txhhsc-to-oarow.js.map +1 -0
  163. package/out/tools/viz/browser.d.ts +31 -0
  164. package/out/tools/viz/browser.d.ts.map +1 -0
  165. package/out/tools/viz/browser.js +26 -0
  166. package/out/tools/viz/browser.js.map +1 -0
  167. package/out/tools/viz/cross-dataset-map.d.ts +39 -0
  168. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -0
  169. package/out/tools/viz/cross-dataset-map.js +84 -0
  170. package/out/tools/viz/cross-dataset-map.js.map +1 -0
  171. package/out/tools/viz/geocode-first-surface.d.ts +36 -0
  172. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -0
  173. package/out/tools/viz/geocode-first-surface.js +234 -0
  174. package/out/tools/viz/geocode-first-surface.js.map +1 -0
  175. package/out/tools/viz/render/map.d.ts +42 -0
  176. package/out/tools/viz/render/map.d.ts.map +1 -0
  177. package/out/tools/viz/render/map.js +40 -0
  178. package/out/tools/viz/render/map.js.map +1 -0
  179. package/out/tools/viz/render.d.ts +46 -0
  180. package/out/tools/viz/render.d.ts.map +1 -0
  181. package/out/tools/viz/render.js +49 -0
  182. package/out/tools/viz/render.js.map +1 -0
  183. package/out/tools/viz/source-provenance-map.d.ts +57 -0
  184. package/out/tools/viz/source-provenance-map.d.ts.map +1 -0
  185. package/out/tools/viz/source-provenance-map.js +82 -0
  186. package/out/tools/viz/source-provenance-map.js.map +1 -0
  187. package/out/tools/viz/yardstick-figure.d.ts +22 -0
  188. package/out/tools/viz/yardstick-figure.d.ts.map +1 -0
  189. package/out/tools/viz/yardstick-figure.js +106 -0
  190. package/out/tools/viz/yardstick-figure.js.map +1 -0
  191. package/out/types.d.ts +108 -0
  192. package/out/types.d.ts.map +1 -0
  193. package/out/types.js +11 -0
  194. package/out/types.js.map +1 -0
  195. package/package.json +113 -3
  196. package/tools/coverage-reconciliation.ts +192 -0
  197. package/tools/cross/dataset-correlation.ts +380 -0
  198. package/tools/cross/source-threshold-sweep.ts +416 -0
  199. package/tools/dedup-ceiling.ts +225 -0
  200. package/tools/eval-geocoder.ts +77 -0
  201. package/tools/geocoder/namesake-probe.ts +91 -0
  202. package/tools/geocoder/vs-provided-coords.ts +232 -0
  203. package/tools/gold-set-sample.ts +147 -0
  204. package/tools/learned/scorer/clustering-eval.ts +349 -0
  205. package/tools/learned/scorer/crossstate-eval.ts +280 -0
  206. package/tools/learned/scorer/eval.ts +429 -0
  207. package/tools/matcher-scale.ts +185 -0
  208. package/tools/nppes/dedup-benchmark.ts +364 -0
  209. package/tools/nppes/org-name.ts +15 -0
  210. package/tools/nppes/overmerge-packet.ts +98 -0
  211. package/tools/nppes/report.ts +380 -0
  212. package/tools/nppes/sample.ts +250 -0
  213. package/tools/nppes/scoring.ts +115 -0
  214. package/tools/nppes/settings.ts +102 -0
  215. package/tools/nppes/truth-grains.ts +185 -0
  216. package/tools/shared.ts +743 -0
  217. package/tools/train/cross-gbt.ts +214 -0
  218. package/tools/train/gbt.ts +261 -0
  219. package/tools/train/org-cross-gbt.ts +189 -0
  220. package/tools/txhhsc-to-oarow.ts +118 -0
  221. package/tools/viz/browser.ts +41 -0
  222. package/tools/viz/cross-dataset-map.ts +133 -0
  223. package/tools/viz/geocode-first-surface.ts +305 -0
  224. package/tools/viz/render/map.ts +61 -0
  225. package/tools/viz/render.ts +103 -0
  226. package/tools/viz/source-provenance-map.ts +154 -0
  227. package/tools/viz/yardstick-figure.ts +197 -0
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ /**
7
+ * Options for {@linkcode matcherScale}.
8
+ */
9
+ export interface MatcherScaleOptions {
10
+ /**
11
+ * Lists the record counts to measure, defaulting to 10,000, 50,000, 100,000, 250,000 and 500,000.
12
+ */
13
+ sizes?: number[];
14
+ /**
15
+ * Sets the average number of records per distinct synthetic place, defaulting to 3.
16
+ */
17
+ dup?: number;
18
+ /**
19
+ * Fits the Fellegi-Sunter m and u probabilities with EM at each size.
20
+ *
21
+ * This is slower.
22
+ * The option defaults to `false`.
23
+ */
24
+ em?: boolean;
25
+ /**
26
+ * Gives a path where the Markdown report is also written.
27
+ */
28
+ outMd?: string;
29
+ }
30
+ /**
31
+ * Measures entity-resolution time, candidate pairs and memory on synthetic records
32
+ * of increasing size, all in one Node process.
33
+ *
34
+ * The function prints the Markdown report to stdout and returns it.
35
+ * It also writes to `outMd` when set.
36
+ */
37
+ export declare function matcherScale(options?: MatcherScaleOptions, report?: (line: string) => void): Promise<{
38
+ markdown: string;
39
+ }>;
40
+ //# sourceMappingURL=matcher-scale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matcher-scale.d.ts","sourceRoot":"","sources":["../../tools/matcher-scale.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAEhB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;;;OAKG;IACH,EAAE,CAAC,EAAE,OAAO,CAAA;IAEZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAmCD;;;;;;GAMG;AACH,wBAAsB,YAAY,CACjC,OAAO,GAAE,mBAAwB,EACjC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAsG/B"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ import { writeLocalFile } from "@mailwoman/core/fs/writers";
7
+ import { makeLcg } from "@mailwoman/core/random";
8
+ import { resolveEntities } from "#index";
9
+ function generate(n, dup, seed = 1) {
10
+ const rnd = makeLcg(seed || 1);
11
+ const places = Math.max(1, Math.round(n / dup));
12
+ const records = new Array(n);
13
+ for (let i = 0; i < n; i++) {
14
+ const place = i % places;
15
+ const latitude = 25 + rnd() * 24;
16
+ const longitude = -124 + rnd() * 57;
17
+ const variant = i < places ? "" : rnd() < 0.5 ? " llc" : " inc";
18
+ records[i] = {
19
+ id: String(i),
20
+ organization: { canonical: `org ${place}${variant}`, raw: `Org ${place}` },
21
+ address: {
22
+ components: {},
23
+ canonicalKey: `key-${place}`,
24
+ raw: `${place} main st`,
25
+ geocode: {
26
+ coordinate: { latitude: latitude + (place % 7) * 1e-4, longitude: longitude + (place % 5) * 1e-4 },
27
+ tier: "address_point",
28
+ uncertaintyMeters: 5,
29
+ },
30
+ },
31
+ };
32
+ }
33
+ return records;
34
+ }
35
+ const mb = (bytes) => `${(bytes / 1024 / 1024).toFixed(0)} MB`;
36
+ const sec = (ms) => `${(ms / 1000).toFixed(2)} s`;
37
+ /**
38
+ * Measures entity-resolution time, candidate pairs and memory on synthetic records
39
+ * of increasing size, all in one Node process.
40
+ *
41
+ * The function prints the Markdown report to stdout and returns it.
42
+ * It also writes to `outMd` when set.
43
+ */
44
+ export async function matcherScale(options = {}, report) {
45
+ const SIZES = options.sizes?.length ? options.sizes : [10_000, 50_000, 100_000, 250_000, 500_000];
46
+ const DUP = options.dup ?? 3;
47
+ const EM = options.em ?? false;
48
+ const OUT_MD = options.outMd || "";
49
+ const rows = [];
50
+ for (const n of SIZES) {
51
+ const records = generate(n, DUP);
52
+ const t0 = performance.now();
53
+ const { entities, candidatePairs } = resolveEntities(records, {
54
+ collapseSpatial: true,
55
+ trainEM: EM,
56
+ learnedScorer: false,
57
+ });
58
+ const wallMs = performance.now() - t0;
59
+ const rssBytes = process.memoryUsage().rss;
60
+ rows.push({ n, records: records.length, entities: entities.length, candidatePairs, wallMs, rssBytes });
61
+ report?.(` N=${n}: ${sec(wallMs)}, ${candidatePairs} pairs → ${entities.length} entities, RSS ${mb(rssBytes)}`);
62
+ if (globalThis.gc) {
63
+ globalThis.gc();
64
+ }
65
+ }
66
+ const lines = [
67
+ `# Matcher scale — pure-Node block → score → cluster (#K)`,
68
+ "",
69
+ `_Generated by \`registry/tools/matcher-scale.ts\`. Synthetic geo-clustered records (~${DUP} per ` +
70
+ `distinct place), resolved with the geo-first baseline (collapsed spatial${EM ? " + EM" : ""}) in one Node ` +
71
+ `process without Elasticsearch or a server. Geocoding is out of scope (measured separately); this isolates the ` +
72
+ `matcher's block/score/cluster cost vs N._`,
73
+ "",
74
+ `| records | candidate pairs | entities | wall-clock | resolve rate | RSS (high-water) |`,
75
+ `|---:|---:|---:|---:|---:|---:|`,
76
+ ];
77
+ for (const r of rows) {
78
+ const rate = Math.round(r.records / (r.wallMs / 1000));
79
+ lines.push(`| ${r.records.toLocaleString()} | ${r.candidatePairs.toLocaleString()} | ${r.entities.toLocaleString()} | ` +
80
+ `${sec(r.wallMs)} | ${rate.toLocaleString()}/s | ${mb(r.rssBytes)} |`);
81
+ }
82
+ lines.push("");
83
+ lines.push(`## Reading`);
84
+ lines.push("");
85
+ const last = rows.at(-1);
86
+ lines.push(`The matcher resolves **${last.records.toLocaleString()} records in ${sec(last.wallMs)}** in a single Node ` +
87
+ `process (block → Fellegi-Sunter → union-find clustering) without an external service. Geo-cell + canonical-key ` +
88
+ `blocking keeps candidate generation near-linear (it never enumerates the O(n²) pair space), so the wall-clock ` +
89
+ `scales with the number of *blocked* pairs, not the square of N. That is the architectural claim made ` +
90
+ `concrete: a calibrated street-level geocoder feeding the blocking lets entity resolution run in-process at ` +
91
+ `hundreds of thousands of records, where a string-similarity matcher would need a search cluster to make the ` +
92
+ `candidate generation tractable.`);
93
+ lines.push("");
94
+ lines.push(`RSS is the shared-process high-water mark across the sweep (each size reuses the heap), so it is an upper ` +
95
+ `bound, not a per-N working set. The largest size that fits is bounded by the record objects + the link array; ` +
96
+ `beyond that, extract by geography (each cell is independent) — the same partition the blocking already implies.`);
97
+ lines.push("");
98
+ lines.push(`One honest caveat on the shape: these are uniform-random US coordinates, so as N rises the geo-cell collision ` +
99
+ `rate climbs and the candidate-pair count grows faster than N (visible in the table). Real address data clusters ` +
100
+ `into a roughly fixed set of places, so its pair/record ratio is flatter — the wall-clock here, which tracks the ` +
101
+ `number of PAIRS, is a conservative upper bound on a realistic workload of the same N.`);
102
+ lines.push("");
103
+ const md = lines.join("\n");
104
+ console.log(md);
105
+ if (OUT_MD) {
106
+ await writeLocalFile(md, OUT_MD);
107
+ report?.(`[written] ${OUT_MD}`);
108
+ }
109
+ return { markdown: md };
110
+ }
111
+ //# sourceMappingURL=matcher-scale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matcher-scale.js","sourceRoot":"","sources":["../../tools/matcher-scale.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAqB,MAAM,QAAQ,CAAA;AA8B3D,SAAS,QAAQ,CAAC,CAAS,EAAE,GAAW,EAAE,IAAI,GAAG,CAAC;IACjD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAA;IAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,G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M,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAA;IAEzB,KAAK,CAAC,IAAI,CACT,0BAA0B,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,eAAe,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,sBAAsB;QAC3G,iHAAiH;QACjH,gHAAgH;QAChH,uGAAuG;QACvG,6GAA6G;QAC7G,8GAA8G;QAC9G,iCAAiC,CAClC,CAAA;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,KAAK,CAAC,IAAI,CACT,4GAA4G;QAC3G,gHAAgH;QAChH,iHAAiH,CAClH,CAAA;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,KAAK,CAAC,IAAI,CACT,gHAAgH;QAC/G,kHAAkH;QAClH,kHAAkH;QAClH,uFAAuF,CACxF,CAAA;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAE3B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEf,IAAI,MAAM,EAAE,CAAC;QACZ,MAAM,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;QAChC,MAAM,EAAE,CAAC,aAAa,MAAM,EAAE,CAAC,CAAA;IAChC,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AACxB,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Builds a varied multi-record set per NPI from real data.
7
+ * Runs the matcher without NPI values, then scores recovered clusters against the NPI grouping.
8
+ *
9
+ * Run: `mailwoman registry scorer-eval nppes-benchmark [--state TX] [--max-npis 300] [--wof <admin.db>] [--data-root <dir>] [--no-train-em] [--out-md docs/articles/evals/matcher-dedup/<date>-nppes-dedup-benchmark.md]`
10
+ */
11
+ import type { EvalGeocodeStream, EvalGeocoderFactory } from "#tools/eval-geocoder";
12
+ /**
13
+ * Options for {@linkcode nppesDedupBenchmark}.
14
+ */
15
+ export interface NPPESDedupBenchmarkOptions {
16
+ /**
17
+ * The injected geocoder factory, wired by the command to `mailwoman/geocode-core`; model-swap
18
+ * overrides (`--model`/`--tokenizer`/`--model-card`) are its factory config rather than tool options.
19
+ */
20
+ createGeocoder: EvalGeocoderFactory;
21
+ /**
22
+ * The threaded geocode surface — required when {@linkcode parallelGeocode} is set.
23
+ */
24
+ geocodeStream?: EvalGeocodeStream;
25
+ /**
26
+ * Record-matcher sources directory, defaulting to `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
27
+ */
28
+ sources?: string;
29
+ /**
30
+ * State filter, default TX.
31
+ */
32
+ state?: string;
33
+ /**
34
+ * NPIs sampled, default 300.
35
+ */
36
+ maxNpis?: number;
37
+ /**
38
+ * EM-train the FS arms (label-free), default true; `--no-train-em` uses the seeds.
39
+ */
40
+ trainEm?: boolean;
41
+ /**
42
+ * Reproduce the pre-flip ingest (space-joined address columns with case normalization off),
43
+ * so that with the same data and GBT only the flip is toggled.
44
+ *
45
+ * @defaultValue `false`
46
+ */
47
+ legacyJoin?: boolean;
48
+ /**
49
+ * Optional A/B: a path to a trained dedup-gbt TS module exporting DEDUP_GBT_MODEL +
50
+ * DEDUP_GBT_META, scored alongside the shipped GBT at both truth levels.
51
+ */
52
+ candidate?: string;
53
+ /**
54
+ * Write the gold-set adjudication packet of org-name-grain over-merged clusters here.
55
+ */
56
+ dumpOvermerges?: string;
57
+ /**
58
+ * H3 resolution for the org-name-h3 truth grain, default 11 (≈25 m edge).
59
+ */
60
+ h3Res?: number;
61
+ /**
62
+ * Geocode the sample through a worker pool with {@linkcode geocodeStream}.
63
+ *
64
+ * The worker pool parallelizes the per-row ONNX parse and WOF SQLite work while preserving coordinates.
65
+ */
66
+ parallelGeocode?: boolean;
67
+ /**
68
+ * Worker-pool concurrency for {@linkcode parallelGeocode}, default 2 (geocode is I/O-bound).
69
+ */
70
+ geoConcurrency?: number;
71
+ /**
72
+ * Also write the markdown report here.
73
+ */
74
+ outMd?: string;
75
+ }
76
+ /**
77
+ * The NPPES dedup benchmark (see the module doc), emitting the markdown report to stdout.
78
+ */
79
+ export declare function nppesDedupBenchmark(options: NPPESDedupBenchmarkOptions, report?: (line: string) => void): Promise<{
80
+ markdown: string;
81
+ }>;
82
+ //# sourceMappingURL=dedup-benchmark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedup-benchmark.d.ts","sourceRoot":"","sources":["../../../tools/nppes/dedup-benchmark.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgBH,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAelF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;OAGG;IACH,cAAc,EAAE,mBAAmB,CAAA;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,iBAAiB,CAAA;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,0BAA0B,EACnC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA4P/B"}
@@ -0,0 +1,226 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Builds a varied multi-record set per NPI from real data.
7
+ * Runs the matcher without NPI values, then scores recovered clusters against the NPI grouping.
8
+ *
9
+ * Run: `mailwoman registry scorer-eval nppes-benchmark [--state TX] [--max-npis 300] [--wof <admin.db>] [--data-root <dir>] [--no-train-em] [--out-md docs/articles/evals/matcher-dedup/<date>-nppes-dedup-benchmark.md]`
10
+ */
11
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
12
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
13
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
14
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
15
+ });
16
+ }
17
+ return path;
18
+ };
19
+ import { dataRootPath } from "@mailwoman/core/data-root";
20
+ import { writeLocalFile } from "@mailwoman/core/fs/writers";
21
+ import { pathToFileURL } from "@mailwoman/core/module/file-url";
22
+ import { resolvePath } from "path-ts";
23
+ import { ingestRows, resolveEntities, } from "#index";
24
+ import { writeOvermergePacket } from "#tools/nppes/overmerge-packet";
25
+ import { renderNPPESDedupReport } from "#tools/nppes/report";
26
+ import { buildNPPESSample } from "#tools/nppes/sample";
27
+ import { scoreEntities } from "#tools/nppes/scoring";
28
+ import { buildSettings } from "#tools/nppes/settings";
29
+ import { buildOrgNameCoordGrain, buildOrgNameGrain, buildOrgNameH3Grain, collectPrimaryCoordinates, } from "#tools/nppes/truth-grains";
30
+ import { stateOption } from "#tools/shared";
31
+ /**
32
+ * The NPPES dedup benchmark (see the module doc), emitting the markdown report to stdout.
33
+ */
34
+ export async function nppesDedupBenchmark(options, report) {
35
+ const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
36
+ const STATE = stateOption(options);
37
+ const MAX_NPIS = options.maxNpis ?? 300;
38
+ const OUT_MD = options.outMd || "";
39
+ const TRAIN_EM = options.trainEm ?? true;
40
+ const LEGACY = options.legacyJoin ?? false;
41
+ const CANDIDATE = options.candidate || "";
42
+ const PARALLEL_GEOCODE = options.parallelGeocode ?? false;
43
+ const GEO_CONC = options.geoConcurrency ?? 2;
44
+ const { rows, keptNpis, npiPrimary, addressFrequency } = await buildNPPESSample({
45
+ registryPath: `${SOURCES}/nppes_npi-registry_20260607.tsv`,
46
+ otherNamesPath: `${SOURCES}/nppes_other-names_20260607.tsv`,
47
+ state: STATE,
48
+ maxNpis: MAX_NPIS,
49
+ }, report);
50
+ // Without `modelCardPath`, a STAGE3 model silently mis-decodes into empty parses when `modelPath` is set.
51
+ report?.("[C] building the geocoder + geocoding records…");
52
+ const mapping = {
53
+ id: "npi",
54
+ name: "name",
55
+ organization: "org",
56
+ address: "address",
57
+ // `entityTruth` appears as an attribute purely for scoring, never as a discriminator
58
+ // in matching, carrying the site-level label alongside the NPI.
59
+ attributes: { authorizedOfficial: "auth", taxonomy: "taxonomy", entityTruth: "entityID" },
60
+ source: "nppes",
61
+ };
62
+ let geo = 0;
63
+ let records;
64
+ if (PARALLEL_GEOCODE) {
65
+ // `address` is a single pre-joined column on this path, so `--legacy-join` is a no-op
66
+ // and case normalization follows the worker default (`"title-case"`).
67
+ if (!options.geocodeStream) {
68
+ throw new Error("parallelGeocode requires the injected geocodeStream (see ./eval-geocoder.ts)");
69
+ }
70
+ const normalized = await ingestRows(rows, mapping);
71
+ const order = new Map(normalized.map((r, i) => [r.id, i]));
72
+ const geocoded = [];
73
+ for await (const rec of options.geocodeStream(normalized, { mapping, concurrency: GEO_CONC })) {
74
+ geocoded.push(rec);
75
+ if (rec.address?.geocode) {
76
+ geo++;
77
+ }
78
+ }
79
+ // Restore input order because `geocodeStream` yields in completion order
80
+ // and downstream cluster tie-breaks must be byte-stable.
81
+ geocoded.sort((a, b) => (order.get(a.id) ?? 0) - (order.get(b.id) ?? 0));
82
+ records = geocoded;
83
+ }
84
+ else {
85
+ const geocoder = await options.createGeocoder({ caseNormalization: LEGACY ? "preserve" : "title-case" });
86
+ const countedGeocodeForIngest = async (raw) => {
87
+ const g = await geocoder.geocodeAddress(raw);
88
+ if (g?.geocode) {
89
+ geo++;
90
+ }
91
+ return g;
92
+ };
93
+ records = await ingestRows(rows, mapping, {
94
+ geocodeAddress: countedGeocodeForIngest,
95
+ addressSeparator: LEGACY ? " " : ", ",
96
+ });
97
+ geocoder[Symbol.dispose]();
98
+ }
99
+ report?.(` geocoded ${geo}/${rows.length} (${((100 * geo) / rows.length).toFixed(1)}%)`);
100
+ const N = records.length;
101
+ // Every grain scores against the same record population, so the ARI expectation is fixed for the run.
102
+ const score = (entities, labelOf) => scoreEntities(entities, labelOf, N);
103
+ // A score for the same clusters at NPI and entity level isolates how much of the
104
+ // apparent over-merge is NPI over-segmentation rather than model error.
105
+ const npiLabel = (rec) => rec.id;
106
+ const entityLabel = (rec) => rec.attributes?.["entityTruth"] ?? rec.id;
107
+ const orgNameLabel = buildOrgNameGrain(npiPrimary);
108
+ const npiCoord = collectPrimaryCoordinates(records);
109
+ const orgNameCoordLabel = buildOrgNameCoordGrain(npiPrimary, npiCoord);
110
+ const geocodedNpis = [...npiPrimary.keys()].filter((n) => npiCoord.has(n)).length;
111
+ const H3_RES = options.h3Res ?? 11; // res 11 ≈ 25 m edge. res 10 ≈ 65 m (block scale)
112
+ const orgNameH3Label = buildOrgNameH3Grain(npiPrimary, npiCoord, H3_RES);
113
+ report?.(`[D] resolving the setting progression${TRAIN_EM ? " (EM-trained)" : ""}…`);
114
+ // The learned scorer is default-on, so it is pinned off here.
115
+ // Otherwise every row would silently be the GBT.
116
+ const progression = buildSettings(addressFrequency).map((l) => {
117
+ const res = resolveEntities(records, { learnedScorer: false, trainEM: TRAIN_EM, threshold: 0, ...l.config });
118
+ return { ...l, res, score: score(res.entities, npiLabel) };
119
+ });
120
+ const bestSetting = progression.at(-1); // the full setting stack
121
+ // The shipped out-of-box default auto-computes an input-scoped address-frequency table.
122
+ // on this sub-sampled corpus it is sparse and F1 collapses to ≈baseline, because IDF is a
123
+ // corpus statistic, so the CLI passes a corpus-wide table built from the full source files.
124
+ const defaultRes = resolveEntities(records, { learnedScorer: false, trainEM: TRAIN_EM, threshold: 0 });
125
+ const defaultOutOfBox = score(defaultRes.entities, npiLabel);
126
+ const THRESHOLDS = [0, 4, 8, 12, 16, 20];
127
+ const sweep = THRESHOLDS.map((t) => {
128
+ const res = resolveEntities(records, {
129
+ learnedScorer: false,
130
+ trainEM: TRAIN_EM,
131
+ threshold: t,
132
+ ...bestSetting.config,
133
+ });
134
+ return { t, res, score: score(res.entities, npiLabel) };
135
+ });
136
+ const base = sweep[0]; // threshold 0, full setting stack
137
+ let best = sweep[0];
138
+ for (const arm of sweep) {
139
+ if (arm.score.f1 > best.score.f1) {
140
+ best = arm;
141
+ }
142
+ }
143
+ report?.(` progression @ threshold 0: ${progression.map((p) => `${(100 * p.score.f1).toFixed(1)}%`).join(" → ")} F1`);
144
+ report?.(` default F1 ${(100 * base.score.f1).toFixed(1)}% → best F1 ${(100 * best.score.f1).toFixed(1)}% @ threshold ${best.t}`);
145
+ const entityCount = new Set(records.map((r) => entityLabel(r))).size;
146
+ const orgCount = new Set(records.map((r) => orgNameLabel(r))).size;
147
+ const fsNPI = bestSetting.score;
148
+ const fsEntity = score(bestSetting.res.entities, entityLabel);
149
+ const fsOrg = score(bestSetting.res.entities, orgNameLabel);
150
+ const gbtRes = resolveEntities(records, { addressFrequency, trainEM: TRAIN_EM }); // GBT default-on (production)
151
+ const gbtNPI = score(gbtRes.entities, npiLabel);
152
+ const gbtEntity = score(gbtRes.entities, entityLabel);
153
+ const gbtOrg = score(gbtRes.entities, orgNameLabel);
154
+ const orgCoordCount = new Set(records.map((r) => orgNameCoordLabel(r))).size;
155
+ const fsOrgCoord = score(bestSetting.res.entities, orgNameCoordLabel);
156
+ const gbtOrgCoord = score(gbtRes.entities, orgNameCoordLabel);
157
+ const orgH3Count = new Set(records.map((r) => orgNameH3Label(r))).size;
158
+ const gbtOrgH3 = score(gbtRes.entities, orgNameH3Label);
159
+ const DUMP_OVERMERGES = options.dumpOvermerges || "";
160
+ if (DUMP_OVERMERGES) {
161
+ const clusters = await writeOvermergePacket(DUMP_OVERMERGES, {
162
+ state: STATE,
163
+ entities: gbtRes.entities,
164
+ rows,
165
+ recordCount: records.length,
166
+ maxNpis: MAX_NPIS,
167
+ orgNameLabel,
168
+ });
169
+ report?.(` adjudication packet: ${clusters} over-merged clusters -> ${DUMP_OVERMERGES}`);
170
+ }
171
+ let cand = null;
172
+ if (CANDIDATE) {
173
+ const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(resolvePath(CANDIDATE)).href)));
174
+ const t = mod.DEDUP_GBT_META?.recommendedThreshold ?? 0;
175
+ const res = resolveEntities(records, {
176
+ addressFrequency,
177
+ trainEM: TRAIN_EM,
178
+ learnedScorer: mod.DEDUP_GBT_MODEL,
179
+ threshold: t,
180
+ });
181
+ const cost = mod.DEDUP_GBT_META?.costNegative ?? 1;
182
+ cand = {
183
+ label: `GBT candidate (${mod.DEDUP_GBT_META?.features ?? "?"}-feat${cost !== 1 ? `, cost ×${cost}` : ""})`,
184
+ npi: score(res.entities, npiLabel),
185
+ entity: score(res.entities, entityLabel),
186
+ };
187
+ report?.(` candidate ${CANDIDATE}: NPI ${(100 * cand.npi.f1).toFixed(1)}% / entity ${(100 * cand.entity.f1).toFixed(1)}%`);
188
+ }
189
+ report?.(` truth-grains — GBT NPI ${(100 * gbtNPI.f1).toFixed(1)}% → site ${(100 * gbtEntity.f1).toFixed(1)}% → org-name ${(100 * gbtOrg.f1).toFixed(1)}% → org-name-coord ${(100 * gbtOrgCoord.f1).toFixed(1)}% → org-name-h3 ${(100 * gbtOrgH3.f1).toFixed(1)}% (res ${H3_RES}); ` +
190
+ `FS: NPI ${(100 * fsNPI.f1).toFixed(1)}% / entity ${(100 * fsEntity.f1).toFixed(1)}% / org-coord ${(100 * fsOrgCoord.f1).toFixed(1)}%`);
191
+ const md = renderNPPESDedupReport({
192
+ state: STATE,
193
+ keptNpis: keptNpis.size,
194
+ recordCount: N,
195
+ geocoded: geo,
196
+ trainEM: TRAIN_EM,
197
+ addressFrequency,
198
+ progression,
199
+ defaultOutOfBox,
200
+ sweep,
201
+ best,
202
+ entityCount,
203
+ orgCount,
204
+ orgCoordCount,
205
+ orgH3Count,
206
+ fsNPI,
207
+ fsEntity,
208
+ fsOrg,
209
+ fsOrgCoord,
210
+ gbtNPI,
211
+ gbtEntity,
212
+ gbtOrg,
213
+ gbtOrgCoord,
214
+ gbtOrgH3,
215
+ candidate: cand,
216
+ h3Res: H3_RES,
217
+ geocodedNpis,
218
+ });
219
+ console.log(md);
220
+ if (OUT_MD) {
221
+ await writeLocalFile(md, OUT_MD);
222
+ report?.(`\n[written] ${OUT_MD}`);
223
+ }
224
+ return { markdown: md };
225
+ }
226
+ //# sourceMappingURL=dedup-benchmark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedup-benchmark.js","sourceRoot":"","sources":["../../../tools/nppes/dedup-benchmark.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;;;;;;;;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,EACN,UAAU,EACV,eAAe,GAKf,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAE,oBAAoB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}
@@ -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 declare const ORG_TAU = 0.7;
6
+ /**
7
+ * An NPI's primary registry identity: the org-name token set plus the address key of its practice location.
8
+ *
9
+ * Every grain of the org-name truth blocks on a location and filters on the tokens.
10
+ */
11
+ export interface NPIPrimary {
12
+ tokens: Set<string>;
13
+ addrKey: string;
14
+ }
15
+ //# sourceMappingURL=org-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-name.d.ts","sourceRoot":"","sources":["../../../tools/nppes/org-name.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,OAAO,MAAM,CAAA;AAE1B;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,6 @@
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
+ //# sourceMappingURL=org-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-name.js","sourceRoot":"","sources":["../../../tools/nppes/org-name.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Writes the over-merged NPPES clusters with every matcher-visible field for human adjudication.
6
+ */
7
+ import type { PathBuilderLike } from "path-ts";
8
+ import type { ResolvedEntity } from "#index";
9
+ import type { MessyRow } from "#tools/nppes/sample";
10
+ import type { TruthLabel } from "#tools/nppes/truth-grains";
11
+ /**
12
+ * The inputs to {@link writeOvermergePacket}.
13
+ */
14
+ export interface OvermergePacketInput {
15
+ /**
16
+ * The clusters to inspect.
17
+ * Callers pass the clusters from the shipped matcher config.
18
+ */
19
+ entities: readonly ResolvedEntity[];
20
+ /**
21
+ * The source rows.
22
+ *
23
+ * The packet reads the authorized official and taxonomy from them.
24
+ */
25
+ rows: readonly MessyRow[];
26
+ recordCount: number;
27
+ maxNpis: number;
28
+ /**
29
+ * The state that the sample was drawn from.
30
+ * The packet header prints it.
31
+ */
32
+ state: string;
33
+ orgNameLabel: TruthLabel;
34
+ }
35
+ /**
36
+ * Writes the adjudication packet and returns the number of over-merged clusters in it.
37
+ *
38
+ * A cluster is over-merged when its members have more than one org-name truth label.
39
+ * A reviewer marks each cluster as one real entity or as distinct providers.
40
+ * which separates model error from truth-label error.
41
+ */
42
+ export declare function writeOvermergePacket(path: PathBuilderLike, input: OvermergePacketInput): Promise<number>;
43
+ //# sourceMappingURL=overmerge-packet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overmerge-packet.d.ts","sourceRoot":"","sources":["../../../tools/nppes/overmerge-packet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,QAAQ,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAE3D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAA;IACnC;;;;OAIG;IACH,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,UAAU,CAAA;CACxB;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkD9G"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Writes the over-merged NPPES clusters with every matcher-visible field for human adjudication.
6
+ */
7
+ import { writeLocalTextFile } from "@mailwoman/core/fs/writers";
8
+ import { formatPersonName } from "@mailwoman/record/name";
9
+ /**
10
+ * Writes the adjudication packet and returns the number of over-merged clusters in it.
11
+ *
12
+ * A cluster is over-merged when its members have more than one org-name truth label.
13
+ * A reviewer marks each cluster as one real entity or as distinct providers.
14
+ * which separates model error from truth-label error.
15
+ */
16
+ export async function writeOvermergePacket(path, input) {
17
+ const { entities, rows, recordCount, maxNpis, state, orgNameLabel } = input;
18
+ const rowByID = new Map(rows.map((r) => [r.npi, r]));
19
+ const out = [
20
+ "# #625 gold-set adjudication packet — org-name-grain over-merged clusters (GBT, shipped config)",
21
+ "",
22
+ `${state} --max-npis ${maxNpis} · ${recordCount} records · generated by \`registry scorer-eval nppes-benchmark --dump-overmerges\``,
23
+ "",
24
+ "For each cluster: the matcher fused records that the org-name truth says belong to DIFFERENT entities.",
25
+ "Adjudicate each: **[same]** one real-world entity (yardstick error — the truth under-collapsed) or",
26
+ "**[distinct]** genuinely different co-located providers (model over-merge). Mark inline and return.",
27
+ "",
28
+ ];
29
+ let n = 0;
30
+ entities.forEach((e) => {
31
+ const byLabel = new Map();
32
+ for (const rec of e.records) {
33
+ const lbl = orgNameLabel(rec);
34
+ const list = byLabel.get(lbl) ?? [];
35
+ list.push(rec);
36
+ byLabel.set(lbl, list);
37
+ }
38
+ if (byLabel.size <= 1)
39
+ return;
40
+ n++;
41
+ out.push(`## Cluster ${n} — ${e.records.length} records, ${byLabel.size} org-name entities → verdict: [ ]`);
42
+ for (const [lbl, members] of byLabel) {
43
+ out.push(`- **entity ${lbl}**`);
44
+ for (const rec of members) {
45
+ const src = rowByID.get(rec.id);
46
+ out.push(` - npi=${rec.id} · name="${formatPersonName(rec.name ?? null, "short")}" · org="${rec.organization?.canonical ?? ""}" · addr="${rec.address?.raw ?? ""}" · auth="${src?.auth ?? ""}" · taxonomy="${src?.taxonomy ?? ""}"`);
47
+ }
48
+ }
49
+ out.push("");
50
+ });
51
+ await writeLocalTextFile(out.join("\n"), path);
52
+ return n;
53
+ }
54
+ //# sourceMappingURL=overmerge-packet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overmerge-packet.js","sourceRoot":"","sources":["../../../tools/nppes/overmerge-packet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAgCzD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAqB,EAAE,KAA2B;IAC5F,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,KAAK,CAAA;IAC3E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAEpD,MAAM,GAAG,GAAa;QACrB,iGAAiG;QACjG,EAAE;QACF,GAAG,KAAK,eAAe,OAAO,MAAM,WAAW,oFAAoF;QACnI,EAAE;QACF,wGAAwG;QACxG,oGAAoG;QACpG,qGAAqG;QACrG,EAAE;KACF,CAAA;IAED,IAAI,CAAC,GAAG,CAAC,CAAA;IAET,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACtB,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAA;QAEjD,KAAK,MAAM,GAAG,IAAI,CA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