@mailwoman/registry 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/lib/address-key.ts +14 -10
- package/lib/geocode-handler.ts +6 -4
- package/lib/geojson.ts +11 -6
- package/lib/ingest.ts +57 -83
- package/lib/learned-scorer.ts +38 -44
- package/lib/map-html.ts +24 -70
- package/lib/models/crosssource-gbt-en-us.ts +9 -7
- package/lib/models/dedup-gbt-en-us.ts +9 -8
- package/lib/models/org-crosssource-gbt-en-us.ts +10 -8
- package/lib/reconcile.ts +43 -53
- package/lib/resolve.ts +180 -124
- package/lib/types.ts +18 -12
- package/out/address-key.d.ts +14 -10
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js +14 -10
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +6 -4
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +6 -4
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +9 -5
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +11 -6
- package/out/geojson.js.map +1 -1
- package/out/ingest.d.ts +46 -75
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +27 -54
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +29 -26
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js +31 -39
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +13 -32
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +9 -62
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts +9 -7
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js +9 -7
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts +9 -8
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js +9 -8
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts +10 -8
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js +10 -8
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts +35 -50
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +17 -41
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +150 -90
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +62 -63
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.d.ts +23 -23
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +15 -26
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross/dataset-correlation.d.ts +20 -27
- package/out/tools/cross/dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross/dataset-correlation.js +9 -61
- package/out/tools/cross/dataset-correlation.js.map +1 -1
- package/out/tools/cross/source-threshold-sweep.d.ts +20 -26
- package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -1
- package/out/tools/cross/source-threshold-sweep.js +14 -40
- package/out/tools/cross/source-threshold-sweep.js.map +1 -1
- package/out/tools/dedup-ceiling.d.ts +23 -26
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +22 -41
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +22 -15
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +5 -6
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder/namesake-probe.d.ts +9 -8
- package/out/tools/geocoder/namesake-probe.d.ts.map +1 -1
- package/out/tools/geocoder/namesake-probe.js +6 -7
- package/out/tools/geocoder/namesake-probe.js.map +1 -1
- package/out/tools/geocoder/vs-provided-coords.d.ts +18 -15
- package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder/vs-provided-coords.js +30 -27
- package/out/tools/geocoder/vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts +27 -18
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +18 -22
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.d.ts +30 -27
- package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.js +28 -38
- package/out/tools/learned/scorer/clustering-eval.js.map +1 -1
- package/out/tools/learned/scorer/crossstate-eval.d.ts +24 -18
- package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/crossstate-eval.js +19 -25
- package/out/tools/learned/scorer/crossstate-eval.js.map +1 -1
- package/out/tools/learned/scorer/eval.d.ts +22 -39
- package/out/tools/learned/scorer/eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/eval.js +11 -71
- package/out/tools/learned/scorer/eval.js.map +1 -1
- package/out/tools/matcher-scale.d.ts +12 -17
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +11 -29
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/dedup-benchmark.d.ts +21 -41
- package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes/dedup-benchmark.js +20 -66
- package/out/tools/nppes/dedup-benchmark.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts +5 -4
- package/out/tools/nppes/org-name.d.ts.map +1 -1
- package/out/tools/nppes/org-name.js +2 -2
- package/out/tools/nppes/org-name.js.map +1 -1
- package/out/tools/nppes/overmerge-packet.d.ts +15 -11
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
- package/out/tools/nppes/overmerge-packet.js +5 -6
- package/out/tools/nppes/overmerge-packet.js.map +1 -1
- package/out/tools/nppes/report.d.ts +17 -13
- package/out/tools/nppes/report.d.ts.map +1 -1
- package/out/tools/nppes/report.js +6 -14
- package/out/tools/nppes/report.js.map +1 -1
- package/out/tools/nppes/sample.d.ts +28 -17
- package/out/tools/nppes/sample.d.ts.map +1 -1
- package/out/tools/nppes/sample.js +23 -26
- package/out/tools/nppes/sample.js.map +1 -1
- package/out/tools/nppes/scoring.d.ts +7 -6
- package/out/tools/nppes/scoring.d.ts.map +1 -1
- package/out/tools/nppes/scoring.js +6 -5
- package/out/tools/nppes/scoring.js.map +1 -1
- package/out/tools/nppes/settings.d.ts +10 -7
- package/out/tools/nppes/settings.d.ts.map +1 -1
- package/out/tools/nppes/settings.js +16 -16
- package/out/tools/nppes/settings.js.map +1 -1
- package/out/tools/nppes/truth-grains.d.ts +36 -23
- package/out/tools/nppes/truth-grains.d.ts.map +1 -1
- package/out/tools/nppes/truth-grains.js +36 -20
- package/out/tools/nppes/truth-grains.js.map +1 -1
- package/out/tools/shared.d.ts +63 -59
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +49 -66
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train/cross-gbt.d.ts +36 -26
- package/out/tools/train/cross-gbt.d.ts.map +1 -1
- package/out/tools/train/cross-gbt.js +14 -25
- package/out/tools/train/cross-gbt.js.map +1 -1
- package/out/tools/train/gbt.d.ts +36 -20
- package/out/tools/train/gbt.d.ts.map +1 -1
- package/out/tools/train/gbt.js +27 -31
- package/out/tools/train/gbt.js.map +1 -1
- package/out/tools/train/org-cross-gbt.d.ts +37 -24
- package/out/tools/train/org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train/org-cross-gbt.js +18 -22
- package/out/tools/train/org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.d.ts +14 -9
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +16 -15
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +6 -5
- package/out/tools/viz/browser.d.ts.map +1 -1
- package/out/tools/viz/browser.js +6 -5
- package/out/tools/viz/browser.js.map +1 -1
- package/out/tools/viz/cross-dataset-map.d.ts +7 -4
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +9 -6
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +10 -5
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +16 -11
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render/map.d.ts +5 -5
- package/out/tools/viz/render/map.d.ts.map +1 -1
- package/out/tools/viz/render/map.js +6 -5
- package/out/tools/viz/render/map.js.map +1 -1
- package/out/tools/viz/{render/index.d.ts → render.d.ts} +13 -9
- package/out/tools/viz/render.d.ts.map +1 -0
- package/out/tools/viz/{render/index.js → render.js} +9 -8
- package/out/tools/viz/render.js.map +1 -0
- package/out/tools/viz/source-provenance-map.d.ts +19 -7
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +11 -8
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +2 -21
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +3 -39
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts +17 -11
- package/out/types.d.ts.map +1 -1
- package/out/types.js +2 -2
- package/out/types.js.map +1 -1
- package/package.json +41 -184
- package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
- package/{lib/tools → tools}/cross/dataset-correlation.ts +31 -72
- package/{lib/tools → tools}/cross/source-threshold-sweep.ts +29 -46
- package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
- package/tools/eval-geocoder.ts +74 -0
- package/{lib/tools → tools}/geocoder/namesake-probe.ts +9 -8
- package/{lib/tools → tools}/geocoder/vs-provided-coords.ts +39 -30
- package/{lib/tools → tools}/gold-set-sample.ts +35 -29
- package/{lib/tools → tools}/learned/scorer/clustering-eval.ts +49 -45
- package/{lib/tools → tools}/learned/scorer/crossstate-eval.ts +34 -30
- package/{lib/tools → tools}/learned/scorer/eval.ts +35 -78
- package/{lib/tools → tools}/matcher-scale.ts +21 -33
- package/{lib/tools → tools}/nppes/dedup-benchmark.ts +37 -82
- package/{lib/tools → tools}/nppes/org-name.ts +5 -4
- package/{lib/tools → tools}/nppes/overmerge-packet.ts +15 -11
- package/{lib/tools → tools}/nppes/report.ts +32 -25
- package/{lib/tools → tools}/nppes/sample.ts +41 -36
- package/{lib/tools → tools}/nppes/scoring.ts +7 -6
- package/{lib/tools → tools}/nppes/settings.ts +16 -16
- package/{lib/tools → tools}/nppes/truth-grains.ts +46 -26
- package/{lib/tools → tools}/shared.ts +73 -83
- package/{lib/tools → tools}/train/cross-gbt.ts +38 -34
- package/{lib/tools → tools}/train/gbt.ts +55 -41
- package/{lib/tools → tools}/train/org-cross-gbt.ts +39 -30
- package/{lib/tools → tools}/txhhsc-to-oarow.ts +24 -18
- package/{lib/tools → tools}/viz/browser.ts +6 -5
- package/{lib/tools → tools}/viz/cross-dataset-map.ts +15 -9
- package/{lib/tools → tools}/viz/geocode-first-surface.ts +28 -17
- package/{lib/tools → tools}/viz/render/map.ts +7 -6
- package/{lib/tools/viz/render/index.ts → tools/viz/render.ts} +16 -11
- package/{lib/tools → tools}/viz/source-provenance-map.ts +30 -15
- package/{lib/tools → tools}/viz/yardstick-figure.ts +6 -43
- package/lib/tools/eval-geocoder.ts +0 -67
- package/lib/tools/index.ts +0 -31
- package/out/tools/index.d.ts +0 -31
- package/out/tools/index.d.ts.map +0 -1
- package/out/tools/index.js +0 -31
- package/out/tools/index.js.map +0 -1
- package/out/tools/viz/render/index.d.ts.map +0 -1
- package/out/tools/viz/render/index.js.map +0 -1
|
@@ -3,26 +3,20 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Train the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* feasibility doc blocked a cross-source retrain on "no non-circular anchor"; the anchor exists:
|
|
11
|
-
* **CMS Open Payments joins NPPES by NPI** — the same practitioner in two INDEPENDENT registries,
|
|
12
|
-
* each with independently human-entered name + address. Same-NPI cross-source pairs are
|
|
13
|
-
* ground-truth positives labeled by a key the matcher's features never see.
|
|
6
|
+
* Train the cross-source link scorer. The dedup GBT is trained on within-NPPES labels, so its
|
|
7
|
+
* strongest feature (`spatial-exact × name-disagree`) rejects the prototypical cross-source pair,
|
|
8
|
+
* the same provider under different operational text across registries.
|
|
9
|
+
* CMS Open Payments joins NPPES by NPI. That join provides ground-truth positive pairs labeled by a key the matcher never sees.
|
|
14
10
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* `
|
|
19
|
-
* threshold rule: max recall subject to a pairwise-precision bar, reported alongside F1-max) →
|
|
20
|
-
* train the shipped model on all pairs → emit `registry/models/crosssource-gbt-en-us.ts`.
|
|
11
|
+
* The pipeline assembles NPPES and Open Payments TX records for the same NPI population, then the
|
|
12
|
+
* shared `trainCrossSourceModel` geocodes through the standard ingest and blocks the union. It keeps only
|
|
13
|
+
* cross-source candidate pairs. It trains the shipped model into
|
|
14
|
+
* `registry/models/crosssource-gbt-en-us.ts`.
|
|
21
15
|
*
|
|
22
16
|
* Sources (both public domain, `.notes/data-sources.md`):
|
|
23
17
|
*
|
|
24
|
-
* - `nppes_npi-registry_*.tsv
|
|
25
|
-
* - `openpayments_covered-recipient-profile_*.csv
|
|
18
|
+
* - `nppes_npi-registry_*.tsv`: the practice-location and primary-name records.
|
|
19
|
+
* - `openpayments_covered-recipient-profile_*.csv`: the OP profile supplement (NPI, profile
|
|
26
20
|
* first/last, profile practice address).
|
|
27
21
|
*
|
|
28
22
|
* Run: `mailwoman registry train-scorer cross-gbt [--state TX] [--npis 2000]
|
|
@@ -32,6 +26,7 @@
|
|
|
32
26
|
|
|
33
27
|
import { dataRootPath } from "@mailwoman/core/data-root"
|
|
34
28
|
import { isoDate } from "@mailwoman/core/utils"
|
|
29
|
+
import { resolvePath, type PathBuilderLike } from "path-ts"
|
|
35
30
|
|
|
36
31
|
import { addressFrequencyKey, streamRows } from "#index"
|
|
37
32
|
import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
|
|
@@ -42,59 +37,73 @@ import { addr, norm, NPPES_COLUMNS as N, stateOption, trainCrossSourceModel, typ
|
|
|
42
37
|
*/
|
|
43
38
|
export interface TrainCrossSourceGBTOptions {
|
|
44
39
|
/**
|
|
45
|
-
* The injected geocoder factory
|
|
40
|
+
* The injected geocoder factory.
|
|
41
|
+
*
|
|
42
|
+
* The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
|
|
46
43
|
*/
|
|
47
44
|
createGeocoder: EvalGeocoderFactory
|
|
48
45
|
/**
|
|
49
|
-
* Record-matcher sources directory.
|
|
46
|
+
* Record-matcher sources directory.
|
|
47
|
+
*
|
|
48
|
+
* Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
|
|
50
49
|
*/
|
|
51
|
-
sources?:
|
|
50
|
+
sources?: PathBuilderLike
|
|
52
51
|
/**
|
|
53
|
-
* State filter.
|
|
52
|
+
* State filter.
|
|
53
|
+
*
|
|
54
|
+
* Default TX.
|
|
54
55
|
*/
|
|
55
56
|
state?: string
|
|
56
57
|
/**
|
|
57
|
-
* NPIs sampled.
|
|
58
|
+
* NPIs sampled.
|
|
59
|
+
*
|
|
60
|
+
* Default 2000.
|
|
58
61
|
*/
|
|
59
62
|
npis?: number
|
|
60
63
|
/**
|
|
61
|
-
* Output TS module path.
|
|
64
|
+
* Output TS module path.
|
|
65
|
+
*
|
|
66
|
+
* Default `registry/models/crosssource-gbt-en-us.ts`.
|
|
62
67
|
*/
|
|
63
68
|
out?: string
|
|
64
69
|
/**
|
|
65
|
-
* Locale recorded in the model meta.
|
|
70
|
+
* Locale recorded in the model meta.
|
|
71
|
+
*
|
|
72
|
+
* Default en-US.
|
|
66
73
|
*/
|
|
67
74
|
locale?: string
|
|
68
75
|
/**
|
|
69
|
-
*
|
|
76
|
+
* Max cross-source recall subject to this held-out pairwise precision.
|
|
77
|
+
* Default 0.95.
|
|
70
78
|
*/
|
|
71
79
|
precisionBar?: number
|
|
72
80
|
/**
|
|
73
|
-
*
|
|
81
|
+
* The training date stored in the metadata.
|
|
82
|
+
*
|
|
83
|
+
* Default today.
|
|
74
84
|
*/
|
|
75
85
|
date?: string
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
/**
|
|
79
|
-
* Train
|
|
89
|
+
* Train and emit the cross-source link GBT.
|
|
80
90
|
*/
|
|
81
91
|
export async function trainCrossSourceGBT(
|
|
82
92
|
options: TrainCrossSourceGBTOptions,
|
|
83
93
|
report?: (line: string) => void
|
|
84
94
|
): Promise<{ out: string; pairs: number; recommendedThreshold: number }> {
|
|
85
|
-
const SOURCES = options.sources
|
|
95
|
+
const SOURCES = resolvePath(options.sources ?? dataRootPath("record-matcher", "sources"))
|
|
86
96
|
const STATE = stateOption(options)
|
|
87
97
|
const NPIS = options.npis ?? 2000
|
|
88
98
|
const OUT = options.out || "packages/registry/lib/models/crosssource-gbt-en-us.ts"
|
|
89
99
|
const LOCALE = options.locale || "en-US"
|
|
90
|
-
//
|
|
100
|
+
// Max cross-source recall subject to this held-out pairwise precision.
|
|
91
101
|
const PRECISION_BAR = options.precisionBar ?? 0.95
|
|
92
102
|
const TRAIN_DATE = options.date || isoDate()
|
|
93
103
|
|
|
94
104
|
const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
|
|
95
105
|
const OP_PROFILE = `${SOURCES}/openpayments_covered-recipient-profile_20260603.csv`
|
|
96
106
|
|
|
97
|
-
// Build Open Payments practitioner records with NPI, profile name, and profile address.
|
|
98
107
|
report?.(`[A] streaming the OP profile supplement (${STATE})…`)
|
|
99
108
|
const opByNPI = new Map<string, CrossSourceRow>()
|
|
100
109
|
|
|
@@ -121,8 +130,6 @@ export async function trainCrossSourceGBT(
|
|
|
121
130
|
|
|
122
131
|
report?.(` ${opByNPI.size} OP ${STATE} practitioners`)
|
|
123
132
|
|
|
124
|
-
// Join the same NPPES NPIs with practice address, legal name, and corpus-wide
|
|
125
|
-
// address-frequency table (one full registry pass, identical to train-gbt). ---
|
|
126
133
|
report?.("[B] full registry pass: address-frequency table + the NPI-joined NPPES rows…")
|
|
127
134
|
const rows: CrossSourceRow[] = []
|
|
128
135
|
const joined = new Set<string>()
|
|
@@ -157,7 +164,6 @@ export async function trainCrossSourceGBT(
|
|
|
157
164
|
rows.push({ npi, name, org: "", address: practice, source: "nppes" })
|
|
158
165
|
}
|
|
159
166
|
|
|
160
|
-
// Keep only NPIs present in BOTH sources — every record has a cross-source counterpart.
|
|
161
167
|
for (const npi of joined) {
|
|
162
168
|
rows.push(opByNPI.get(npi)!)
|
|
163
169
|
}
|
|
@@ -170,8 +176,6 @@ export async function trainCrossSourceGBT(
|
|
|
170
176
|
|
|
171
177
|
report?.(` ${joined.size} NPI-joined pairs → ${rows.length} records`)
|
|
172
178
|
|
|
173
|
-
// Run the shared cross-source trainer: geocode, form pairs, calibrate, and train.
|
|
174
|
-
// → shipped model → committed module). ---
|
|
175
179
|
return trainCrossSourceModel({
|
|
176
180
|
createGeocoder: options.createGeocoder,
|
|
177
181
|
rows,
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* benchmark
|
|
8
|
-
*
|
|
9
|
-
* `createMatchFeaturizer
|
|
10
|
-
*
|
|
11
|
-
* (`registry/models/dedup-gbt-en-us.ts`) that ships in the package.
|
|
6
|
+
* Trains the production learned-scorer model. `buildNPPESSample` creates the same NPI-keyed records used by
|
|
7
|
+
* the dedup benchmark and clustering A/B. The sample uses the real registry and includes name drift plus address variation.
|
|
8
|
+
* The trainer geocodes records and groups them into candidate pairs. It featurizes each pair with
|
|
9
|
+
* `createMatchFeaturizer`. It labels pairs by NPI and fits a gradient-boosted tree model.
|
|
10
|
+
* It writes the model to the committed package module `registry/models/dedup-gbt-en-us.ts`.
|
|
12
11
|
*
|
|
13
|
-
* Unlike the eval, this trains on
|
|
14
|
-
* eval's job
|
|
15
|
-
* then re-measures generalization against the FS baseline.
|
|
12
|
+
* Unlike the eval, this trains on all sampled NPIs with no held-out split, since the held-out F1
|
|
13
|
+
* is the eval's job.
|
|
16
14
|
*
|
|
17
15
|
* Run: `mailwoman registry train-scorer gbt [--state TX] [--npis 3000] [--wof <admin.db>]
|
|
18
16
|
* [--data-root <dir>] [--out registry/models/dedup-gbt-en-us.ts]`
|
|
@@ -20,6 +18,7 @@
|
|
|
20
18
|
|
|
21
19
|
import { dataRootPath } from "@mailwoman/core/data-root"
|
|
22
20
|
import { makeDirectories, writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
21
|
+
import { prettyJSON, stringifyJSON } from "@mailwoman/core/json"
|
|
23
22
|
import { makeLcg } from "@mailwoman/core/random"
|
|
24
23
|
import { isoDate } from "@mailwoman/core/utils"
|
|
25
24
|
import { block, gbtScore, trainGBT } from "@mailwoman/match"
|
|
@@ -40,7 +39,8 @@ import { scoreEntities } from "#tools/nppes/scoring"
|
|
|
40
39
|
import { stateOption, uniqueQuantiles } from "#tools/shared"
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
|
-
* Share of entities assigned to fit
|
|
42
|
+
* Share of entities assigned to fit.
|
|
43
|
+
* The rest are held out.
|
|
44
44
|
*/
|
|
45
45
|
const FIT_SPLIT_FRACTION = 0.8
|
|
46
46
|
|
|
@@ -49,43 +49,61 @@ const FIT_SPLIT_FRACTION = 0.8
|
|
|
49
49
|
*/
|
|
50
50
|
export interface TrainDedupGBTOptions {
|
|
51
51
|
/**
|
|
52
|
-
* The injected geocoder factory
|
|
52
|
+
* The injected geocoder factory.
|
|
53
|
+
*
|
|
54
|
+
* The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
|
|
53
55
|
*/
|
|
54
56
|
createGeocoder: EvalGeocoderFactory
|
|
55
57
|
/**
|
|
56
|
-
* Record-matcher sources directory.
|
|
58
|
+
* Record-matcher sources directory.
|
|
59
|
+
*
|
|
60
|
+
* Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
|
|
57
61
|
*/
|
|
58
62
|
sources?: string
|
|
59
63
|
/**
|
|
60
|
-
* State filter.
|
|
64
|
+
* State filter.
|
|
65
|
+
*
|
|
66
|
+
* Default TX.
|
|
61
67
|
*/
|
|
62
68
|
state?: string
|
|
63
69
|
/**
|
|
64
|
-
* NPIs sampled.
|
|
70
|
+
* NPIs sampled.
|
|
71
|
+
*
|
|
72
|
+
* Default 3000.
|
|
65
73
|
*/
|
|
66
74
|
npis?: number
|
|
67
75
|
/**
|
|
68
|
-
* Output TS module path.
|
|
76
|
+
* Output TS module path.
|
|
77
|
+
*
|
|
78
|
+
* Default `registry/models/dedup-gbt-en-us.ts`.
|
|
69
79
|
*/
|
|
70
80
|
out?: string
|
|
71
81
|
/**
|
|
72
|
-
* Locale recorded in the model meta (the command's factory loads the matching weights).
|
|
82
|
+
* Locale recorded in the model meta (the command's factory loads the matching weights).
|
|
83
|
+
*
|
|
84
|
+
* Default en-US.
|
|
73
85
|
*/
|
|
74
86
|
locale?: string
|
|
75
87
|
/**
|
|
76
|
-
* Cost-sensitive training
|
|
77
|
-
*
|
|
78
|
-
*
|
|
88
|
+
* Cost-sensitive training: up-weight the negative (distinct-pair) class by this factor
|
|
89
|
+
* so the model is more conservative about merging.
|
|
90
|
+
*
|
|
91
|
+
* It trades recall for precision to reduce over-merge.
|
|
92
|
+
* `1` is the symmetric class-balanced default.
|
|
93
|
+
*
|
|
94
|
+
* A value above 1 penalizes a false merge more than a missed merge.
|
|
79
95
|
*/
|
|
80
96
|
cost?: number
|
|
81
97
|
/**
|
|
82
|
-
*
|
|
98
|
+
* The training date stored in the metadata (overridable for reproducible commits).
|
|
99
|
+
*
|
|
100
|
+
* Default today.
|
|
83
101
|
*/
|
|
84
102
|
date?: string
|
|
85
103
|
}
|
|
86
104
|
|
|
87
105
|
/**
|
|
88
|
-
* Train
|
|
106
|
+
* Train and emit the production dedup GBT.
|
|
89
107
|
*/
|
|
90
108
|
export async function trainDedupGBT(
|
|
91
109
|
options: TrainDedupGBTOptions,
|
|
@@ -97,24 +115,22 @@ export async function trainDedupGBT(
|
|
|
97
115
|
const OUT = options.out || "packages/registry/lib/models/dedup-gbt-en-us.ts"
|
|
98
116
|
const LOCALE = options.locale || "en-US"
|
|
99
117
|
const COST = options.cost ?? 1
|
|
100
|
-
const TRAIN_DATE = options.date || isoDate()
|
|
118
|
+
const TRAIN_DATE = options.date || isoDate()
|
|
101
119
|
|
|
102
120
|
const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
|
|
103
121
|
const OTHER_NAMES = `${SOURCES}/nppes_other-names_20260607.tsv`
|
|
104
122
|
|
|
105
|
-
// Build the variation-rich sample and corpus-wide address-frequency table.
|
|
106
|
-
// sample builder — the same records the dedup benchmark and the learned-scorer evals see). ---
|
|
107
123
|
const { rows, keptNpis, addressFrequency } = await buildNPPESSample(
|
|
108
124
|
{ registryPath: REGISTRY, otherNamesPath: OTHER_NAMES, state: STATE, maxNpis: NPIS },
|
|
109
125
|
report
|
|
110
126
|
)
|
|
111
127
|
|
|
112
|
-
//
|
|
113
|
-
// injected (see ./eval-geocoder.ts) — the registry package never imports the runtime. ---
|
|
128
|
+
// The geocoder is injected, since the registry package never imports the runtime.
|
|
114
129
|
report?.("[C] geocoding…")
|
|
115
130
|
const geocoder = await options.createGeocoder()
|
|
116
131
|
|
|
117
|
-
//
|
|
132
|
+
// `record.id` supplies the NPI label.
|
|
133
|
+
// Multiple records can share an NPI as ground truth.
|
|
118
134
|
const mapping: ColumnMapping = {
|
|
119
135
|
id: "npi",
|
|
120
136
|
name: "name",
|
|
@@ -131,7 +147,6 @@ export async function trainDedupGBT(
|
|
|
131
147
|
const geocoded = records.filter((r) => r.address?.geocode).length
|
|
132
148
|
report?.(` ${records.length} records, ${geocoded} geocoded`)
|
|
133
149
|
|
|
134
|
-
// Block records, generate shared features, then assign labels.
|
|
135
150
|
report?.("[D] blocking + featurizing…")
|
|
136
151
|
const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons
|
|
137
152
|
const featurize = createMatchFeaturizer({ comparisons, addressFrequency })
|
|
@@ -139,18 +154,18 @@ export async function trainDedupGBT(
|
|
|
139
154
|
const X = pairs.map(([a, b]) => featurize(a, b))
|
|
140
155
|
const Y = pairs.map(([a, b]) => (a.id === b.id ? 1 : 0))
|
|
141
156
|
const posRate = Y.reduce<number>((s, v) => s + v, 0) / Math.max(1, Y.length)
|
|
142
|
-
const W = Y.map((y) => (y === 1 ? 1 - posRate : posRate * COST))
|
|
157
|
+
const W = Y.map((y) => (y === 1 ? 1 - posRate : posRate * COST))
|
|
143
158
|
const hyperparams = { rounds: 120, depth: 3, lr: 0.3, minLeaf: 20 }
|
|
144
159
|
|
|
145
160
|
if (COST !== 1) {
|
|
146
161
|
report?.(` cost-sensitive: negative class weighted ×${COST} (penalize over-merge)`)
|
|
147
162
|
}
|
|
148
163
|
|
|
149
|
-
// Calibrate the default link threshold
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
// The shipped full-data model has near-identical logit calibration, so the threshold transfers.
|
|
164
|
+
// Calibrate the default link threshold.
|
|
165
|
+
// The GBT logit uses no Fellegi-Sunter weight units.
|
|
166
|
+
// With class-balanced weights, logit 0 ignores the roughly 1% match base rate and over-merges.
|
|
167
|
+
// The threshold is swept on a held-out 20% of NPIs.
|
|
168
|
+
// The shipped full-data model has near-identical logit calibration, so the threshold transfers.
|
|
154
169
|
report?.("[E] calibrating the default link threshold on a held-out NPI split…")
|
|
155
170
|
const rnd = makeLcg(20_260_615)
|
|
156
171
|
const split = new Map<string, "fit" | "holdout">()
|
|
@@ -196,13 +211,12 @@ export async function trainDedupGBT(
|
|
|
196
211
|
` recommended link threshold ${recommendedThreshold.toFixed(3)} (held-out clustering F1 ${(100 * bestF1).toFixed(1)}%)`
|
|
197
212
|
)
|
|
198
213
|
|
|
199
|
-
// Train the shipped model on every available pair.
|
|
200
214
|
report?.("[F] training the shipped model on all pairs…")
|
|
201
215
|
const model = trainGBT(X, Y, W, hyperparams)
|
|
202
216
|
report?.(` ${pairs.length} pairs (${(100 * posRate).toFixed(1)}% positive), ${model.trees.length} trees`)
|
|
203
217
|
|
|
204
|
-
// Emit the model as a committed TypeScript module with a prettier-stable literal
|
|
205
|
-
// retrain produces a clean one-line diff
|
|
218
|
+
// Emit the model as a committed TypeScript module with a prettier-stable literal,
|
|
219
|
+
// so a retrain produces a clean one-line diff.
|
|
206
220
|
const meta = {
|
|
207
221
|
version: "1.0.0",
|
|
208
222
|
locale: LOCALE,
|
|
@@ -212,9 +226,9 @@ export async function trainDedupGBT(
|
|
|
212
226
|
records: records.length,
|
|
213
227
|
pairs: pairs.length,
|
|
214
228
|
posRate: Number(posRate.toFixed(4)),
|
|
215
|
-
costNegative: COST,
|
|
229
|
+
costNegative: COST,
|
|
216
230
|
hyperparams,
|
|
217
|
-
recommendedThreshold: Number(recommendedThreshold.toFixed(4)),
|
|
231
|
+
recommendedThreshold: Number(recommendedThreshold.toFixed(4)),
|
|
218
232
|
features: X[0]?.length ?? 0,
|
|
219
233
|
addressFrequencyDistinct: addressFrequency.distinct,
|
|
220
234
|
addressFrequencyTotal: addressFrequency.total,
|
|
@@ -235,9 +249,9 @@ export async function trainDedupGBT(
|
|
|
235
249
|
` */\n\n` +
|
|
236
250
|
`import type { GBT } from "@mailwoman/match"\n\n` +
|
|
237
251
|
`/** Provenance for the bundled model — what it was trained on. */\n` +
|
|
238
|
-
`export const DEDUP_GBT_META = ${
|
|
252
|
+
`export const DEDUP_GBT_META = ${prettyJSON(meta)} as const\n\n` +
|
|
239
253
|
`// prettier-ignore\n` +
|
|
240
|
-
`export const DEDUP_GBT_MODEL: GBT = ${
|
|
254
|
+
`export const DEDUP_GBT_MODEL: GBT = ${stringifyJSON(model)}\n`
|
|
241
255
|
|
|
242
256
|
await makeDirectories(dirname(OUT))
|
|
243
257
|
await writeLocalFile(moduleSource, OUT)
|
|
@@ -3,24 +3,21 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Train the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* systems (certification vs quality reporting), each with independently-entered name + address.
|
|
11
|
-
* Measured drift across the national join (n≈5.4k): 12.2% name, 4.9% address — the rename /
|
|
12
|
-
* system-vs-facility / acquisition class the org objective exists for.
|
|
6
|
+
* Train the organization-level cross-source link scorer. The practitioner cross-source GBT does
|
|
7
|
+
* not transfer to organization records because its person-name features go dark. The organization
|
|
8
|
+
* cross-dataset flows therefore pin the FS baseline. CMS Provider of Services joins Care Compare
|
|
9
|
+
* by CCN. Each system represents the same facility and maintains its name and address separately.
|
|
13
10
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* `registry/models/org-crosssource-gbt-en-us.ts`.
|
|
11
|
+
* The pipeline runs a national CCN join into one record per source per facility, then the shared
|
|
12
|
+
* `trainCrossSourceModel` geocodes the rows and blocks the union. It keeps cross-source pairs.
|
|
13
|
+
* It featurizes them with the shared featurizer and labels them by CCN.
|
|
14
|
+
* Calibration uses held-out CCNs.
|
|
15
|
+
* The function emits `registry/models/org-crosssource-gbt-en-us.ts`.
|
|
19
16
|
*
|
|
20
17
|
* Sources (both public domain, direct CSVs):
|
|
21
18
|
*
|
|
22
|
-
* - `cms-pos_hospital-other_*.csv
|
|
23
|
-
* - `cms-carecompare_hospital-general_*.csv
|
|
19
|
+
* - `cms-pos_hospital-other_*.csv`: Provider of Services (PRVDR_NUM, FAC_NAME, ST_ADR…).
|
|
20
|
+
* - `cms-carecompare_hospital-general_*.csv`: Care Compare (Facility ID, Facility Name, Address…).
|
|
24
21
|
*
|
|
25
22
|
* Run: `mailwoman registry train-scorer org-cross-gbt [--cap 6000] [--precision-bar 0.95]
|
|
26
23
|
* [--wof <admin.db>] [--data-root <dir>] [--out registry/models/org-crosssource-gbt-en-us.ts]`
|
|
@@ -28,6 +25,7 @@
|
|
|
28
25
|
|
|
29
26
|
import { dataRootPath } from "@mailwoman/core/data-root"
|
|
30
27
|
import { isoDate } from "@mailwoman/core/utils"
|
|
28
|
+
import { resolvePath, type PathBuilderLike } from "path-ts"
|
|
31
29
|
|
|
32
30
|
import { addressFrequencyKey, streamRows } from "#index"
|
|
33
31
|
import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
|
|
@@ -38,55 +36,69 @@ import { addr, norm, trainCrossSourceModel, type CrossSourceRow } from "#tools/s
|
|
|
38
36
|
*/
|
|
39
37
|
export interface TrainOrgCrossSourceGBTOptions {
|
|
40
38
|
/**
|
|
41
|
-
* The injected geocoder factory
|
|
39
|
+
* The injected geocoder factory.
|
|
40
|
+
*
|
|
41
|
+
* The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
|
|
42
42
|
*/
|
|
43
43
|
createGeocoder: EvalGeocoderFactory
|
|
44
44
|
/**
|
|
45
|
-
* Record-matcher sources directory.
|
|
45
|
+
* Record-matcher sources directory.
|
|
46
|
+
*
|
|
47
|
+
* Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
|
|
46
48
|
*/
|
|
47
|
-
sources?:
|
|
49
|
+
sources?: PathBuilderLike
|
|
48
50
|
/**
|
|
49
|
-
* Care Compare facilities sampled.
|
|
51
|
+
* Care Compare facilities sampled.
|
|
52
|
+
*
|
|
53
|
+
* Default 6000.
|
|
50
54
|
*/
|
|
51
55
|
cap?: number
|
|
52
56
|
/**
|
|
53
|
-
* Output TS module path.
|
|
57
|
+
* Output TS module path.
|
|
58
|
+
*
|
|
59
|
+
* Default `registry/models/org-crosssource-gbt-en-us.ts`.
|
|
54
60
|
*/
|
|
55
61
|
out?: string
|
|
56
62
|
/**
|
|
57
|
-
* Locale recorded in the model meta.
|
|
63
|
+
* Locale recorded in the model meta.
|
|
64
|
+
*
|
|
65
|
+
* Default en-US.
|
|
58
66
|
*/
|
|
59
67
|
locale?: string
|
|
60
68
|
/**
|
|
61
|
-
*
|
|
69
|
+
* Max cross-source recall subject to this held-out pairwise precision.
|
|
70
|
+
* Default 0.95.
|
|
62
71
|
*/
|
|
63
72
|
precisionBar?: number
|
|
64
73
|
/**
|
|
65
|
-
*
|
|
74
|
+
* The training date stored in the metadata.
|
|
75
|
+
*
|
|
76
|
+
* Default today.
|
|
66
77
|
*/
|
|
67
78
|
date?: string
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
/**
|
|
71
|
-
* Train
|
|
72
|
-
*
|
|
82
|
+
* Train and emit the org-level cross-source link GBT.
|
|
83
|
+
*
|
|
84
|
+
* The CCN is the cross-system facility key.
|
|
85
|
+
* It is stored in {@link CrossSourceRow.npi} and copied to `record.id` as the held-out label.
|
|
73
86
|
*/
|
|
74
87
|
export async function trainOrgCrossSourceGBT(
|
|
75
88
|
options: TrainOrgCrossSourceGBTOptions,
|
|
76
89
|
report?: (line: string) => void
|
|
77
90
|
): Promise<{ out: string; pairs: number; recommendedThreshold: number }> {
|
|
78
|
-
const SOURCES = options.sources
|
|
91
|
+
const SOURCES = resolvePath(options.sources ?? dataRootPath("record-matcher", "sources"))
|
|
79
92
|
const CAP = options.cap ?? 6000
|
|
80
93
|
const OUT = options.out || "packages/registry/lib/models/org-crosssource-gbt-en-us.ts"
|
|
81
94
|
const LOCALE = options.locale || "en-US"
|
|
82
|
-
//
|
|
95
|
+
// Max cross-source recall subject to this held-out pairwise precision.
|
|
83
96
|
const PRECISION_BAR = options.precisionBar ?? 0.95
|
|
84
97
|
const TRAIN_DATE = options.date || isoDate()
|
|
85
98
|
|
|
86
99
|
const POS = `${SOURCES}/cms-pos_hospital-other_2026q1.csv`
|
|
87
100
|
const CARE_COMPARE = `${SOURCES}/cms-carecompare_hospital-general_20260706.csv`
|
|
88
101
|
|
|
89
|
-
// Build Care Compare facility records with facility ID, name, and address.
|
|
90
102
|
report?.("[A] streaming Care Compare…")
|
|
91
103
|
const ccByID = new Map<string, CrossSourceRow>()
|
|
92
104
|
|
|
@@ -102,7 +114,6 @@ export async function trainOrgCrossSourceGBT(
|
|
|
102
114
|
|
|
103
115
|
report?.(` ${ccByID.size} Care Compare facilities`)
|
|
104
116
|
|
|
105
|
-
// Join the same CCNs from POS with the corpus-wide address-frequency table.
|
|
106
117
|
report?.("[B] streaming POS + building the frequency table…")
|
|
107
118
|
const rows: CrossSourceRow[] = []
|
|
108
119
|
const joined = new Set<string>()
|
|
@@ -141,8 +152,6 @@ export async function trainOrgCrossSourceGBT(
|
|
|
141
152
|
|
|
142
153
|
report?.(` ${joined.size} CCN-joined facilities → ${rows.length} records`)
|
|
143
154
|
|
|
144
|
-
// Run the shared cross-source trainer: geocode, form pairs, calibrate, and train.
|
|
145
|
-
// → shipped model → committed module). ---
|
|
146
155
|
return trainCrossSourceModel({
|
|
147
156
|
createGeocoder: options.createGeocoder,
|
|
148
157
|
rows,
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* = `lat,lon` per facility
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Convert the TX hhsc nursing-facilities source into the OaRow jsonl the resolver eval consumes.
|
|
7
|
+
* The source ships an authoritative `Geo Location` = `lat,lon` per facility, so the geocoder is
|
|
8
|
+
* graded against the provided coordinates on real facility addresses. `oa-resolver-eval
|
|
9
|
+
* --address-points` reports a great-circle delta and a tier breakdown.
|
|
10
10
|
*
|
|
11
|
-
* Neutral scope: this measures
|
|
11
|
+
* Neutral scope: this measures geocoder accuracy on real public addresses and makes no claim about
|
|
12
12
|
* the facilities themselves.
|
|
13
13
|
*
|
|
14
14
|
* Run: `mailwoman registry convert tx-hhsc [--src <tsv>] [--out /tmp/txhhsc-oarow.jsonl]`
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
|
|
18
18
|
import { readLocalTextFile } from "@mailwoman/core/fs/readers"
|
|
19
19
|
import { writeLocalTextFile } from "@mailwoman/core/fs/writers"
|
|
20
|
+
import { stringifyJSON } from "@mailwoman/core/json"
|
|
21
|
+
import type { PathBuilderLike } from "path-ts"
|
|
20
22
|
import { TSVSpliterator } from "spliterator"
|
|
21
23
|
|
|
22
24
|
import { inTXBBOX } from "#tools/shared"
|
|
@@ -26,11 +28,15 @@ import { inTXBBOX } from "#tools/shared"
|
|
|
26
28
|
*/
|
|
27
29
|
export interface TXHHSCConvertOptions {
|
|
28
30
|
/**
|
|
29
|
-
* The TX
|
|
31
|
+
* The TX hhsc nursing-facilities TSV.
|
|
32
|
+
*
|
|
33
|
+
* Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources/…`.
|
|
30
34
|
*/
|
|
31
|
-
src?:
|
|
35
|
+
src?: PathBuilderLike
|
|
32
36
|
/**
|
|
33
|
-
* Output OaRow
|
|
37
|
+
* Output OaRow jsonl path.
|
|
38
|
+
*
|
|
39
|
+
* Default `/tmp/txhhsc-oarow.jsonl`.
|
|
34
40
|
*/
|
|
35
41
|
out?: string
|
|
36
42
|
}
|
|
@@ -38,20 +44,20 @@ export interface TXHHSCConvertOptions {
|
|
|
38
44
|
const GEO = /^\s*(-?\d+\.\d+)\s*,\s*(-?\d+\.\d+)\s*$/
|
|
39
45
|
|
|
40
46
|
/**
|
|
41
|
-
* Convert the TX
|
|
47
|
+
* Convert the TX hhsc nursing-facilities TSV into OaRow jsonl for `oa-resolver-eval`.
|
|
42
48
|
*/
|
|
43
49
|
export async function convertTXHHSC(
|
|
44
50
|
options: TXHHSCConvertOptions = {},
|
|
45
51
|
report?: (line: string) => void
|
|
46
52
|
): Promise<{ written: number; skipped: number; out: string }> {
|
|
47
|
-
const src = options.src
|
|
53
|
+
const src = options.src ?? dataRootPath("record-matcher", "sources", "txhhsc_nursing-facilities_20260611.tsv")
|
|
48
54
|
const out = options.out || tempRootPath("txhhsc-oarow.jsonl")
|
|
49
55
|
|
|
50
56
|
const records: string[] = []
|
|
51
57
|
let skipped = 0
|
|
52
58
|
|
|
53
|
-
// Column indices
|
|
54
|
-
// blank-row guard below applies to it
|
|
59
|
+
// Column indices come from the first non-blank row.
|
|
60
|
+
// `header: false` keeps that row in the stream, so the blank-row guard below applies to it.
|
|
55
61
|
let cAddr = -1
|
|
56
62
|
let cCity = -1
|
|
57
63
|
let cZip = -1
|
|
@@ -59,7 +65,7 @@ export async function convertTXHHSC(
|
|
|
59
65
|
let sawHeader = false
|
|
60
66
|
|
|
61
67
|
for (const f of TSVSpliterator.from(await readLocalTextFile(src), { header: false })) {
|
|
62
|
-
if (f.every((value) => !value
|
|
68
|
+
if (f.every((value) => !value)) continue
|
|
63
69
|
|
|
64
70
|
if (!sawHeader) {
|
|
65
71
|
sawHeader = true
|
|
@@ -72,9 +78,9 @@ export async function convertTXHHSC(
|
|
|
72
78
|
continue
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
const addr =
|
|
76
|
-
const city =
|
|
77
|
-
const zip =
|
|
81
|
+
const addr = f[cAddr] ?? ""
|
|
82
|
+
const city = f[cCity] ?? ""
|
|
83
|
+
const zip = f[cZip] ?? ""
|
|
78
84
|
const m = GEO.exec(f[cGeo] ?? "")
|
|
79
85
|
|
|
80
86
|
if (!addr || !city || !m) {
|
|
@@ -94,7 +100,7 @@ export async function convertTXHHSC(
|
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
records.push(
|
|
97
|
-
|
|
103
|
+
stringifyJSON({
|
|
98
104
|
input: `${addr}, ${city}, TX ${zip}`,
|
|
99
105
|
lat,
|
|
100
106
|
lon,
|
|
@@ -105,7 +111,7 @@ export async function convertTXHHSC(
|
|
|
105
111
|
)
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
await writeLocalTextFile(records
|
|
114
|
+
await writeLocalTextFile(records, out)
|
|
109
115
|
report?.(`wrote ${records.length} rows (skipped ${skipped}) → ${out}`)
|
|
110
116
|
|
|
111
117
|
return { written: records.length, skipped, out }
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* The shared headless-Chromium harness behind the `registry viz` renderers (an internal helper,
|
|
7
|
-
*
|
|
8
|
-
* the browser launches on ANGLE's SwiftShader software rasterizer (`--use-gl=angle
|
|
6
|
+
* The shared headless-Chromium harness behind the `registry viz` renderers (an internal helper rather than a command). The WebGL consumers (Plotly 3D, MapLibre) get no GPU in headless Chromium, so
|
|
7
|
+
* the browser launches on angle's SwiftShader software rasterizer (`--use-gl=angle
|
|
9
8
|
* --use-angle=swiftshader --enable-unsafe-swiftshader`); each caller owns its own navigation +
|
|
10
9
|
* wait strategy and screenshots inside the callback.
|
|
11
10
|
*
|
|
@@ -24,8 +23,10 @@ export interface ChromiumPageOptions {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
|
-
* Launch headless Chromium (SwiftShader WebGL), open one page at `deviceScaleFactor: 2`,
|
|
28
|
-
* run `fn`, and dispose the browser.
|
|
26
|
+
* Launch headless Chromium (SwiftShader WebGL), open one page at `deviceScaleFactor: 2`,
|
|
27
|
+
* collect console + page errors, run `fn`, and dispose the browser.
|
|
28
|
+
*
|
|
29
|
+
* The callback owns navigation, waits and the screenshot.
|
|
29
30
|
*/
|
|
30
31
|
export async function withChromiumPage<T>(
|
|
31
32
|
options: ChromiumPageOptions,
|