@mailwoman/registry 9.2.0 → 9.4.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 +1 -1
  2. package/{address-key.ts → lib/address-key.ts} +1 -1
  3. package/{geocode-handler.ts → lib/geocode-handler.ts} +7 -7
  4. package/{geojson.ts → lib/geojson.ts} +9 -4
  5. package/{index.ts → lib/index.ts} +10 -10
  6. package/{ingest.ts → lib/ingest.ts} +75 -68
  7. package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
  8. package/{map-html.ts → lib/map-html.ts} +7 -13
  9. package/{reconcile.ts → lib/reconcile.ts} +7 -23
  10. package/{resolve.ts → lib/resolve.ts} +25 -12
  11. package/{tools → lib/tools}/coverage-reconciliation.ts +12 -14
  12. package/{tools → lib/tools}/cross-dataset-correlation.ts +60 -137
  13. package/{tools → lib/tools}/cross-source-threshold-sweep.ts +20 -31
  14. package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
  15. package/{tools → lib/tools}/eval-geocoder.ts +9 -10
  16. package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
  17. package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +9 -10
  18. package/lib/tools/gold-set-sample.ts +141 -0
  19. package/lib/tools/index.ts +31 -0
  20. package/{tools → lib/tools}/learned-scorer-clustering-eval.ts +68 -257
  21. package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +60 -243
  22. package/{tools → lib/tools}/learned-scorer-eval.ts +63 -257
  23. package/{tools → lib/tools}/matcher-scale.ts +4 -5
  24. package/lib/tools/nppes/org-name.ts +23 -0
  25. package/{tools → lib/tools}/nppes/overmerge-packet.ts +5 -7
  26. package/{tools → lib/tools}/nppes/report.ts +22 -25
  27. package/{tools → lib/tools}/nppes/sample.ts +80 -32
  28. package/{tools/nppes/levers.ts → lib/tools/nppes/settings.ts} +10 -10
  29. package/{tools → lib/tools}/nppes/truth-grains.ts +4 -44
  30. package/{tools → lib/tools}/nppes-dedup-benchmark.ts +42 -38
  31. package/lib/tools/shared.ts +761 -0
  32. package/lib/tools/train-cross-gbt.ts +209 -0
  33. package/{tools → lib/tools}/train-gbt.ts +35 -154
  34. package/lib/tools/train-org-cross-gbt.ts +179 -0
  35. package/{tools → lib/tools}/txhhsc-to-oarow.ts +9 -27
  36. package/lib/tools/viz/browser.ts +50 -0
  37. package/{tools → lib/tools}/viz/cross-dataset-map.ts +7 -8
  38. package/{tools → lib/tools}/viz/geocode-first-surface.ts +10 -8
  39. package/{tools → lib/tools}/viz/render-map.ts +10 -23
  40. package/lib/tools/viz/render.ts +98 -0
  41. package/{tools → lib/tools}/viz/source-provenance-map.ts +8 -10
  42. package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
  43. package/out/address-key.d.ts +1 -1
  44. package/out/address-key.d.ts.map +1 -1
  45. package/out/address-key.js.map +1 -1
  46. package/out/geocode-handler.d.ts +6 -6
  47. package/out/geocode-handler.d.ts.map +1 -1
  48. package/out/geocode-handler.js +6 -6
  49. package/out/geocode-handler.js.map +1 -1
  50. package/out/geojson.d.ts +7 -2
  51. package/out/geojson.d.ts.map +1 -1
  52. package/out/geojson.js +5 -3
  53. package/out/geojson.js.map +1 -1
  54. package/out/index.d.ts +10 -10
  55. package/out/index.d.ts.map +1 -1
  56. package/out/index.js +10 -10
  57. package/out/index.js.map +1 -1
  58. package/out/ingest.d.ts +64 -46
  59. package/out/ingest.d.ts.map +1 -1
  60. package/out/ingest.js +31 -45
  61. package/out/ingest.js.map +1 -1
  62. package/out/learned-scorer.d.ts +1 -1
  63. package/out/learned-scorer.d.ts.map +1 -1
  64. package/out/learned-scorer.js.map +1 -1
  65. package/out/map-html.d.ts +3 -3
  66. package/out/map-html.d.ts.map +1 -1
  67. package/out/map-html.js +6 -11
  68. package/out/map-html.js.map +1 -1
  69. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
  70. package/out/models/crosssource-gbt-en-us.js.map +1 -1
  71. package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
  72. package/out/models/dedup-gbt-en-us.js.map +1 -1
  73. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
  74. package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
  75. package/out/reconcile.d.ts +6 -1
  76. package/out/reconcile.d.ts.map +1 -1
  77. package/out/reconcile.js +5 -20
  78. package/out/reconcile.js.map +1 -1
  79. package/out/resolve.d.ts +19 -7
  80. package/out/resolve.d.ts.map +1 -1
  81. package/out/resolve.js +16 -5
  82. package/out/resolve.js.map +1 -1
  83. package/out/tools/coverage-reconciliation.d.ts +1 -1
  84. package/out/tools/coverage-reconciliation.d.ts.map +1 -1
  85. package/out/tools/coverage-reconciliation.js +11 -11
  86. package/out/tools/coverage-reconciliation.js.map +1 -1
  87. package/out/tools/cross-dataset-correlation.d.ts +4 -4
  88. package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
  89. package/out/tools/cross-dataset-correlation.js +57 -109
  90. package/out/tools/cross-dataset-correlation.js.map +1 -1
  91. package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
  92. package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
  93. package/out/tools/cross-source-threshold-sweep.js +19 -27
  94. package/out/tools/cross-source-threshold-sweep.js.map +1 -1
  95. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  96. package/out/tools/dedup-ceiling.js +36 -117
  97. package/out/tools/dedup-ceiling.js.map +1 -1
  98. package/out/tools/eval-geocoder.d.ts +8 -12
  99. package/out/tools/eval-geocoder.d.ts.map +1 -1
  100. package/out/tools/eval-geocoder.js +2 -2
  101. package/out/tools/eval-geocoder.js.map +1 -1
  102. package/out/tools/geocoder-namesake-probe.d.ts +2 -2
  103. package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
  104. package/out/tools/geocoder-namesake-probe.js +4 -8
  105. package/out/tools/geocoder-namesake-probe.js.map +1 -1
  106. package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
  107. package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
  108. package/out/tools/geocoder-vs-provided-coords.js +8 -7
  109. package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
  110. package/out/tools/gold-set-sample.d.ts +5 -5
  111. package/out/tools/gold-set-sample.d.ts.map +1 -1
  112. package/out/tools/gold-set-sample.js +37 -122
  113. package/out/tools/gold-set-sample.js.map +1 -1
  114. package/out/tools/index.d.ts +23 -23
  115. package/out/tools/index.d.ts.map +1 -1
  116. package/out/tools/index.js +23 -23
  117. package/out/tools/index.js.map +1 -1
  118. package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
  119. package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
  120. package/out/tools/learned-scorer-clustering-eval.js +36 -169
  121. package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
  122. package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
  123. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
  124. package/out/tools/learned-scorer-crossstate-eval.js +44 -166
  125. package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
  126. package/out/tools/learned-scorer-eval.d.ts +1 -1
  127. package/out/tools/learned-scorer-eval.d.ts.map +1 -1
  128. package/out/tools/learned-scorer-eval.js +38 -168
  129. package/out/tools/learned-scorer-eval.js.map +1 -1
  130. package/out/tools/matcher-scale.d.ts.map +1 -1
  131. package/out/tools/matcher-scale.js +4 -4
  132. package/out/tools/matcher-scale.js.map +1 -1
  133. package/out/tools/nppes/org-name.d.ts +2 -5
  134. package/out/tools/nppes/org-name.d.ts.map +1 -1
  135. package/out/tools/nppes/org-name.js +1 -30
  136. package/out/tools/nppes/org-name.js.map +1 -1
  137. package/out/tools/nppes/overmerge-packet.d.ts +3 -3
  138. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
  139. package/out/tools/nppes/overmerge-packet.js +3 -3
  140. package/out/tools/nppes/overmerge-packet.js.map +1 -1
  141. package/out/tools/nppes/report.d.ts +5 -5
  142. package/out/tools/nppes/report.d.ts.map +1 -1
  143. package/out/tools/nppes/report.js +17 -19
  144. package/out/tools/nppes/report.js.map +1 -1
  145. package/out/tools/nppes/sample.d.ts +32 -6
  146. package/out/tools/nppes/sample.d.ts.map +1 -1
  147. package/out/tools/nppes/sample.js +44 -26
  148. package/out/tools/nppes/sample.js.map +1 -1
  149. package/out/tools/nppes/scoring.d.ts.map +1 -1
  150. package/out/tools/nppes/scoring.js.map +1 -1
  151. package/out/tools/nppes/{levers.d.ts → settings.d.ts} +8 -8
  152. package/out/tools/nppes/settings.d.ts.map +1 -0
  153. package/out/tools/nppes/{levers.js → settings.js} +8 -8
  154. package/out/tools/nppes/settings.js.map +1 -0
  155. package/out/tools/nppes/truth-grains.d.ts +2 -2
  156. package/out/tools/nppes/truth-grains.d.ts.map +1 -1
  157. package/out/tools/nppes/truth-grains.js +4 -29
  158. package/out/tools/nppes/truth-grains.js.map +1 -1
  159. package/out/tools/nppes-dedup-benchmark.d.ts +4 -4
  160. package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
  161. package/out/tools/nppes-dedup-benchmark.js +40 -34
  162. package/out/tools/nppes-dedup-benchmark.js.map +1 -1
  163. package/out/tools/shared.d.ts +243 -7
  164. package/out/tools/shared.d.ts.map +1 -1
  165. package/out/tools/shared.js +348 -18
  166. package/out/tools/shared.js.map +1 -1
  167. package/out/tools/train-cross-gbt.d.ts +7 -7
  168. package/out/tools/train-cross-gbt.d.ts.map +1 -1
  169. package/out/tools/train-cross-gbt.js +47 -145
  170. package/out/tools/train-cross-gbt.js.map +1 -1
  171. package/out/tools/train-gbt.d.ts +7 -7
  172. package/out/tools/train-gbt.d.ts.map +1 -1
  173. package/out/tools/train-gbt.js +31 -111
  174. package/out/tools/train-gbt.js.map +1 -1
  175. package/out/tools/train-org-cross-gbt.d.ts +7 -5
  176. package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
  177. package/out/tools/train-org-cross-gbt.js +45 -141
  178. package/out/tools/train-org-cross-gbt.js.map +1 -1
  179. package/out/tools/txhhsc-to-oarow.d.ts +2 -2
  180. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  181. package/out/tools/txhhsc-to-oarow.js +8 -22
  182. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  183. package/out/tools/viz/browser.d.ts +34 -0
  184. package/out/tools/viz/browser.d.ts.map +1 -0
  185. package/out/tools/viz/browser.js +33 -0
  186. package/out/tools/viz/browser.js.map +1 -0
  187. package/out/tools/viz/cross-dataset-map.d.ts +2 -2
  188. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  189. package/out/tools/viz/cross-dataset-map.js +6 -6
  190. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  191. package/out/tools/viz/geocode-first-surface.d.ts +4 -3
  192. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  193. package/out/tools/viz/geocode-first-surface.js +7 -5
  194. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  195. package/out/tools/viz/render-map.d.ts +3 -6
  196. package/out/tools/viz/render-map.d.ts.map +1 -1
  197. package/out/tools/viz/render-map.js +9 -19
  198. package/out/tools/viz/render-map.js.map +1 -1
  199. package/out/tools/viz/render.d.ts +4 -9
  200. package/out/tools/viz/render.d.ts.map +1 -1
  201. package/out/tools/viz/render.js +24 -39
  202. package/out/tools/viz/render.js.map +1 -1
  203. package/out/tools/viz/source-provenance-map.d.ts +2 -2
  204. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  205. package/out/tools/viz/source-provenance-map.js +6 -7
  206. package/out/tools/viz/source-provenance-map.js.map +1 -1
  207. package/out/tools/viz/yardstick-figure.d.ts +2 -2
  208. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  209. package/out/tools/viz/yardstick-figure.js +5 -4
  210. package/out/tools/viz/yardstick-figure.js.map +1 -1
  211. package/out/types.d.ts.map +1 -1
  212. package/out/types.js.map +1 -1
  213. package/package.json +115 -15
  214. package/out/tools/nppes/levers.d.ts.map +0 -1
  215. package/out/tools/nppes/levers.js.map +0 -1
  216. package/tools/gold-set-sample.ts +0 -254
  217. package/tools/index.ts +0 -31
  218. package/tools/nppes/org-name.ts +0 -56
  219. package/tools/shared.ts +0 -162
  220. package/tools/train-cross-gbt.ts +0 -359
  221. package/tools/train-org-cross-gbt.ts +0 -330
  222. package/tools/viz/render.ts +0 -113
  223. /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
  224. /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
  225. /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
  226. /package/{tools → lib/tools}/nppes/scoring.ts +0 -0
  227. /package/{types.ts → lib/types.ts} +0 -0
@@ -17,11 +17,11 @@
17
17
  * NPI split across two genuinely-distant addresses is geo-first behaving correctly, counted here
18
18
  * as a recall miss. We resolve and report; interpretation is the consumer's.
19
19
  *
20
- * Sample: a tractable, variation-rich cut — providers in one state (default TX) that have ≥1
20
+ * Sample: a tractable, variation-rich slice — providers in one state (default TX) that have ≥1
21
21
  * alternate name, so every entity has ≥2 records and the dedup is non-trivial. Streams the 4.8 GB
22
22
  * registry via `streamRows` (#616), so nothing loads whole.
23
23
  *
24
- * The stages live in `./nppes/`: the sample, the scorer, the truth grains, the lever progression,
24
+ * The stages live in `./nppes/`: the sample, the scorer, the truth grains, the setting progression,
25
25
  * the adjudication packet, and the report. This file is the orchestration — read it for the order
26
26
  * of operations, the modules for what each stage does.
27
27
  *
@@ -30,12 +30,11 @@
30
30
  * [--out-md docs/articles/evals/matcher-dedup/<date>-nppes-dedup-benchmark.md]`
31
31
  */
32
32
 
33
- import { writeFileSync } from "node:fs"
34
- import { resolve as resolvePath } from "node:path"
35
- import { pathToFileURL } from "node:url"
36
-
37
- import { dataRootPath } from "@mailwoman/core/utils"
33
+ import { dataRootPath } from "@mailwoman/core/data-root"
34
+ import { writeLocalFile } from "@mailwoman/core/fs/writers"
35
+ import { pathToFileURL } from "@mailwoman/core/module/file-url"
38
36
  import type { GBT } from "@mailwoman/match"
37
+ import { resolvePath } from "path-ts"
39
38
 
40
39
  import {
41
40
  ingestRows,
@@ -45,20 +44,20 @@ import {
45
44
  type ResolvedEntity,
46
45
  type SourceRecord,
47
46
  } from "#index"
48
-
49
- import type { EvalGeocodeStream, EvalGeocoderFactory } from "./eval-geocoder.ts"
50
- import { buildLevers } from "./nppes/levers.ts"
51
- import { writeOvermergePacket } from "./nppes/overmerge-packet.ts"
52
- import { renderNPPESDedupReport, type SweepArm } from "./nppes/report.ts"
53
- import { buildNPPESSample } from "./nppes/sample.ts"
54
- import { scoreEntities, type Score } from "./nppes/scoring.ts"
47
+ import type { EvalGeocodeStream, EvalGeocoderFactory } from "#tools/eval-geocoder"
48
+ import { writeOvermergePacket } from "#tools/nppes/overmerge-packet"
49
+ import { renderNPPESDedupReport, type SweepArm } from "#tools/nppes/report"
50
+ import { buildNPPESSample } from "#tools/nppes/sample"
51
+ import { scoreEntities, type Score } from "#tools/nppes/scoring"
52
+ import { buildSettings } from "#tools/nppes/settings"
55
53
  import {
56
54
  buildOrgNameCoordGrain,
57
55
  buildOrgNameGrain,
58
56
  buildOrgNameH3Grain,
59
57
  collectPrimaryCoordinates,
60
58
  type TruthLabel,
61
- } from "./nppes/truth-grains.ts"
59
+ } from "#tools/nppes/truth-grains"
60
+ import { stateOption } from "#tools/shared"
62
61
 
63
62
  /**
64
63
  * Options for {@linkcode nppesDedupBenchmark}.
@@ -109,7 +108,7 @@ export interface NPPESDedupBenchmarkOptions {
109
108
  */
110
109
  h3Res?: number
111
110
  /**
112
- * Geocode the sample across a worker pool ({@linkcode geocodeStream}) instead of the serial in-process seam. Heavy
111
+ * Geocode the sample across a worker pool ({@linkcode geocodeStream}) instead of the serial in-process path. Heavy
113
112
  * per-row work (ONNX parse + WOF SQLite) → threading pays; measured ~1.5× at 2 workers, coordinates identical.
114
113
  */
115
114
  parallelGeocode?: boolean
@@ -131,7 +130,7 @@ export async function nppesDedupBenchmark(
131
130
  report?: (line: string) => void
132
131
  ): Promise<{ markdown: string }> {
133
132
  const SOURCES = options.sources || dataRootPath("record-matcher", "sources")
134
- const STATE = (options.state || "TX").toUpperCase()
133
+ const STATE = stateOption(options)
135
134
  const MAX_NPIS = options.maxNpis ?? 300
136
135
  const OUT_MD = options.outMd || ""
137
136
  const TRAIN_EM = options.trainEm ?? true
@@ -173,7 +172,7 @@ export async function nppesDedupBenchmark(
173
172
 
174
173
  if (PARALLEL_GEOCODE) {
175
174
  // Threaded geocode: normalize on the main thread, then hand records to a worker pool that each rebuild the
176
- // classifier/resolver/shards from config. `address` is a single pre-joined column here, so `--legacy-join`
175
+ // classifier/resolver/extracts from config. `address` is a single pre-joined column here, so `--legacy-join`
177
176
  // (a separator toggle) is a no-op for this path; `normalizeCase` follows the worker default (on).
178
177
  if (!options.geocodeStream) {
179
178
  throw new Error("parallelGeocode requires the injected geocodeStream (see ./eval-geocoder.ts)")
@@ -197,9 +196,9 @@ export async function nppesDedupBenchmark(
197
196
  } else {
198
197
  const geocoder = await options.createGeocoder({ normalizeCase: !LEGACY })
199
198
 
200
- // Count placements at the seam (parity with the retired in-script counter).
201
- const countedSeam: GeocodeAddress = async (raw) => {
202
- const g = await geocoder.seam(raw)
199
+ // Count placements at the boundary (parity with the retired in-script counter).
200
+ const countedGeocodeForIngest: GeocodeAddress = async (raw) => {
201
+ const g = await geocoder.geocodeAddress(raw)
203
202
 
204
203
  if (g?.geocode) {
205
204
  geo++
@@ -209,11 +208,11 @@ export async function nppesDedupBenchmark(
209
208
  }
210
209
 
211
210
  records = await ingestRows(rows, mapping, {
212
- geocodeAddress: countedSeam,
211
+ geocodeAddress: countedGeocodeForIngest,
213
212
  addressSeparator: LEGACY ? " " : ", ",
214
213
  })
215
214
 
216
- geocoder.close()
215
+ geocoder[Symbol.dispose]()
217
216
  }
218
217
 
219
218
  report?.(` geocoded ${geo}/${rows.length} (${((100 * geo) / rows.length).toFixed(1)}%)`)
@@ -238,23 +237,23 @@ export async function nppesDedupBenchmark(
238
237
  const H3_RES = options.h3Res ?? 11 // res 11 ≈ 25 m edge; res 10 ≈ 65 m (block scale)
239
238
  const orgNameH3Label = buildOrgNameH3Grain(npiPrimary, npiCoord, H3_RES)
240
239
 
241
- // --- Phase D: the comparison-model lever progression — toggle each lever ON in turn at the default
240
+ // --- Phase D: the comparison-model setting progression — toggle each setting ON in turn at the default
242
241
  // threshold to isolate its marginal effect, then sweep the link threshold on the best config (geocode
243
242
  // once, resolve many — config is cheap). ---
244
- report?.(`[D] resolving the lever progression${TRAIN_EM ? " (EM-trained)" : ""}…`)
243
+ report?.(`[D] resolving the setting progression${TRAIN_EM ? " (EM-trained)" : ""}…`)
245
244
 
246
- // learnedScorer:false throughout — this benchmark studies the FS COMPARISON-MODEL levers (#617/#625).
245
+ // learnedScorer:false throughout — this benchmark studies the FS COMPARISON-MODEL settings (#617/#625).
247
246
  // The learned scorer is now default-on, so it must be pinned off here or every row would silently be the
248
247
  // GBT; the learned scorer is measured separately (learned-scorer-clustering-eval / -crossstate-eval).
249
- const progression = buildLevers(addressFrequency).map((l) => {
248
+ const progression = buildSettings(addressFrequency).map((l) => {
250
249
  const res = resolveEntities(records, { learnedScorer: false, trainEM: TRAIN_EM, threshold: 0, ...l.config })
251
250
 
252
251
  return { ...l, res, score: score(res.entities, npiLabel) }
253
252
  })
254
253
 
255
- const bestLever = progression.at(-1)! // the full lever stack
254
+ const bestSetting = progression.at(-1)! // the full setting stack
256
255
 
257
- // The SHIPPED out-of-box default (#86): no lever config at all → resolveEntities auto-computes an
256
+ // The SHIPPED out-of-box default (#86): no setting config at all → resolveEntities auto-computes an
258
257
  // input-scoped address-frequency table + collapsed spatial. On this deliberately-sub-sampled corpus the
259
258
  // auto table is sparse (few repeats), so the inverse-frequency signal is near-inert and F1 collapses to
260
259
  // ≈baseline — NOT a regression, just the honest truth that IDF is a corpus statistic you can't synthesize
@@ -266,12 +265,17 @@ export async function nppesDedupBenchmark(
266
265
  const THRESHOLDS = [0, 4, 8, 12, 16, 20]
267
266
 
268
267
  const sweep: SweepArm[] = THRESHOLDS.map((t) => {
269
- const res = resolveEntities(records, { learnedScorer: false, trainEM: TRAIN_EM, threshold: t, ...bestLever.config })
268
+ const res = resolveEntities(records, {
269
+ learnedScorer: false,
270
+ trainEM: TRAIN_EM,
271
+ threshold: t,
272
+ ...bestSetting.config,
273
+ })
270
274
 
271
275
  return { t, res, score: score(res.entities, npiLabel) }
272
276
  })
273
277
 
274
- const base = sweep[0]! // threshold 0, full lever stack
278
+ const base = sweep[0]! // threshold 0, full setting stack
275
279
  let best = sweep[0]!
276
280
 
277
281
  for (const arm of sweep) {
@@ -290,20 +294,20 @@ export async function nppesDedupBenchmark(
290
294
 
291
295
  // --- Phase F: NPI-level vs ENTITY-level truth. Score the SAME clusters against both yardsticks to
292
296
  // reveal how much of the apparent over-merge is NPI over-segmentation (one org / many subpart-NPIs,
293
- // where merging is CORRECT) rather than model error. Two production configs: the FS full lever stack
297
+ // where merging is CORRECT) rather than model error. Two production configs: the FS full setting stack
294
298
  // and the shipped default (GBT, default-on) — each fed the corpus-wide address-frequency table. ---
295
299
  const entityCount = new Set(records.map((r) => entityLabel(r))).size
296
300
  const orgCount = new Set(records.map((r) => orgNameLabel(r))).size
297
- const fsNPI = bestLever.score
298
- const fsEntity = score(bestLever.res.entities, entityLabel)
299
- const fsOrg = score(bestLever.res.entities, orgNameLabel)
301
+ const fsNPI = bestSetting.score
302
+ const fsEntity = score(bestSetting.res.entities, entityLabel)
303
+ const fsOrg = score(bestSetting.res.entities, orgNameLabel)
300
304
  const gbtRes = resolveEntities(records, { addressFrequency, trainEM: TRAIN_EM }) // GBT default-on (production)
301
305
  const gbtNPI = score(gbtRes.entities, npiLabel)
302
306
  const gbtEntity = score(gbtRes.entities, entityLabel)
303
307
  const gbtOrg = score(gbtRes.entities, orgNameLabel)
304
308
  // Tier 2D: the coordinate-co-location org-name truth (tighter lower bound).
305
309
  const orgCoordCount = new Set(records.map((r) => orgNameCoordLabel(r))).size
306
- const fsOrgCoord = score(bestLever.res.entities, orgNameCoordLabel)
310
+ const fsOrgCoord = score(bestSetting.res.entities, orgNameCoordLabel)
307
311
  const gbtOrgCoord = score(gbtRes.entities, orgNameCoordLabel)
308
312
  // #109: the H3-cell co-location truth — a robustness check on the haversine coord-grain.
309
313
  const orgH3Count = new Set(records.map((r) => orgNameH3Label(r))).size
@@ -315,7 +319,7 @@ export async function nppesDedupBenchmark(
315
319
  const DUMP_OVERMERGES = options.dumpOvermerges || ""
316
320
 
317
321
  if (DUMP_OVERMERGES) {
318
- const clusters = writeOvermergePacket(DUMP_OVERMERGES, {
322
+ const clusters = await writeOvermergePacket(DUMP_OVERMERGES, {
319
323
  state: STATE,
320
324
  entities: gbtRes.entities,
321
325
  rows,
@@ -396,7 +400,7 @@ export async function nppesDedupBenchmark(
396
400
  console.log(md)
397
401
 
398
402
  if (OUT_MD) {
399
- writeFileSync(OUT_MD, md)
403
+ await writeLocalFile(md, OUT_MD)
400
404
  report?.(`\n[written] ${OUT_MD}`)
401
405
  }
402
406