@mailwoman/registry 9.2.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/{address-key.ts → lib/address-key.ts} +1 -1
- package/{geocode-handler.ts → lib/geocode-handler.ts} +7 -7
- package/{geojson.ts → lib/geojson.ts} +9 -4
- package/{index.ts → lib/index.ts} +10 -10
- package/{ingest.ts → lib/ingest.ts} +75 -68
- package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
- package/{map-html.ts → lib/map-html.ts} +7 -13
- package/{reconcile.ts → lib/reconcile.ts} +7 -23
- package/{resolve.ts → lib/resolve.ts} +25 -12
- package/{tools → lib/tools}/coverage-reconciliation.ts +12 -14
- package/{tools → lib/tools}/cross-dataset-correlation.ts +60 -137
- package/{tools → lib/tools}/cross-source-threshold-sweep.ts +20 -31
- package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
- package/{tools → lib/tools}/eval-geocoder.ts +9 -10
- package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
- package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +9 -10
- package/lib/tools/gold-set-sample.ts +141 -0
- package/lib/tools/index.ts +31 -0
- package/{tools → lib/tools}/learned-scorer-clustering-eval.ts +68 -257
- package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +60 -243
- package/{tools → lib/tools}/learned-scorer-eval.ts +62 -256
- package/{tools → lib/tools}/matcher-scale.ts +4 -5
- package/lib/tools/nppes/org-name.ts +23 -0
- package/{tools → lib/tools}/nppes/overmerge-packet.ts +5 -7
- package/{tools → lib/tools}/nppes/report.ts +22 -25
- package/{tools → lib/tools}/nppes/sample.ts +80 -32
- package/{tools/nppes/levers.ts → lib/tools/nppes/settings.ts} +10 -10
- package/{tools → lib/tools}/nppes/truth-grains.ts +4 -44
- package/{tools → lib/tools}/nppes-dedup-benchmark.ts +42 -38
- package/lib/tools/shared.ts +763 -0
- package/lib/tools/train-cross-gbt.ts +209 -0
- package/{tools → lib/tools}/train-gbt.ts +35 -154
- package/lib/tools/train-org-cross-gbt.ts +179 -0
- package/{tools → lib/tools}/txhhsc-to-oarow.ts +9 -27
- package/lib/tools/viz/browser.ts +50 -0
- package/{tools → lib/tools}/viz/cross-dataset-map.ts +7 -8
- package/{tools → lib/tools}/viz/geocode-first-surface.ts +10 -8
- package/{tools → lib/tools}/viz/render-map.ts +10 -23
- package/lib/tools/viz/render.ts +98 -0
- package/{tools → lib/tools}/viz/source-provenance-map.ts +8 -10
- package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
- package/out/address-key.d.ts +1 -1
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +6 -6
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +6 -6
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +7 -2
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +5 -3
- package/out/geojson.js.map +1 -1
- package/out/index.d.ts +10 -10
- package/out/index.d.ts.map +1 -1
- package/out/index.js +10 -10
- package/out/index.js.map +1 -1
- package/out/ingest.d.ts +64 -46
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +31 -45
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +1 -1
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +3 -3
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +6 -11
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts +6 -1
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +5 -20
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +19 -7
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +16 -5
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.d.ts +1 -1
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +11 -11
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross-dataset-correlation.d.ts +4 -4
- package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross-dataset-correlation.js +57 -109
- package/out/tools/cross-dataset-correlation.js.map +1 -1
- package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
- package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
- package/out/tools/cross-source-threshold-sweep.js +19 -27
- package/out/tools/cross-source-threshold-sweep.js.map +1 -1
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +36 -117
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +8 -12
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +2 -2
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder-namesake-probe.d.ts +2 -2
- package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
- package/out/tools/geocoder-namesake-probe.js +4 -8
- package/out/tools/geocoder-namesake-probe.js.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.js +8 -7
- package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts +5 -5
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +37 -122
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/index.d.ts +23 -23
- package/out/tools/index.d.ts.map +1 -1
- package/out/tools/index.js +23 -23
- package/out/tools/index.js.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.js +35 -169
- package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
- package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.js +44 -166
- package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
- package/out/tools/learned-scorer-eval.d.ts +1 -1
- package/out/tools/learned-scorer-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-eval.js +37 -168
- package/out/tools/learned-scorer-eval.js.map +1 -1
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +4 -4
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts +2 -5
- package/out/tools/nppes/org-name.d.ts.map +1 -1
- package/out/tools/nppes/org-name.js +1 -30
- package/out/tools/nppes/org-name.js.map +1 -1
- package/out/tools/nppes/overmerge-packet.d.ts +3 -3
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
- package/out/tools/nppes/overmerge-packet.js +3 -3
- package/out/tools/nppes/overmerge-packet.js.map +1 -1
- package/out/tools/nppes/report.d.ts +5 -5
- package/out/tools/nppes/report.d.ts.map +1 -1
- package/out/tools/nppes/report.js +17 -19
- package/out/tools/nppes/report.js.map +1 -1
- package/out/tools/nppes/sample.d.ts +32 -6
- package/out/tools/nppes/sample.d.ts.map +1 -1
- package/out/tools/nppes/sample.js +44 -26
- package/out/tools/nppes/sample.js.map +1 -1
- package/out/tools/nppes/scoring.d.ts.map +1 -1
- package/out/tools/nppes/scoring.js.map +1 -1
- package/out/tools/nppes/{levers.d.ts → settings.d.ts} +8 -8
- package/out/tools/nppes/settings.d.ts.map +1 -0
- package/out/tools/nppes/{levers.js → settings.js} +8 -8
- package/out/tools/nppes/settings.js.map +1 -0
- package/out/tools/nppes/truth-grains.d.ts +2 -2
- package/out/tools/nppes/truth-grains.d.ts.map +1 -1
- package/out/tools/nppes/truth-grains.js +4 -29
- package/out/tools/nppes/truth-grains.js.map +1 -1
- package/out/tools/nppes-dedup-benchmark.d.ts +4 -4
- package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes-dedup-benchmark.js +40 -34
- package/out/tools/nppes-dedup-benchmark.js.map +1 -1
- package/out/tools/shared.d.ts +244 -7
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +349 -18
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train-cross-gbt.d.ts +7 -7
- package/out/tools/train-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-cross-gbt.js +47 -145
- package/out/tools/train-cross-gbt.js.map +1 -1
- package/out/tools/train-gbt.d.ts +7 -7
- package/out/tools/train-gbt.d.ts.map +1 -1
- package/out/tools/train-gbt.js +31 -111
- package/out/tools/train-gbt.js.map +1 -1
- package/out/tools/train-org-cross-gbt.d.ts +7 -5
- package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-org-cross-gbt.js +45 -141
- package/out/tools/train-org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.d.ts +2 -2
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +8 -22
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +34 -0
- package/out/tools/viz/browser.d.ts.map +1 -0
- package/out/tools/viz/browser.js +33 -0
- package/out/tools/viz/browser.js.map +1 -0
- package/out/tools/viz/cross-dataset-map.d.ts +2 -2
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +6 -6
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +4 -3
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +7 -5
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render-map.d.ts +3 -6
- package/out/tools/viz/render-map.d.ts.map +1 -1
- package/out/tools/viz/render-map.js +9 -19
- package/out/tools/viz/render-map.js.map +1 -1
- package/out/tools/viz/render.d.ts +4 -9
- package/out/tools/viz/render.d.ts.map +1 -1
- package/out/tools/viz/render.js +24 -39
- package/out/tools/viz/render.js.map +1 -1
- package/out/tools/viz/source-provenance-map.d.ts +2 -2
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +6 -7
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +2 -2
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +5 -4
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/package.json +115 -15
- package/out/tools/nppes/levers.d.ts.map +0 -1
- package/out/tools/nppes/levers.js.map +0 -1
- package/tools/gold-set-sample.ts +0 -254
- package/tools/index.ts +0 -31
- package/tools/nppes/org-name.ts +0 -56
- package/tools/shared.ts +0 -162
- package/tools/train-cross-gbt.ts +0 -359
- package/tools/train-org-cross-gbt.ts +0 -330
- package/tools/viz/render.ts +0 -113
- /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
- /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
- /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
- /package/{tools → lib/tools}/nppes/scoring.ts +0 -0
- /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
|
|
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
|
|
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 {
|
|
34
|
-
import {
|
|
35
|
-
import { pathToFileURL } from "
|
|
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
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
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 "
|
|
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
|
|
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
|
|
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/
|
|
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
|
|
201
|
-
const
|
|
202
|
-
const g = await geocoder.
|
|
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:
|
|
211
|
+
geocodeAddress: countedGeocodeForIngest,
|
|
213
212
|
addressSeparator: LEGACY ? " " : ", ",
|
|
214
213
|
})
|
|
215
214
|
|
|
216
|
-
geocoder.
|
|
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
|
|
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
|
|
243
|
+
report?.(`[D] resolving the setting progression${TRAIN_EM ? " (EM-trained)" : ""}…`)
|
|
245
244
|
|
|
246
|
-
// learnedScorer:false throughout — this benchmark studies the FS COMPARISON-MODEL
|
|
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 =
|
|
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
|
|
254
|
+
const bestSetting = progression.at(-1)! // the full setting stack
|
|
256
255
|
|
|
257
|
-
// The SHIPPED out-of-box default (#86): no
|
|
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, {
|
|
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
|
|
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
|
|
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 =
|
|
298
|
-
const fsEntity = score(
|
|
299
|
-
const fsOrg = score(
|
|
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(
|
|
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
|
-
|
|
403
|
+
await writeLocalFile(md, OUT_MD)
|
|
400
404
|
report?.(`\n[written] ${OUT_MD}`)
|
|
401
405
|
}
|
|
402
406
|
|