@mailwoman/registry 9.1.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/geojson.ts +3 -2
- package/ingest.ts +2 -1
- package/map-html.ts +4 -4
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +3 -2
- package/out/geojson.js.map +1 -1
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +2 -1
- package/out/ingest.js.map +1 -1
- package/out/map-html.d.ts +2 -2
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js.map +1 -1
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +2 -1
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +4 -1
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.js +2 -2
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross-dataset-correlation.js +6 -5
- package/out/tools/cross-dataset-correlation.js.map +1 -1
- package/out/tools/cross-source-threshold-sweep.js +2 -2
- 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 +2 -3
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +1 -1
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.js +3 -2
- package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +4 -3
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/index.d.ts +1 -6
- package/out/tools/index.d.ts.map +1 -1
- package/out/tools/index.js +1 -6
- package/out/tools/index.js.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.js +1 -2
- package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.js +1 -1
- package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
- package/out/tools/learned-scorer-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-eval.js +1 -6
- 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 +1 -1
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/levers.d.ts +38 -0
- package/out/tools/nppes/levers.d.ts.map +1 -0
- package/out/tools/nppes/levers.js +79 -0
- package/out/tools/nppes/levers.js.map +1 -0
- package/out/tools/nppes/org-name.d.ts +24 -0
- package/out/tools/nppes/org-name.d.ts.map +1 -0
- package/out/tools/nppes/org-name.js +42 -0
- package/out/tools/nppes/org-name.js.map +1 -0
- package/out/tools/nppes/overmerge-packet.d.ts +39 -0
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -0
- package/out/tools/nppes/overmerge-packet.js +55 -0
- package/out/tools/nppes/overmerge-packet.js.map +1 -0
- package/out/tools/nppes/report.d.ts +93 -0
- package/out/tools/nppes/report.d.ts.map +1 -0
- package/out/tools/nppes/report.js +188 -0
- package/out/tools/nppes/report.js.map +1 -0
- package/out/tools/nppes/sample.d.ts +64 -0
- package/out/tools/nppes/sample.d.ts.map +1 -0
- package/out/tools/nppes/sample.js +113 -0
- package/out/tools/nppes/sample.js.map +1 -0
- package/out/tools/nppes/scoring.d.ts +36 -0
- package/out/tools/nppes/scoring.d.ts.map +1 -0
- package/out/tools/nppes/scoring.js +80 -0
- package/out/tools/nppes/scoring.js.map +1 -0
- package/out/tools/nppes/truth-grains.d.ts +50 -0
- package/out/tools/nppes/truth-grains.d.ts.map +1 -0
- package/out/tools/nppes/truth-grains.js +148 -0
- package/out/tools/nppes/truth-grains.js.map +1 -0
- package/out/tools/nppes-dedup-benchmark.d.ts +4 -0
- package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes-dedup-benchmark.js +79 -652
- package/out/tools/nppes-dedup-benchmark.js.map +1 -1
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +5 -4
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-cross-gbt.js +2 -2
- package/out/tools/train-cross-gbt.js.map +1 -1
- package/out/tools/train-gbt.d.ts.map +1 -1
- package/out/tools/train-gbt.js +2 -2
- package/out/tools/train-gbt.js.map +1 -1
- package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-org-cross-gbt.js +2 -2
- package/out/tools/train-org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +2 -2
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/cross-dataset-map.d.ts +2 -23
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +7 -28
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +2 -32
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +4 -33
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render.js +1 -1
- package/out/tools/viz/render.js.map +1 -1
- package/out/tools/viz/source-provenance-map.d.ts +2 -22
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +7 -26
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/types.d.ts +11 -1
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/package.json +78 -9
- package/reconcile.ts +2 -1
- package/resolve.ts +6 -1
- package/tools/coverage-reconciliation.ts +3 -3
- package/tools/cross-dataset-correlation.ts +7 -5
- package/tools/cross-source-threshold-sweep.ts +3 -3
- package/tools/dedup-ceiling.ts +3 -3
- package/tools/eval-geocoder.ts +1 -1
- package/tools/geocoder-vs-provided-coords.ts +4 -2
- package/tools/gold-set-sample.ts +5 -3
- package/tools/index.ts +1 -6
- package/tools/learned-scorer-clustering-eval.ts +4 -4
- package/tools/learned-scorer-crossstate-eval.ts +4 -4
- package/tools/learned-scorer-eval.ts +4 -9
- package/tools/matcher-scale.ts +2 -1
- package/tools/nppes/levers.ts +102 -0
- package/tools/nppes/org-name.ts +56 -0
- package/tools/nppes/overmerge-packet.ts +96 -0
- package/tools/nppes/report.ts +376 -0
- package/tools/nppes/sample.ts +197 -0
- package/tools/nppes/scoring.ts +114 -0
- package/tools/nppes/truth-grains.ts +201 -0
- package/tools/nppes-dedup-benchmark.ts +92 -868
- package/tools/shared.ts +6 -4
- package/tools/train-cross-gbt.ts +6 -5
- package/tools/train-gbt.ts +5 -4
- package/tools/train-org-cross-gbt.ts +6 -5
- package/tools/txhhsc-to-oarow.ts +2 -2
- package/tools/viz/cross-dataset-map.ts +12 -34
- package/tools/viz/geocode-first-surface.ts +5 -33
- package/tools/viz/render.ts +1 -1
- package/tools/viz/source-provenance-map.ts +14 -31
- package/types.ts +10 -1
package/tools/shared.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* stays with that probe.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { isPresent } from "@mailwoman/core/objects"
|
|
13
|
+
|
|
12
14
|
import type { ColumnMapping } from "../ingest.ts"
|
|
13
15
|
|
|
14
16
|
export interface SourceSpec {
|
|
@@ -27,7 +29,7 @@ export const norm = (s: string | undefined): string => (s ?? "").trim()
|
|
|
27
29
|
* Join the four US address columns into one line, dropping blanks.
|
|
28
30
|
*/
|
|
29
31
|
export const addr = (line: string, city: string, st: string, zip: string): string =>
|
|
30
|
-
[norm(line), norm(city), norm(st), norm(zip)].filter(
|
|
32
|
+
[norm(line), norm(city), norm(st), norm(zip)].filter(isPresent).join(", ")
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Arithmetic mean; `0` on an empty sample rather than `NaN`, because these feed report tables that print a number per
|
|
@@ -60,11 +62,11 @@ export const NPPES_COLUMNS = {
|
|
|
60
62
|
pAddr: "Provider First Line Business Practice Location Address",
|
|
61
63
|
pCity: "Provider Business Practice Location Address City Name",
|
|
62
64
|
pState: "Provider Business Practice Location Address State Name",
|
|
63
|
-
pZip: "Provider Business Practice Location Address
|
|
65
|
+
pZip: "Provider Business Practice Location Address Postcode",
|
|
64
66
|
mAddr: "Provider First Line Business Mailing Address",
|
|
65
67
|
mCity: "Provider Business Mailing Address City Name",
|
|
66
68
|
mState: "Provider Business Mailing Address State Name",
|
|
67
|
-
mZip: "Provider Business Mailing Address
|
|
69
|
+
mZip: "Provider Business Mailing Address Postcode",
|
|
68
70
|
otherOrg: "Provider Other Organization Name",
|
|
69
71
|
authLast: "Authorized Official Last Name",
|
|
70
72
|
authFirst: "Authorized Official First Name",
|
|
@@ -147,7 +149,7 @@ export const buildSpecs = (S: string, STATE: string): SourceSpec[] => [
|
|
|
147
149
|
"Provider First Line Business Practice Location Address",
|
|
148
150
|
"Provider Business Practice Location Address City Name",
|
|
149
151
|
"Provider Business Practice Location Address State Name",
|
|
150
|
-
"Provider Business Practice Location Address
|
|
152
|
+
"Provider Business Practice Location Address Postcode",
|
|
151
153
|
],
|
|
152
154
|
phone: "Provider Business Practice Location Address Telephone Number",
|
|
153
155
|
source: "nppes",
|
package/tools/train-cross-gbt.ts
CHANGED
|
@@ -35,6 +35,7 @@ import { dirname } from "node:path"
|
|
|
35
35
|
|
|
36
36
|
import { dataRootPath, makeLcg } from "@mailwoman/core/utils"
|
|
37
37
|
import { block, gbtScore, trainGBT } from "@mailwoman/match"
|
|
38
|
+
|
|
38
39
|
import {
|
|
39
40
|
addressFrequencyKey,
|
|
40
41
|
buildDefaultModel,
|
|
@@ -44,7 +45,7 @@ import {
|
|
|
44
45
|
streamRows,
|
|
45
46
|
type ColumnMapping,
|
|
46
47
|
type SourceRecord,
|
|
47
|
-
} from "
|
|
48
|
+
} from "#index"
|
|
48
49
|
|
|
49
50
|
import type { EvalGeocoderFactory } from "./eval-geocoder.ts"
|
|
50
51
|
import { addr, norm, NPPES_COLUMNS as N, uniqueQuantiles } from "./shared.ts"
|
|
@@ -92,7 +93,7 @@ export interface TrainCrossSourceGBTOptions {
|
|
|
92
93
|
date?: string
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
interface MessyRow {
|
|
96
|
+
interface MessyRow extends Record<string, string> {
|
|
96
97
|
npi: string
|
|
97
98
|
name: string
|
|
98
99
|
org: string
|
|
@@ -110,7 +111,7 @@ export async function trainCrossSourceGBT(
|
|
|
110
111
|
const SOURCES = options.sources || String(dataRootPath("record-matcher", "sources"))
|
|
111
112
|
const STATE = (options.state || "TX").toUpperCase()
|
|
112
113
|
const NPIS = options.npis ?? 2000
|
|
113
|
-
const OUT = options.out || "registry/models/crosssource-gbt-en-us.ts"
|
|
114
|
+
const OUT = options.out || "packages/registry/models/crosssource-gbt-en-us.ts"
|
|
114
115
|
const LOCALE = options.locale || "en-US"
|
|
115
116
|
// #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
|
|
116
117
|
const PRECISION_BAR = options.precisionBar ?? 0.95
|
|
@@ -214,10 +215,10 @@ export async function trainCrossSourceGBT(
|
|
|
214
215
|
const opRows = rows.filter((r) => r.source === "openpayments")
|
|
215
216
|
|
|
216
217
|
const records: SourceRecord[] = [
|
|
217
|
-
...(await ingestRows(nppesRows
|
|
218
|
+
...(await ingestRows(nppesRows, mappingFor("nppes"), {
|
|
218
219
|
geocodeAddress: geocoder.seam,
|
|
219
220
|
})),
|
|
220
|
-
...(await ingestRows(opRows
|
|
221
|
+
...(await ingestRows(opRows, mappingFor("openpayments"), {
|
|
221
222
|
geocodeAddress: geocoder.seam,
|
|
222
223
|
})),
|
|
223
224
|
]
|
package/tools/train-gbt.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { dirname } from "node:path"
|
|
|
23
23
|
|
|
24
24
|
import { dataRootPath, makeLcg } from "@mailwoman/core/utils"
|
|
25
25
|
import { block, gbtScore, trainGBT } from "@mailwoman/match"
|
|
26
|
+
|
|
26
27
|
import {
|
|
27
28
|
addressFrequencyKey,
|
|
28
29
|
buildDefaultModel,
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
streamRows,
|
|
34
35
|
type ColumnMapping,
|
|
35
36
|
type SourceRecord,
|
|
36
|
-
} from "
|
|
37
|
+
} from "#index"
|
|
37
38
|
|
|
38
39
|
import type { EvalGeocoderFactory } from "./eval-geocoder.ts"
|
|
39
40
|
import { addr, MIN_GROUP_SIZE, norm, NPPES_COLUMNS as C, uniqueQuantiles } from "./shared.ts"
|
|
@@ -83,7 +84,7 @@ export interface TrainDedupGBTOptions {
|
|
|
83
84
|
date?: string
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
interface MessyRow {
|
|
87
|
+
interface MessyRow extends Record<string, string> {
|
|
87
88
|
npi: string
|
|
88
89
|
name: string
|
|
89
90
|
org: string
|
|
@@ -140,7 +141,7 @@ export async function trainDedupGBT(
|
|
|
140
141
|
const SOURCES = options.sources || dataRootPath("record-matcher", "sources")
|
|
141
142
|
const STATE = (options.state || "TX").toUpperCase()
|
|
142
143
|
const NPIS = options.npis ?? 3000
|
|
143
|
-
const OUT = options.out || "registry/models/dedup-gbt-en-us.ts"
|
|
144
|
+
const OUT = options.out || "packages/registry/models/dedup-gbt-en-us.ts"
|
|
144
145
|
const LOCALE = options.locale || "en-US"
|
|
145
146
|
const COST = options.cost ?? 1
|
|
146
147
|
const TRAIN_DATE = options.date || new Date().toISOString().slice(0, 10) // overridable for reproducible commits
|
|
@@ -242,7 +243,7 @@ export async function trainDedupGBT(
|
|
|
242
243
|
attributes: { authorizedOfficial: "auth" },
|
|
243
244
|
}
|
|
244
245
|
|
|
245
|
-
const records: SourceRecord[] = await ingestRows(rows
|
|
246
|
+
const records: SourceRecord[] = await ingestRows(rows, mapping, {
|
|
246
247
|
geocodeAddress: geocoder.seam,
|
|
247
248
|
})
|
|
248
249
|
|
|
@@ -30,6 +30,7 @@ import { dirname } from "node:path"
|
|
|
30
30
|
|
|
31
31
|
import { dataRootPath, makeLcg } from "@mailwoman/core/utils"
|
|
32
32
|
import { block, gbtScore, trainGBT } from "@mailwoman/match"
|
|
33
|
+
|
|
33
34
|
import {
|
|
34
35
|
addressFrequencyKey,
|
|
35
36
|
buildDefaultModel,
|
|
@@ -39,7 +40,7 @@ import {
|
|
|
39
40
|
streamRows,
|
|
40
41
|
type ColumnMapping,
|
|
41
42
|
type SourceRecord,
|
|
42
|
-
} from "
|
|
43
|
+
} from "#index"
|
|
43
44
|
|
|
44
45
|
import type { EvalGeocoderFactory } from "./eval-geocoder.ts"
|
|
45
46
|
import { addr, norm, uniqueQuantiles } from "./shared.ts"
|
|
@@ -83,7 +84,7 @@ export interface TrainOrgCrossSourceGBTOptions {
|
|
|
83
84
|
date?: string
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
interface MessyRow {
|
|
87
|
+
interface MessyRow extends Record<string, string> {
|
|
87
88
|
/**
|
|
88
89
|
* The CCN — the cross-system facility key; rides `record.id` as the held-out label.
|
|
89
90
|
*/
|
|
@@ -103,7 +104,7 @@ export async function trainOrgCrossSourceGBT(
|
|
|
103
104
|
): Promise<{ out: string; pairs: number; recommendedThreshold: number }> {
|
|
104
105
|
const SOURCES = options.sources || String(dataRootPath("record-matcher", "sources"))
|
|
105
106
|
const CAP = options.cap ?? 6000
|
|
106
|
-
const OUT = options.out || "registry/models/org-crosssource-gbt-en-us.ts"
|
|
107
|
+
const OUT = options.out || "packages/registry/models/org-crosssource-gbt-en-us.ts"
|
|
107
108
|
const LOCALE = options.locale || "en-US"
|
|
108
109
|
// #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
|
|
109
110
|
const PRECISION_BAR = options.precisionBar ?? 0.95
|
|
@@ -186,10 +187,10 @@ export async function trainOrgCrossSourceGBT(
|
|
|
186
187
|
const ccRows = rows.filter((r) => r.source === "care-compare")
|
|
187
188
|
|
|
188
189
|
const records: SourceRecord[] = [
|
|
189
|
-
...(await ingestRows(posRows
|
|
190
|
+
...(await ingestRows(posRows, mappingFor("cms-pos"), {
|
|
190
191
|
geocodeAddress: geocoder.seam,
|
|
191
192
|
})),
|
|
192
|
-
...(await ingestRows(ccRows
|
|
193
|
+
...(await ingestRows(ccRows, mappingFor("care-compare"), {
|
|
193
194
|
geocodeAddress: geocoder.seam,
|
|
194
195
|
})),
|
|
195
196
|
]
|
package/tools/txhhsc-to-oarow.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { readFileSync, writeFileSync } from "node:fs"
|
|
18
18
|
|
|
19
|
-
import { dataRootPath } from "@mailwoman/core/utils"
|
|
19
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/utils"
|
|
20
20
|
import { TSVSpliterator } from "spliterator"
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -63,7 +63,7 @@ export function convertTXHHSC(
|
|
|
63
63
|
report?: (line: string) => void
|
|
64
64
|
): { written: number; skipped: number; out: string } {
|
|
65
65
|
const src = options.src || String(dataRootPath("record-matcher", "sources", "txhhsc_nursing-facilities_20260611.tsv"))
|
|
66
|
-
const out = options.out || "
|
|
66
|
+
const out = options.out || tempRootPath("txhhsc-oarow.jsonl")
|
|
67
67
|
|
|
68
68
|
const records: string[] = []
|
|
69
69
|
let skipped = 0
|
|
@@ -3,36 +3,17 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* The matcher resolves entities ACROSS independent sources (NPPES provider registry, FCC RHC
|
|
9
|
-
* funding, TX HHSC facility licensing) with NO shared key — purely on the geocoded location +
|
|
10
|
-
* name agreement. This renders the `cross-dataset-links` GeoJSON (every entity that resolved
|
|
11
|
-
* across ≥2 sources) on the HOUSE map stack via {@link toMapHTML} (MapLibre GL + a Protomaps
|
|
12
|
-
* basemap). Each entity is colored by its SOURCE COMBINATION (a synthesized `bucket`), so the
|
|
13
|
-
* entities spanning all three sources stand out from the two-source links.
|
|
14
|
-
*
|
|
15
|
-
* Neutral entity-resolution view: it shows what resolved to what and how confidently (cohesion
|
|
16
|
-
* sizes the marker). It does NOT interpret coverage/eligibility — that is the consumer's call.
|
|
17
|
-
*
|
|
18
|
-
* SERVE THE OUTPUT OVER LOCALHOST (the house tile server CORS-restricts to localhost + the docs
|
|
19
|
-
* domains; a file:// page shows accurate markers on a blank basemap). e.g. `python3 -m
|
|
20
|
-
* http.server -d <dir>` then open the page; or use `renderServedMapToPNG` (`./render-map.ts`)
|
|
21
|
-
* against the served URL.
|
|
22
|
-
*
|
|
23
|
-
* `--cross-agency-only` keeps just the entities whose sources span >1 AGENCY (the two FCC datasets
|
|
24
|
-
* count as one) — the harder cross-agency slice; most raw links are FCC-internal (RHC ↔
|
|
25
|
-
* commitments).
|
|
26
|
-
*
|
|
27
|
-
* Run: `mailwoman registry viz cross-dataset-map [--in <links.geojson>]
|
|
28
|
-
* [--out-html /tmp/cross-dataset-map.html] [--cross-agency-only]`
|
|
6
|
+
* Render linked entities from a GeoJSON file in MapLibre, colored by source combination.
|
|
7
|
+
* `crossAgencyOnly` removes links whose sources belong to one agency.
|
|
29
8
|
*/
|
|
30
9
|
|
|
31
10
|
import { readFileSync, writeFileSync } from "node:fs"
|
|
32
11
|
|
|
33
12
|
import { parseJSONStrict } from "@mailwoman/core/objects"
|
|
34
|
-
import { dataRootPath } from "@mailwoman/core/utils"
|
|
35
|
-
import {
|
|
13
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/utils"
|
|
14
|
+
import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial"
|
|
15
|
+
|
|
16
|
+
import { type MapFeatureData, toMapHTML } from "#index"
|
|
36
17
|
|
|
37
18
|
/**
|
|
38
19
|
* Distinct agencies a combination needs before it is plotted as a cross-agency cluster.
|
|
@@ -82,8 +63,8 @@ const SOURCE_AGENCY: Record<string, string> = {
|
|
|
82
63
|
|
|
83
64
|
const agencyOf = (s: string) => SOURCE_AGENCY[s] ?? s
|
|
84
65
|
|
|
85
|
-
const sourcesOf = (f:
|
|
86
|
-
Array.isArray(f.properties?.
|
|
66
|
+
const sourcesOf = (f: GeoFeature<PointLiteral, MapFeatureData>): string[] =>
|
|
67
|
+
Array.isArray(f.properties?.sources) ? f.properties.sources : []
|
|
87
68
|
|
|
88
69
|
/**
|
|
89
70
|
* Render the cross-dataset-links GeoJSON to a bucket-colored MapLibre HTML page.
|
|
@@ -93,13 +74,10 @@ export function crossDatasetMap(
|
|
|
93
74
|
report?: (line: string) => void
|
|
94
75
|
): { outHTML: string; kept: number; total: number; triple: number } {
|
|
95
76
|
const IN = options.in || dataRootPath("record-matcher", "2026-06-16-cross-dataset-links.geojson")
|
|
96
|
-
const OUT = options.outHTML || "
|
|
77
|
+
const OUT = options.outHTML || tempRootPath("cross-dataset-map.html")
|
|
97
78
|
const CROSS_AGENCY_ONLY = options.crossAgencyOnly ?? false
|
|
98
79
|
|
|
99
|
-
const parsed = parseJSONStrict<
|
|
100
|
-
type: "FeatureCollection"
|
|
101
|
-
features: Array<{ properties: Record<string, unknown> | null }>
|
|
102
|
-
}>(readFileSync(IN, "utf8"))
|
|
80
|
+
const parsed = parseJSONStrict<GeoFeatureCollection<PointLiteral, MapFeatureData>>(readFileSync(IN, "utf8"))
|
|
103
81
|
|
|
104
82
|
const total = parsed.features.length
|
|
105
83
|
|
|
@@ -117,7 +95,7 @@ export function crossDatasetMap(
|
|
|
117
95
|
const bucket = combo.map(label).join(" + ") || "unlinked"
|
|
118
96
|
|
|
119
97
|
if (f.properties) {
|
|
120
|
-
f.properties
|
|
98
|
+
f.properties.bucket = bucket
|
|
121
99
|
}
|
|
122
100
|
|
|
123
101
|
if (new Set(combo.map(agencyOf)).size >= MIN_DISTINCT_AGENCIES) {
|
|
@@ -130,7 +108,7 @@ export function crossDatasetMap(
|
|
|
130
108
|
const kept = geojson.features.length
|
|
131
109
|
const scope = CROSS_AGENCY_ONLY ? "across agencies" : "across sources"
|
|
132
110
|
|
|
133
|
-
const html = toMapHTML(geojson
|
|
111
|
+
const html = toMapHTML(geojson, {
|
|
134
112
|
title: `Cross-dataset entity links — ${kept} resolved ${scope} (no shared key)`,
|
|
135
113
|
flavor: "light",
|
|
136
114
|
colorBy: "bucket",
|
|
@@ -3,42 +3,14 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* What a reader should walk away with: **geography is the primary key; string similarity only
|
|
9
|
-
* refines within a place.** The figure makes that legible as a _landscape_. Two surfaces of
|
|
10
|
-
* P(match) over the same record-pair space (string similarity × geographic distance), scored by
|
|
11
|
-
* the SAME Fellegi-Sunter machinery, differing only in which evidence each model is allowed to
|
|
12
|
-
* see:
|
|
13
|
-
*
|
|
14
|
-
* - **String-first** sees the name agreement only → its decision boundary is _vertical_: high string
|
|
15
|
-
* similarity ⇒ match, at any distance. It fuses `Springfield General (IL)` with `Springfield
|
|
16
|
-
* General (MA)` (identical name, ~1500 km apart) and still misses `123 Main St` ↔ `123 Main
|
|
17
|
-
* Street Apt 2` when the strings drift.
|
|
18
|
-
* - **Geocode-first** also sees the distance agreement → its boundary _bends with geography_: near
|
|
19
|
-
* the same coordinate a modest name match suffices; far apart, even an exact name is
|
|
20
|
-
* rejected. It gets both traps right.
|
|
21
|
-
*
|
|
22
|
-
* Honesty notes (so the figure can't mislead):
|
|
23
|
-
*
|
|
24
|
-
* - The per-level weights are the REAL Bayes factors from the codebase — `NAME_LEVELS`
|
|
25
|
-
* (`registry/resolve.ts`) and `DEFAULT_DISTANCE_LEVELS` (`match/distance.ts`). Geography
|
|
26
|
-
* simply carries the heaviest evidence: ±9.45 bits at the same-building grain vs ±6.32 for an
|
|
27
|
-
* exact name.
|
|
28
|
-
* - The PRIOR is illustrative (λ shown in the caption), not production's λ=1e-4. Production is even
|
|
29
|
-
* more conservative and leans on additional corroboration (phone, the spatial exact-key) that
|
|
30
|
-
* this two-axis slice deliberately omits — the point here is the _shape of the boundary_, not
|
|
31
|
-
* a reproduction of a production score. The caption says so.
|
|
32
|
-
*
|
|
33
|
-
* Emits a self-contained Plotly HTML (twin 3D landscapes + an annotated 2D contour). Render to PNG
|
|
34
|
-
* with `renderPlotlyHTMLToPNG` (`./render.ts` — Playwright + swiftshader for headless WebGL).
|
|
35
|
-
*
|
|
36
|
-
* Run: `mailwoman registry viz geocode-first-surface [--lambda 0.02]
|
|
37
|
-
* [--out-html /tmp/geocode-first-surface.html]`
|
|
6
|
+
* Plot string-only and string-plus-distance match probabilities using the record matcher's
|
|
7
|
+
* Fellegi-Sunter weights. The supplied prior is illustrative and the output is self-contained HTML.
|
|
38
8
|
*/
|
|
39
9
|
|
|
40
10
|
import { writeFileSync } from "node:fs"
|
|
41
11
|
|
|
12
|
+
import { tempRootPath } from "@mailwoman/core/utils"
|
|
13
|
+
|
|
42
14
|
/**
|
|
43
15
|
* Options for {@linkcode geocodeFirstSurface}.
|
|
44
16
|
*/
|
|
@@ -115,7 +87,7 @@ export function geocodeFirstSurface(
|
|
|
115
87
|
report?: (line: string) => void
|
|
116
88
|
): { outHTML: string } {
|
|
117
89
|
const LAMBDA = options.lambda ?? 0.02
|
|
118
|
-
const OUT_HTML = options.outHTML || "
|
|
90
|
+
const OUT_HTML = options.outHTML || tempRootPath("geocode-first-surface.html")
|
|
119
91
|
|
|
120
92
|
const PRIOR = priorWeight(LAMBDA)
|
|
121
93
|
|
package/tools/viz/render.ts
CHANGED
|
@@ -76,7 +76,7 @@ export async function renderPlotlyHTMLToPNG(
|
|
|
76
76
|
on?: (event: string, cb: () => void) => void
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
const doc = (globalThis
|
|
79
|
+
const doc = Reflect.get(globalThis, "document") as { querySelectorAll(s: string): Iterable<unknown> }
|
|
80
80
|
|
|
81
81
|
const divs = [...doc.querySelectorAll("div")]
|
|
82
82
|
.map((d) => d as PlotlyDiv)
|
|
@@ -3,35 +3,18 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Every coordinate Mailwoman resolves to comes from an open dataset, and we keep the provenance on
|
|
9
|
-
* the point. This samples the per-state address-point DB (`address_point.source`) and renders it
|
|
10
|
-
* on the house MapLibre + Protomaps stack via {@link toMapHTML}, each dot COLORED BY its upstream
|
|
11
|
-
* open-data source — the National Address Database (a federal release) vs OpenAddresses (county /
|
|
12
|
-
* municipal open-data publishers). New York is the clean example: NAD blankets the state, and New
|
|
13
|
-
* York City arrives separately from NYC Open Data, so the source split is visible as a
|
|
14
|
-
* geography.
|
|
15
|
-
*
|
|
16
|
-
* No competitor in this space will tell you which open dataset a given coordinate came from — for
|
|
17
|
-
* them the assembled pipeline is the moat. Here the provenance is the point of the map.
|
|
18
|
-
*
|
|
19
|
-
* Streets without a rooftop point are covered by TIGER interpolation (`tiger:edges`), a separate
|
|
20
|
-
* layer not plotted here; this map is the rooftop-point sources only.
|
|
21
|
-
*
|
|
22
|
-
* SERVE THE OUTPUT OVER LOCALHOST (the house tile server CORS-restricts to localhost + the docs
|
|
23
|
-
* domains). e.g. `python3 -m http.server -d <dir>`, or `renderServedMapToPNG` (`./render-map.ts`)
|
|
24
|
-
* against the served URL.
|
|
25
|
-
*
|
|
26
|
-
* Run: `mailwoman registry viz source-provenance-map [--state ny] [--db <address-points-us-XX.db>]
|
|
27
|
-
* [--out-html /tmp/source-provenance.html] [--nad-mod 700] [--oa-mod 120] [--cap 7000]`
|
|
6
|
+
* Sample `address_point.source` rows from a state database and render them by source in MapLibre.
|
|
7
|
+
* The output requires an HTTP origin because the tile server does not serve `file:` origins.
|
|
28
8
|
*/
|
|
29
9
|
|
|
30
10
|
import { writeFileSync } from "node:fs"
|
|
31
11
|
import { DatabaseSync } from "node:sqlite"
|
|
32
12
|
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
13
|
+
import { isPresent } from "@mailwoman/core/objects"
|
|
14
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/utils"
|
|
15
|
+
import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial"
|
|
16
|
+
|
|
17
|
+
import { type MapFeatureData, toMapHTML } from "#index"
|
|
35
18
|
|
|
36
19
|
/**
|
|
37
20
|
* Options for {@linkcode sourceProvenanceMap}.
|
|
@@ -93,7 +76,7 @@ export function sourceProvenanceMap(
|
|
|
93
76
|
): { outHTML: string; points: number } {
|
|
94
77
|
const STATE = (options.state || "ny").toLowerCase()
|
|
95
78
|
const DB = options.db || String(dataRootPath("address-points", `address-points-us-${STATE}.db`))
|
|
96
|
-
const OUT = options.outHTML || "
|
|
79
|
+
const OUT = options.outHTML || tempRootPath("source-provenance.html")
|
|
97
80
|
const NAD_MOD = options.nadMod ?? 700 // keep ~1/700 of NAD points
|
|
98
81
|
const OA_MOD = options.oaMod ?? 120 // keep ~1/120 of OpenAddresses points
|
|
99
82
|
const CAP = options.cap ?? 7000 // per-source marker cap
|
|
@@ -120,14 +103,14 @@ export function sourceProvenanceMap(
|
|
|
120
103
|
|
|
121
104
|
const counts = new Map<string, number>()
|
|
122
105
|
|
|
123
|
-
const features = rows.map((r) => {
|
|
106
|
+
const features: GeoFeature<PointLiteral, MapFeatureData>[] = rows.map((r) => {
|
|
124
107
|
const { bucket, publisher } = categorize(r.source)
|
|
125
108
|
counts.set(bucket, (counts.get(bucket) ?? 0) + 1)
|
|
126
|
-
const addr = [r.number, r.street_raw].filter(
|
|
109
|
+
const addr = [r.number, r.street_raw].filter(isPresent).join(" ").trim()
|
|
127
110
|
|
|
128
111
|
return {
|
|
129
|
-
type: "Feature"
|
|
130
|
-
geometry: { type: "Point"
|
|
112
|
+
type: "Feature",
|
|
113
|
+
geometry: { type: "Point", coordinates: [r.lon, r.lat] },
|
|
131
114
|
properties: {
|
|
132
115
|
bucket,
|
|
133
116
|
sources: [bucket],
|
|
@@ -139,9 +122,9 @@ export function sourceProvenanceMap(
|
|
|
139
122
|
}
|
|
140
123
|
})
|
|
141
124
|
|
|
142
|
-
const geojson = { type: "FeatureCollection"
|
|
125
|
+
const geojson: GeoFeatureCollection<PointLiteral, MapFeatureData> = { type: "FeatureCollection", features }
|
|
143
126
|
|
|
144
|
-
const html = toMapHTML(geojson
|
|
127
|
+
const html = toMapHTML(geojson, {
|
|
145
128
|
title: `Address-point provenance — ${STATE.toUpperCase()}, every point colored by its open-data source`,
|
|
146
129
|
flavor: "light",
|
|
147
130
|
colorBy: "bucket",
|
package/types.ts
CHANGED
|
@@ -81,7 +81,7 @@ export type ReconciliationBucket = "enrolled" | "eligible-not-enrolled" | "funde
|
|
|
81
81
|
|
|
82
82
|
export interface EntityGeoData {
|
|
83
83
|
entityID: string
|
|
84
|
-
|
|
84
|
+
sourceIDs?: string[]
|
|
85
85
|
recordCount?: number
|
|
86
86
|
cohesion?: number | null
|
|
87
87
|
sources: string[]
|
|
@@ -92,4 +92,13 @@ export interface EntityGeoData {
|
|
|
92
92
|
bucket?: ReconciliationBucket
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Feature properties the map renderer consumes — {@link EntityGeoData} with every field optional, plus an unconstrained
|
|
97
|
+
* `bucket`. The renderer assigns a color per DISTINCT bucket value in first-seen order and builds its legend from that
|
|
98
|
+
* set, so a bucket is any categorical label, not only a {@link ReconciliationBucket}; and a collection assembled from
|
|
99
|
+
* something other than resolved entities (raw address points, links read back from a file) carries no entity id or
|
|
100
|
+
* display name.
|
|
101
|
+
*/
|
|
102
|
+
export type MapFeatureData = Partial<Omit<EntityGeoData, "bucket">> & { bucket?: string }
|
|
103
|
+
|
|
95
104
|
//#endregion
|