@mailwoman/registry 9.1.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 +2 -2
- 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} +12 -6
- package/{index.ts → lib/index.ts} +10 -10
- package/{ingest.ts → lib/ingest.ts} +77 -69
- package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
- package/{map-html.ts → lib/map-html.ts} +10 -16
- package/{reconcile.ts → lib/reconcile.ts} +9 -24
- package/{resolve.ts → lib/resolve.ts} +31 -13
- package/{tools → lib/tools}/coverage-reconciliation.ts +13 -15
- package/{tools → lib/tools}/cross-dataset-correlation.ts +64 -139
- package/{tools → lib/tools}/cross-source-threshold-sweep.ts +21 -32
- package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
- package/{tools → lib/tools}/eval-geocoder.ts +10 -11
- package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
- package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +12 -11
- 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 +71 -260
- package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +62 -245
- package/{tools → lib/tools}/learned-scorer-eval.ts +64 -263
- package/{tools → lib/tools}/matcher-scale.ts +5 -5
- package/lib/tools/nppes/org-name.ts +23 -0
- package/lib/tools/nppes/overmerge-packet.ts +94 -0
- package/lib/tools/nppes/report.ts +373 -0
- package/lib/tools/nppes/sample.ts +245 -0
- package/lib/tools/nppes/scoring.ts +114 -0
- package/lib/tools/nppes/settings.ts +102 -0
- package/lib/tools/nppes/truth-grains.ts +161 -0
- package/lib/tools/nppes-dedup-benchmark.ts +408 -0
- package/lib/tools/shared.ts +763 -0
- package/lib/tools/train-cross-gbt.ts +209 -0
- package/{tools → lib/tools}/train-gbt.ts +38 -156
- package/lib/tools/train-org-cross-gbt.ts +179 -0
- package/{tools → lib/tools}/txhhsc-to-oarow.ts +10 -28
- package/lib/tools/viz/browser.ts +50 -0
- package/{tools → lib/tools}/viz/cross-dataset-map.ts +16 -39
- package/{tools → lib/tools}/viz/geocode-first-surface.ts +13 -39
- 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 +20 -39
- package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
- package/{types.ts → lib/types.ts} +10 -1
- 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 +8 -5
- 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 +33 -46
- 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 +4 -4
- 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 +7 -21
- 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 +20 -6
- 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 +12 -12
- 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 +60 -111
- 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 -118
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +9 -13
- 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 +11 -9
- 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 -121
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/index.d.ts +24 -29
- package/out/tools/index.d.ts.map +1 -1
- package/out/tools/index.js +24 -29
- 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 -170
- 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 -173
- 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 +5 -5
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts +21 -0
- package/out/tools/nppes/org-name.d.ts.map +1 -0
- package/out/tools/nppes/org-name.js +13 -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 +186 -0
- package/out/tools/nppes/report.js.map +1 -0
- package/out/tools/nppes/sample.d.ts +90 -0
- package/out/tools/nppes/sample.d.ts.map +1 -0
- package/out/tools/nppes/sample.js +131 -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/settings.d.ts +38 -0
- package/out/tools/nppes/settings.d.ts.map +1 -0
- package/out/tools/nppes/settings.js +79 -0
- package/out/tools/nppes/settings.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 +123 -0
- package/out/tools/nppes/truth-grains.js.map +1 -0
- package/out/tools/nppes-dedup-benchmark.d.ts +7 -3
- package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes-dedup-benchmark.js +106 -673
- 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 +353 -21
- 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 +9 -23
- 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 +4 -25
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +12 -33
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +6 -35
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +10 -37
- 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 +4 -24
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +12 -32
- 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 +11 -1
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/package.json +180 -11
- package/tools/gold-set-sample.ts +0 -252
- package/tools/index.ts +0 -36
- package/tools/nppes-dedup-benchmark.ts +0 -1180
- package/tools/shared.ts +0 -160
- package/tools/train-cross-gbt.ts +0 -358
- package/tools/train-org-cross-gbt.ts +0 -329
- 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
|
@@ -14,30 +14,12 @@
|
|
|
14
14
|
* Run: `mailwoman registry convert tx-hhsc [--src <tsv>] [--out /tmp/txhhsc-oarow.jsonl]`
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
import {
|
|
17
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
|
|
18
|
+
import { readLocalTextFile } from "@mailwoman/core/fs/readers"
|
|
19
|
+
import { writeLocalTextFile } from "@mailwoman/core/fs/writers"
|
|
20
20
|
import { TSVSpliterator } from "spliterator"
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
* Texas bounding box, used to reject rows whose coordinates landed in the wrong state.
|
|
24
|
-
*/
|
|
25
|
-
const TX_MIN_LATITUDE = 25
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* See {@link TX_MIN_LATITUDE}.
|
|
29
|
-
*/
|
|
30
|
-
const TX_MAX_LATITUDE = 37
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* See {@link TX_MIN_LATITUDE}.
|
|
34
|
-
*/
|
|
35
|
-
const TX_MIN_LONGITUDE = -107
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* See {@link TX_MIN_LATITUDE}.
|
|
39
|
-
*/
|
|
40
|
-
const TX_MAX_LONGITUDE = -93
|
|
22
|
+
import { inTXBBOX } from "#tools/shared"
|
|
41
23
|
|
|
42
24
|
/**
|
|
43
25
|
* Options for {@linkcode convertTXHHSC}.
|
|
@@ -58,12 +40,12 @@ const GEO = /^\s*(-?\d+\.\d+)\s*,\s*(-?\d+\.\d+)\s*$/
|
|
|
58
40
|
/**
|
|
59
41
|
* Convert the TX HHSC nursing-facilities TSV into OaRow JSONL for `oa-resolver-eval`.
|
|
60
42
|
*/
|
|
61
|
-
export function convertTXHHSC(
|
|
43
|
+
export async function convertTXHHSC(
|
|
62
44
|
options: TXHHSCConvertOptions = {},
|
|
63
45
|
report?: (line: string) => void
|
|
64
|
-
): { written: number; skipped: number; out: string } {
|
|
46
|
+
): Promise<{ written: number; skipped: number; out: string }> {
|
|
65
47
|
const src = options.src || String(dataRootPath("record-matcher", "sources", "txhhsc_nursing-facilities_20260611.tsv"))
|
|
66
|
-
const out = options.out || "
|
|
48
|
+
const out = options.out || tempRootPath("txhhsc-oarow.jsonl")
|
|
67
49
|
|
|
68
50
|
const records: string[] = []
|
|
69
51
|
let skipped = 0
|
|
@@ -76,7 +58,7 @@ export function convertTXHHSC(
|
|
|
76
58
|
let cGeo = -1
|
|
77
59
|
let sawHeader = false
|
|
78
60
|
|
|
79
|
-
for (const f of TSVSpliterator.from(
|
|
61
|
+
for (const f of TSVSpliterator.from(await readLocalTextFile(src), { header: false })) {
|
|
80
62
|
if (f.every((value) => !value.trim())) continue
|
|
81
63
|
|
|
82
64
|
if (!sawHeader) {
|
|
@@ -105,7 +87,7 @@ export function convertTXHHSC(
|
|
|
105
87
|
const lon = Number(m[2])
|
|
106
88
|
|
|
107
89
|
// Sanity: TX bounding box (rejects swapped/garbage coords).
|
|
108
|
-
if (lat
|
|
90
|
+
if (!inTXBBOX(lat, lon)) {
|
|
109
91
|
skipped++
|
|
110
92
|
|
|
111
93
|
continue
|
|
@@ -123,7 +105,7 @@ export function convertTXHHSC(
|
|
|
123
105
|
)
|
|
124
106
|
}
|
|
125
107
|
|
|
126
|
-
|
|
108
|
+
await writeLocalTextFile(records.join("\n") + "\n", out)
|
|
127
109
|
report?.(`wrote ${records.length} rows (skipped ${skipped}) → ${out}`)
|
|
128
110
|
|
|
129
111
|
return { written: records.length, skipped, out }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The shared headless-Chromium harness behind the `registry viz` renderers (an internal helper,
|
|
7
|
+
* not a command). The WebGL consumers (Plotly 3D, MapLibre) get no GPU in headless Chromium, so
|
|
8
|
+
* the browser launches on ANGLE's SwiftShader software rasterizer (`--use-gl=angle
|
|
9
|
+
* --use-angle=swiftshader --enable-unsafe-swiftshader`); each caller owns its own navigation +
|
|
10
|
+
* wait strategy and screenshots inside the callback.
|
|
11
|
+
*
|
|
12
|
+
* Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported at call time (the
|
|
13
|
+
* corpus-tools lazy-import convention), so importing `@mailwoman/registry/tools` never pays for
|
|
14
|
+
* it.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { Page } from "playwright"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Options for {@linkcode withChromiumPage}.
|
|
21
|
+
*/
|
|
22
|
+
export interface ChromiumPageOptions {
|
|
23
|
+
viewport: { width: number; height: number }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Launch headless Chromium (SwiftShader WebGL), open one page at `deviceScaleFactor: 2`, collect console + page errors,
|
|
28
|
+
* run `fn`, and dispose the browser. The callback owns navigation, waits, and the screenshot.
|
|
29
|
+
*/
|
|
30
|
+
export async function withChromiumPage<T>(
|
|
31
|
+
options: ChromiumPageOptions,
|
|
32
|
+
fn: (page: Page) => Promise<T>
|
|
33
|
+
): Promise<{ result: T; consoleErrors: string[] }> {
|
|
34
|
+
const { chromium } = await import("playwright")
|
|
35
|
+
|
|
36
|
+
const browser = await chromium.launch({
|
|
37
|
+
args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const page = await browser.newPage({ viewport: options.viewport, deviceScaleFactor: 2 })
|
|
41
|
+
|
|
42
|
+
const errors: string[] = []
|
|
43
|
+
page.on("console", (m) => m.type() === "error" && errors.push(m.text()))
|
|
44
|
+
page.on("pageerror", (e) => errors.push(String(e)))
|
|
45
|
+
|
|
46
|
+
const result = await fn(page)
|
|
47
|
+
await browser[Symbol.asyncDispose]()
|
|
48
|
+
|
|
49
|
+
return { result, consoleErrors: errors }
|
|
50
|
+
}
|
|
@@ -3,36 +3,16 @@
|
|
|
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
|
-
import {
|
|
10
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
|
|
11
|
+
import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
|
|
12
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
13
|
+
import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial"
|
|
32
14
|
|
|
33
|
-
import {
|
|
34
|
-
import { dataRootPath } from "@mailwoman/core/utils"
|
|
35
|
-
import { toMapHTML } from "@mailwoman/registry"
|
|
15
|
+
import { type MapFeatureData, toMapHTML } from "#index"
|
|
36
16
|
|
|
37
17
|
/**
|
|
38
18
|
* Distinct agencies a combination needs before it is plotted as a cross-agency cluster.
|
|
@@ -82,24 +62,21 @@ const SOURCE_AGENCY: Record<string, string> = {
|
|
|
82
62
|
|
|
83
63
|
const agencyOf = (s: string) => SOURCE_AGENCY[s] ?? s
|
|
84
64
|
|
|
85
|
-
const sourcesOf = (f:
|
|
86
|
-
Array.isArray(f.properties?.
|
|
65
|
+
const sourcesOf = (f: GeoFeature<PointLiteral, MapFeatureData>): string[] =>
|
|
66
|
+
Array.isArray(f.properties?.sources) ? f.properties.sources : []
|
|
87
67
|
|
|
88
68
|
/**
|
|
89
69
|
* Render the cross-dataset-links GeoJSON to a bucket-colored MapLibre HTML page.
|
|
90
70
|
*/
|
|
91
|
-
export function crossDatasetMap(
|
|
71
|
+
export async function crossDatasetMap(
|
|
92
72
|
options: CrossDatasetMapOptions = {},
|
|
93
73
|
report?: (line: string) => void
|
|
94
|
-
): { outHTML: string; kept: number; total: number; triple: number } {
|
|
74
|
+
): Promise<{ outHTML: string; kept: number; total: number; triple: number }> {
|
|
95
75
|
const IN = options.in || dataRootPath("record-matcher", "2026-06-16-cross-dataset-links.geojson")
|
|
96
|
-
const OUT = options.outHTML || "
|
|
76
|
+
const OUT = options.outHTML || tempRootPath("cross-dataset-map.html")
|
|
97
77
|
const CROSS_AGENCY_ONLY = options.crossAgencyOnly ?? false
|
|
98
78
|
|
|
99
|
-
const parsed =
|
|
100
|
-
type: "FeatureCollection"
|
|
101
|
-
features: Array<{ properties: Record<string, unknown> | null }>
|
|
102
|
-
}>(readFileSync(IN, "utf8"))
|
|
79
|
+
const parsed = await readLocalJSONFile<GeoFeatureCollection<PointLiteral, MapFeatureData>>(IN)
|
|
103
80
|
|
|
104
81
|
const total = parsed.features.length
|
|
105
82
|
|
|
@@ -117,7 +94,7 @@ export function crossDatasetMap(
|
|
|
117
94
|
const bucket = combo.map(label).join(" + ") || "unlinked"
|
|
118
95
|
|
|
119
96
|
if (f.properties) {
|
|
120
|
-
f.properties
|
|
97
|
+
f.properties.bucket = bucket
|
|
121
98
|
}
|
|
122
99
|
|
|
123
100
|
if (new Set(combo.map(agencyOf)).size >= MIN_DISTINCT_AGENCIES) {
|
|
@@ -130,13 +107,13 @@ export function crossDatasetMap(
|
|
|
130
107
|
const kept = geojson.features.length
|
|
131
108
|
const scope = CROSS_AGENCY_ONLY ? "across agencies" : "across sources"
|
|
132
109
|
|
|
133
|
-
const html = toMapHTML(geojson
|
|
110
|
+
const html = toMapHTML(geojson, {
|
|
134
111
|
title: `Cross-dataset entity links — ${kept} resolved ${scope} (no shared key)`,
|
|
135
112
|
flavor: "light",
|
|
136
113
|
colorBy: "bucket",
|
|
137
114
|
})
|
|
138
115
|
|
|
139
|
-
|
|
116
|
+
await writeLocalFile(html, OUT)
|
|
140
117
|
report?.(`[written] ${OUT} (${kept}${CROSS_AGENCY_ONLY ? ` of ${total} cross-AGENCY` : ""} entities)`)
|
|
141
118
|
report?.(` source combinations:`)
|
|
142
119
|
|
|
@@ -3,41 +3,12 @@
|
|
|
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
|
-
import {
|
|
10
|
+
import { tempRootPath } from "@mailwoman/core/data-root"
|
|
11
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
41
12
|
|
|
42
13
|
/**
|
|
43
14
|
* Options for {@linkcode geocodeFirstSurface}.
|
|
@@ -45,7 +16,8 @@ import { writeFileSync } from "node:fs"
|
|
|
45
16
|
export interface GeocodeFirstSurfaceOptions {
|
|
46
17
|
/**
|
|
47
18
|
* Illustrative prior λ. Production's record matcher uses λ=1e-4 (calibrated for the full multi-field model with phone
|
|
48
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* - Spatial exact-key); here we want the boundary visible in a two-axis slice. Default 0.02.
|
|
49
21
|
*/
|
|
50
22
|
lambda?: number
|
|
51
23
|
/**
|
|
@@ -110,12 +82,12 @@ function distanceWeight(km: number): number {
|
|
|
110
82
|
/**
|
|
111
83
|
* Emit the geocode-first decision-surface Plotly HTML — see the module doc.
|
|
112
84
|
*/
|
|
113
|
-
export function geocodeFirstSurface(
|
|
85
|
+
export async function geocodeFirstSurface(
|
|
114
86
|
options: GeocodeFirstSurfaceOptions = {},
|
|
115
87
|
report?: (line: string) => void
|
|
116
|
-
): { outHTML: string } {
|
|
88
|
+
): Promise<{ 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
|
|
|
@@ -199,7 +171,9 @@ export function geocodeFirstSurface(
|
|
|
199
171
|
prior: PRIOR,
|
|
200
172
|
}
|
|
201
173
|
|
|
202
|
-
|
|
174
|
+
// EVERY `<`, not only `</script>`: `<!--` also leaves script-data state in the HTML tokenizer, after which a
|
|
175
|
+
// later `</script>` no longer ends the element. `\u003c` is the same string to a JSON reader.
|
|
176
|
+
const safe = JSON.stringify(data).replaceAll("<", "\\u003c")
|
|
203
177
|
|
|
204
178
|
const html = `<!doctype html><html><head><meta charset="utf-8"/>
|
|
205
179
|
<script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script>
|
|
@@ -305,7 +279,7 @@ document.getElementByID("cap").innerHTML =
|
|
|
305
279
|
</script>
|
|
306
280
|
</body></html>`
|
|
307
281
|
|
|
308
|
-
|
|
282
|
+
await writeLocalFile(html, OUT_HTML)
|
|
309
283
|
report?.(`[written] ${OUT_HTML}`)
|
|
310
284
|
report?.(`λ=${LAMBDA} prior=${PRIOR.toFixed(2)} bits`)
|
|
311
285
|
|
|
@@ -9,20 +9,19 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Two house-stack constraints make this fiddlier than the Plotly/SVG renderers:
|
|
11
11
|
*
|
|
12
|
-
* - MapLibre needs a real WebGL context
|
|
13
|
-
*
|
|
14
|
-
* - The basemap tiles come from `tiles.
|
|
12
|
+
* - MapLibre needs a real WebGL context — the shared harness (`./browser.ts`) provides one through
|
|
13
|
+
* SwiftShader.
|
|
14
|
+
* - The basemap tiles come from `tiles.mailwoman.ai`, which CORS-restricts to localhost + the docs
|
|
15
15
|
* domains — so the page MUST be SERVED OVER LOCALHOST, not opened as a file (a file:// page
|
|
16
16
|
* renders accurate markers on a blank basemap). Serve the output dir first, e.g. `python3 -m
|
|
17
17
|
* http.server 8899 -d <dir>`, then point this at `http://localhost:8899/<page>.html`.
|
|
18
18
|
*
|
|
19
19
|
* The map paints asynchronously after the network settles; we wait for networkidle, then a fixed
|
|
20
20
|
* beat for the basemap tiles + marker layer to finish compositing.
|
|
21
|
-
*
|
|
22
|
-
* Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
|
|
23
|
-
* fn (the corpus-tools lazy-import convention).
|
|
24
21
|
*/
|
|
25
22
|
|
|
23
|
+
import { withChromiumPage } from "#tools/viz/browser"
|
|
24
|
+
|
|
26
25
|
/**
|
|
27
26
|
* Options for {@linkcode renderServedMapToPNG}.
|
|
28
27
|
*/
|
|
@@ -44,25 +43,13 @@ export async function renderServedMapToPNG(
|
|
|
44
43
|
options: RenderMapOptions,
|
|
45
44
|
report?: (line: string) => void
|
|
46
45
|
): Promise<{ outPNG: string; consoleErrors: string[] }> {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const { consoleErrors: errors } = await withChromiumPage({ viewport: { width: 1100, height: 760 } }, async (page) => {
|
|
47
|
+
await page.goto(options.url, { waitUntil: "networkidle", timeout: 30_000 })
|
|
48
|
+
// MapLibre composites tiles + the marker layer async after the network settles; give it a beat.
|
|
49
|
+
await page.waitForTimeout(4000)
|
|
50
|
+
await page.screenshot({ path: options.outPNG })
|
|
52
51
|
})
|
|
53
52
|
|
|
54
|
-
const page = await browser.newPage({ viewport: { width: 1100, height: 760 }, deviceScaleFactor: 2 })
|
|
55
|
-
|
|
56
|
-
const errors: string[] = []
|
|
57
|
-
page.on("console", (m) => m.type() === "error" && errors.push(m.text()))
|
|
58
|
-
page.on("pageerror", (e) => errors.push(String(e)))
|
|
59
|
-
|
|
60
|
-
await page.goto(options.url, { waitUntil: "networkidle", timeout: 30_000 })
|
|
61
|
-
// MapLibre composites tiles + the marker layer async after the network settles; give it a beat.
|
|
62
|
-
await page.waitForTimeout(4000)
|
|
63
|
-
await page.screenshot({ path: options.outPNG })
|
|
64
|
-
await browser.close()
|
|
65
|
-
|
|
66
53
|
report?.(`[map-render] ${options.outPNG}; console errors=${errors.length}`)
|
|
67
54
|
|
|
68
55
|
for (const e of errors.slice(0, 6)) {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Render a self-contained Plotly HTML to a PNG via headless Chromium — the shared renderer behind
|
|
7
|
+
* the `registry viz` figures (an internal helper, not a command).
|
|
8
|
+
*
|
|
9
|
+
* Plotly 3D (`surface`/`scatter3d`) needs a real WebGL context, which the shared harness
|
|
10
|
+
* (`./browser.ts`) provides through SwiftShader; 2D traces (`contour`/`heatmap`) render on the 2D
|
|
11
|
+
* canvas regardless. We wait for Plotly's `plotly_afterplot` to fire on every graph div rather
|
|
12
|
+
* than a fixed sleep, so the screenshot can't race the (async) WebGL paint.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { pathToFileURL } from "@mailwoman/core/module/file-url"
|
|
16
|
+
import { resolvePath as resolve } from "path-ts"
|
|
17
|
+
|
|
18
|
+
import { withChromiumPage } from "#tools/viz/browser"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Options for {@linkcode renderPlotlyHTMLToPNG}.
|
|
22
|
+
*/
|
|
23
|
+
export interface RenderPlotlyOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The self-contained Plotly HTML file.
|
|
26
|
+
*/
|
|
27
|
+
inHTML: string
|
|
28
|
+
/**
|
|
29
|
+
* Output PNG path.
|
|
30
|
+
*/
|
|
31
|
+
outPNG: string
|
|
32
|
+
/**
|
|
33
|
+
* Viewport width. Default 1160.
|
|
34
|
+
*/
|
|
35
|
+
width?: number
|
|
36
|
+
/**
|
|
37
|
+
* Viewport height. Default 1000.
|
|
38
|
+
*/
|
|
39
|
+
height?: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Screenshot a Plotly HTML page after every graph div's `plotly_afterplot` fires.
|
|
44
|
+
*/
|
|
45
|
+
export async function renderPlotlyHTMLToPNG(
|
|
46
|
+
options: RenderPlotlyOptions,
|
|
47
|
+
report?: (line: string) => void
|
|
48
|
+
): Promise<{ outPNG: string; consoleErrors: string[] }> {
|
|
49
|
+
const { consoleErrors: errors } = await withChromiumPage(
|
|
50
|
+
{ viewport: { width: options.width ?? 1160, height: options.height ?? 1000 } },
|
|
51
|
+
async (page) => {
|
|
52
|
+
await page.goto(pathToFileURL(resolve(options.inHTML)).href, { waitUntil: "networkidle" })
|
|
53
|
+
|
|
54
|
+
// Resolve once every Plotly graph div has fired plotly_afterplot (3D paints land async, after
|
|
55
|
+
// newPlot's promise resolves), with a per-div fallback so an already-painted div can't hang us.
|
|
56
|
+
await page.evaluate(async () => {
|
|
57
|
+
// Runs in the BROWSER — reach DOM/Plotly globals via globalThis so the script needs no DOM lib.
|
|
58
|
+
interface PlotlyDiv {
|
|
59
|
+
_fullLayout?: unknown
|
|
60
|
+
on?: (event: string, cb: () => void) => void
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const doc = Reflect.get(globalThis, "document") as { querySelectorAll(s: string): Iterable<unknown> }
|
|
64
|
+
|
|
65
|
+
const divs = [...doc.querySelectorAll("div")]
|
|
66
|
+
.map((d) => d as PlotlyDiv)
|
|
67
|
+
.filter((d) => d._fullLayout && typeof d.on === "function")
|
|
68
|
+
|
|
69
|
+
await Promise.all(
|
|
70
|
+
divs.map(
|
|
71
|
+
(d) =>
|
|
72
|
+
new Promise<void>((res) => {
|
|
73
|
+
d.on!("plotly_afterplot", () => res())
|
|
74
|
+
setTimeout(() => res(), 2000)
|
|
75
|
+
})
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// Final settle for the software WebGL rasterizer.
|
|
81
|
+
await page.waitForTimeout(800)
|
|
82
|
+
|
|
83
|
+
await page.screenshot({ path: resolve(options.outPNG), fullPage: true })
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if (errors.length) {
|
|
88
|
+
report?.(`[render] ${errors.length} console error(s):`)
|
|
89
|
+
|
|
90
|
+
for (const e of errors.slice(0, 8)) {
|
|
91
|
+
report?.(" " + e)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
report?.(`[render] ${options.outPNG}`)
|
|
96
|
+
|
|
97
|
+
return { outPNG: options.outPNG, consoleErrors: errors }
|
|
98
|
+
}
|
|
@@ -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
|
-
import {
|
|
31
|
-
import {
|
|
10
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
|
|
11
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
12
|
+
import { isPresent } from "@mailwoman/core/objects"
|
|
13
|
+
import type { AddressPointDatabase } from "@mailwoman/resolver-wof-sqlite/address"
|
|
14
|
+
import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial"
|
|
15
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
32
16
|
|
|
33
|
-
import {
|
|
34
|
-
import { toMapHTML } from "@mailwoman/registry"
|
|
17
|
+
import { type MapFeatureData, toMapHTML } from "#index"
|
|
35
18
|
|
|
36
19
|
/**
|
|
37
20
|
* Options for {@linkcode sourceProvenanceMap}.
|
|
@@ -87,18 +70,18 @@ type Row = { lat: number; lon: number; source: string; number: string | null; st
|
|
|
87
70
|
/**
|
|
88
71
|
* Render the per-state address-point provenance map — see the module doc.
|
|
89
72
|
*/
|
|
90
|
-
export function sourceProvenanceMap(
|
|
73
|
+
export async function sourceProvenanceMap(
|
|
91
74
|
options: SourceProvenanceMapOptions = {},
|
|
92
75
|
report?: (line: string) => void
|
|
93
|
-
): { outHTML: string; points: number } {
|
|
76
|
+
): Promise<{ 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
|
|
100
83
|
|
|
101
|
-
|
|
84
|
+
using db = new DatabaseClient<AddressPointDatabase>(DB, { readOnly: true })
|
|
102
85
|
|
|
103
86
|
// Two stratified samples so the smaller source (OpenAddresses, ~1/6 of NY) stays visible next to NAD.
|
|
104
87
|
// abs(random()) % mod == 0 keeps a spatially-uniform ~1/mod fraction; LIMIT caps the marker count.
|
|
@@ -116,18 +99,16 @@ export function sourceProvenanceMap(
|
|
|
116
99
|
...sample("source LIKE 'overture:OpenAddresses%'", OA_MOD),
|
|
117
100
|
]
|
|
118
101
|
|
|
119
|
-
db.close()
|
|
120
|
-
|
|
121
102
|
const counts = new Map<string, number>()
|
|
122
103
|
|
|
123
|
-
const features = rows.map((r) => {
|
|
104
|
+
const features: GeoFeature<PointLiteral, MapFeatureData>[] = rows.map((r) => {
|
|
124
105
|
const { bucket, publisher } = categorize(r.source)
|
|
125
106
|
counts.set(bucket, (counts.get(bucket) ?? 0) + 1)
|
|
126
|
-
const addr = [r.number, r.street_raw].filter(
|
|
107
|
+
const addr = [r.number, r.street_raw].filter(isPresent).join(" ").trim()
|
|
127
108
|
|
|
128
109
|
return {
|
|
129
|
-
type: "Feature"
|
|
130
|
-
geometry: { type: "Point"
|
|
110
|
+
type: "Feature",
|
|
111
|
+
geometry: { type: "Point", coordinates: [r.lon, r.lat] },
|
|
131
112
|
properties: {
|
|
132
113
|
bucket,
|
|
133
114
|
sources: [bucket],
|
|
@@ -139,15 +120,15 @@ export function sourceProvenanceMap(
|
|
|
139
120
|
}
|
|
140
121
|
})
|
|
141
122
|
|
|
142
|
-
const geojson = { type: "FeatureCollection"
|
|
123
|
+
const geojson: GeoFeatureCollection<PointLiteral, MapFeatureData> = { type: "FeatureCollection", features }
|
|
143
124
|
|
|
144
|
-
const html = toMapHTML(geojson
|
|
125
|
+
const html = toMapHTML(geojson, {
|
|
145
126
|
title: `Address-point provenance — ${STATE.toUpperCase()}, every point colored by its open-data source`,
|
|
146
127
|
flavor: "light",
|
|
147
128
|
colorBy: "bucket",
|
|
148
129
|
})
|
|
149
130
|
|
|
150
|
-
|
|
131
|
+
await writeLocalFile(html, OUT)
|
|
151
132
|
report?.(`[written] ${OUT} (${features.length} points)`)
|
|
152
133
|
|
|
153
134
|
for (const [bucket, n] of [...counts.entries()].toSorted((a, b) => b[1] - a[1])) {
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
* [--out-svg docs/records/evals/charts/dedup-yardstick.svg]`
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import {
|
|
27
|
+
import { writeLocalTextFile } from "@mailwoman/core/fs/writers"
|
|
28
|
+
import { escapeHTML } from "@mailwoman/core/strings/escape"
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Options for {@linkcode yardstickFigure}.
|
|
@@ -93,15 +94,15 @@ const MODELS = [
|
|
|
93
94
|
{ key: "FS", label: "FS full stack", color: "#9ca3af", width: 2, dash: "5 4" },
|
|
94
95
|
]
|
|
95
96
|
|
|
96
|
-
const esc =
|
|
97
|
+
const esc = escapeHTML
|
|
97
98
|
|
|
98
99
|
/**
|
|
99
100
|
* Emit the dedup-yardstick slope chart as a self-contained SVG — see the module doc.
|
|
100
101
|
*/
|
|
101
|
-
export function yardstickFigure(
|
|
102
|
+
export async function yardstickFigure(
|
|
102
103
|
options: YardstickFigureOptions = {},
|
|
103
104
|
report?: (line: string) => void
|
|
104
|
-
): { outSVG: string } {
|
|
105
|
+
): Promise<{ outSVG: string }> {
|
|
105
106
|
const OUT = options.outSVG || "docs/records/evals/charts/dedup-yardstick.svg"
|
|
106
107
|
|
|
107
108
|
const parts: string[] = []
|
|
@@ -220,7 +221,7 @@ export function yardstickFigure(
|
|
|
220
221
|
|
|
221
222
|
push(`</svg>`)
|
|
222
223
|
|
|
223
|
-
|
|
224
|
+
await writeLocalTextFile(parts.join(""), OUT)
|
|
224
225
|
report?.(`[written] ${OUT}`)
|
|
225
226
|
|
|
226
227
|
report?.(
|
|
@@ -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
|
package/out/address-key.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { type PostalAddressID } from "@mailwoman/address-id";
|
|
17
17
|
import { type BlockingKey } from "@mailwoman/match";
|
|
18
|
-
import type { SourceRecord } from "
|
|
18
|
+
import type { SourceRecord } from "#types";
|
|
19
19
|
/**
|
|
20
20
|
* The stable address primary key for a record, or null when it isn't geocoded (no coordinate → no locality cell) or
|
|
21
21
|
* carries no raw address to hash. Uses the resolved coordinate + the raw address; the state prefix is plucked from the
|
package/out/address-key.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-key.d.ts","sourceRoot":"","sources":["../address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,kBAAkB,CAAA;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"address-key.d.ts","sourceRoot":"","sources":["../lib/address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,kBAAkB,CAAA;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,GAAG,IAAI,CAO5E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAAC,YAAY,CAAC,CAEhE"}
|