@mailwoman/registry 9.2.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/{address-key.ts → lib/address-key.ts} +1 -1
- package/{geocode-handler.ts → lib/geocode-handler.ts} +7 -7
- package/{geojson.ts → lib/geojson.ts} +9 -4
- package/{index.ts → lib/index.ts} +10 -10
- package/{ingest.ts → lib/ingest.ts} +75 -68
- package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
- package/{map-html.ts → lib/map-html.ts} +7 -13
- package/{reconcile.ts → lib/reconcile.ts} +7 -23
- package/{resolve.ts → lib/resolve.ts} +25 -12
- package/{tools → lib/tools}/coverage-reconciliation.ts +12 -14
- package/{tools → lib/tools}/cross-dataset-correlation.ts +60 -137
- package/{tools → lib/tools}/cross-source-threshold-sweep.ts +20 -31
- package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
- package/{tools → lib/tools}/eval-geocoder.ts +9 -10
- package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
- package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +9 -10
- package/lib/tools/gold-set-sample.ts +141 -0
- package/lib/tools/index.ts +31 -0
- package/{tools → lib/tools}/learned-scorer-clustering-eval.ts +68 -257
- package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +60 -243
- package/{tools → lib/tools}/learned-scorer-eval.ts +62 -256
- package/{tools → lib/tools}/matcher-scale.ts +4 -5
- package/lib/tools/nppes/org-name.ts +23 -0
- package/{tools → lib/tools}/nppes/overmerge-packet.ts +5 -7
- package/{tools → lib/tools}/nppes/report.ts +22 -25
- package/{tools → lib/tools}/nppes/sample.ts +80 -32
- package/{tools/nppes/levers.ts → lib/tools/nppes/settings.ts} +10 -10
- package/{tools → lib/tools}/nppes/truth-grains.ts +4 -44
- package/{tools → lib/tools}/nppes-dedup-benchmark.ts +42 -38
- package/lib/tools/shared.ts +763 -0
- package/lib/tools/train-cross-gbt.ts +209 -0
- package/{tools → lib/tools}/train-gbt.ts +35 -154
- package/lib/tools/train-org-cross-gbt.ts +179 -0
- package/{tools → lib/tools}/txhhsc-to-oarow.ts +9 -27
- package/lib/tools/viz/browser.ts +50 -0
- package/{tools → lib/tools}/viz/cross-dataset-map.ts +7 -8
- package/{tools → lib/tools}/viz/geocode-first-surface.ts +10 -8
- package/{tools → lib/tools}/viz/render-map.ts +10 -23
- package/lib/tools/viz/render.ts +98 -0
- package/{tools → lib/tools}/viz/source-provenance-map.ts +8 -10
- package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
- package/out/address-key.d.ts +1 -1
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +6 -6
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +6 -6
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +7 -2
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +5 -3
- package/out/geojson.js.map +1 -1
- package/out/index.d.ts +10 -10
- package/out/index.d.ts.map +1 -1
- package/out/index.js +10 -10
- package/out/index.js.map +1 -1
- package/out/ingest.d.ts +64 -46
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +31 -45
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +1 -1
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +3 -3
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +6 -11
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts +6 -1
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +5 -20
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +19 -7
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +16 -5
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.d.ts +1 -1
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +11 -11
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross-dataset-correlation.d.ts +4 -4
- package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross-dataset-correlation.js +57 -109
- package/out/tools/cross-dataset-correlation.js.map +1 -1
- package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
- package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
- package/out/tools/cross-source-threshold-sweep.js +19 -27
- package/out/tools/cross-source-threshold-sweep.js.map +1 -1
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +36 -117
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +8 -12
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +2 -2
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder-namesake-probe.d.ts +2 -2
- package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
- package/out/tools/geocoder-namesake-probe.js +4 -8
- package/out/tools/geocoder-namesake-probe.js.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.js +8 -7
- package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts +5 -5
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +37 -122
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/index.d.ts +23 -23
- package/out/tools/index.d.ts.map +1 -1
- package/out/tools/index.js +23 -23
- package/out/tools/index.js.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.js +35 -169
- package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
- package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.js +44 -166
- package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
- package/out/tools/learned-scorer-eval.d.ts +1 -1
- package/out/tools/learned-scorer-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-eval.js +37 -168
- package/out/tools/learned-scorer-eval.js.map +1 -1
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +4 -4
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts +2 -5
- package/out/tools/nppes/org-name.d.ts.map +1 -1
- package/out/tools/nppes/org-name.js +1 -30
- package/out/tools/nppes/org-name.js.map +1 -1
- package/out/tools/nppes/overmerge-packet.d.ts +3 -3
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
- package/out/tools/nppes/overmerge-packet.js +3 -3
- package/out/tools/nppes/overmerge-packet.js.map +1 -1
- package/out/tools/nppes/report.d.ts +5 -5
- package/out/tools/nppes/report.d.ts.map +1 -1
- package/out/tools/nppes/report.js +17 -19
- package/out/tools/nppes/report.js.map +1 -1
- package/out/tools/nppes/sample.d.ts +32 -6
- package/out/tools/nppes/sample.d.ts.map +1 -1
- package/out/tools/nppes/sample.js +44 -26
- package/out/tools/nppes/sample.js.map +1 -1
- package/out/tools/nppes/scoring.d.ts.map +1 -1
- package/out/tools/nppes/scoring.js.map +1 -1
- package/out/tools/nppes/{levers.d.ts → settings.d.ts} +8 -8
- package/out/tools/nppes/settings.d.ts.map +1 -0
- package/out/tools/nppes/{levers.js → settings.js} +8 -8
- package/out/tools/nppes/settings.js.map +1 -0
- package/out/tools/nppes/truth-grains.d.ts +2 -2
- package/out/tools/nppes/truth-grains.d.ts.map +1 -1
- package/out/tools/nppes/truth-grains.js +4 -29
- package/out/tools/nppes/truth-grains.js.map +1 -1
- package/out/tools/nppes-dedup-benchmark.d.ts +4 -4
- package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes-dedup-benchmark.js +40 -34
- package/out/tools/nppes-dedup-benchmark.js.map +1 -1
- package/out/tools/shared.d.ts +244 -7
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +349 -18
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train-cross-gbt.d.ts +7 -7
- package/out/tools/train-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-cross-gbt.js +47 -145
- package/out/tools/train-cross-gbt.js.map +1 -1
- package/out/tools/train-gbt.d.ts +7 -7
- package/out/tools/train-gbt.d.ts.map +1 -1
- package/out/tools/train-gbt.js +31 -111
- package/out/tools/train-gbt.js.map +1 -1
- package/out/tools/train-org-cross-gbt.d.ts +7 -5
- package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-org-cross-gbt.js +45 -141
- package/out/tools/train-org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.d.ts +2 -2
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +8 -22
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +34 -0
- package/out/tools/viz/browser.d.ts.map +1 -0
- package/out/tools/viz/browser.js +33 -0
- package/out/tools/viz/browser.js.map +1 -0
- package/out/tools/viz/cross-dataset-map.d.ts +2 -2
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +6 -6
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +4 -3
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +7 -5
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render-map.d.ts +3 -6
- package/out/tools/viz/render-map.d.ts.map +1 -1
- package/out/tools/viz/render-map.js +9 -19
- package/out/tools/viz/render-map.js.map +1 -1
- package/out/tools/viz/render.d.ts +4 -9
- package/out/tools/viz/render.d.ts.map +1 -1
- package/out/tools/viz/render.js +24 -39
- package/out/tools/viz/render.js.map +1 -1
- package/out/tools/viz/source-provenance-map.d.ts +2 -2
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +6 -7
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +2 -2
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +5 -4
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/package.json +115 -15
- package/out/tools/nppes/levers.d.ts.map +0 -1
- package/out/tools/nppes/levers.js.map +0 -1
- package/tools/gold-set-sample.ts +0 -254
- package/tools/index.ts +0 -31
- package/tools/nppes/org-name.ts +0 -56
- package/tools/shared.ts +0 -162
- package/tools/train-cross-gbt.ts +0 -359
- package/tools/train-org-cross-gbt.ts +0 -330
- package/tools/viz/render.ts +0 -113
- /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
- /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
- /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
- /package/{tools → lib/tools}/nppes/scoring.ts +0 -0
- /package/{types.ts → lib/types.ts} +0 -0
|
@@ -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,10 +40,10 @@ 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
48
|
const out = options.out || tempRootPath("txhhsc-oarow.jsonl")
|
|
67
49
|
|
|
@@ -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
|
+
}
|
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
* `crossAgencyOnly` removes links whose sources belong to one agency.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import { dataRootPath, tempRootPath } from "@mailwoman/core/utils"
|
|
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"
|
|
14
13
|
import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial"
|
|
15
14
|
|
|
16
15
|
import { type MapFeatureData, toMapHTML } from "#index"
|
|
@@ -69,15 +68,15 @@ const sourcesOf = (f: GeoFeature<PointLiteral, MapFeatureData>): string[] =>
|
|
|
69
68
|
/**
|
|
70
69
|
* Render the cross-dataset-links GeoJSON to a bucket-colored MapLibre HTML page.
|
|
71
70
|
*/
|
|
72
|
-
export function crossDatasetMap(
|
|
71
|
+
export async function crossDatasetMap(
|
|
73
72
|
options: CrossDatasetMapOptions = {},
|
|
74
73
|
report?: (line: string) => void
|
|
75
|
-
): { outHTML: string; kept: number; total: number; triple: number } {
|
|
74
|
+
): Promise<{ outHTML: string; kept: number; total: number; triple: number }> {
|
|
76
75
|
const IN = options.in || dataRootPath("record-matcher", "2026-06-16-cross-dataset-links.geojson")
|
|
77
76
|
const OUT = options.outHTML || tempRootPath("cross-dataset-map.html")
|
|
78
77
|
const CROSS_AGENCY_ONLY = options.crossAgencyOnly ?? false
|
|
79
78
|
|
|
80
|
-
const parsed =
|
|
79
|
+
const parsed = await readLocalJSONFile<GeoFeatureCollection<PointLiteral, MapFeatureData>>(IN)
|
|
81
80
|
|
|
82
81
|
const total = parsed.features.length
|
|
83
82
|
|
|
@@ -114,7 +113,7 @@ export function crossDatasetMap(
|
|
|
114
113
|
colorBy: "bucket",
|
|
115
114
|
})
|
|
116
115
|
|
|
117
|
-
|
|
116
|
+
await writeLocalFile(html, OUT)
|
|
118
117
|
report?.(`[written] ${OUT} (${kept}${CROSS_AGENCY_ONLY ? ` of ${total} cross-AGENCY` : ""} entities)`)
|
|
119
118
|
report?.(` source combinations:`)
|
|
120
119
|
|
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
* Fellegi-Sunter weights. The supplied prior is illustrative and the output is self-contained HTML.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import { tempRootPath } from "@mailwoman/core/utils"
|
|
10
|
+
import { tempRootPath } from "@mailwoman/core/data-root"
|
|
11
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Options for {@linkcode geocodeFirstSurface}.
|
|
@@ -17,7 +16,8 @@ import { tempRootPath } from "@mailwoman/core/utils"
|
|
|
17
16
|
export interface GeocodeFirstSurfaceOptions {
|
|
18
17
|
/**
|
|
19
18
|
* Illustrative prior λ. Production's record matcher uses λ=1e-4 (calibrated for the full multi-field model with phone
|
|
20
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* - Spatial exact-key); here we want the boundary visible in a two-axis slice. Default 0.02.
|
|
21
21
|
*/
|
|
22
22
|
lambda?: number
|
|
23
23
|
/**
|
|
@@ -82,10 +82,10 @@ function distanceWeight(km: number): number {
|
|
|
82
82
|
/**
|
|
83
83
|
* Emit the geocode-first decision-surface Plotly HTML — see the module doc.
|
|
84
84
|
*/
|
|
85
|
-
export function geocodeFirstSurface(
|
|
85
|
+
export async function geocodeFirstSurface(
|
|
86
86
|
options: GeocodeFirstSurfaceOptions = {},
|
|
87
87
|
report?: (line: string) => void
|
|
88
|
-
): { outHTML: string } {
|
|
88
|
+
): Promise<{ outHTML: string }> {
|
|
89
89
|
const LAMBDA = options.lambda ?? 0.02
|
|
90
90
|
const OUT_HTML = options.outHTML || tempRootPath("geocode-first-surface.html")
|
|
91
91
|
|
|
@@ -171,7 +171,9 @@ export function geocodeFirstSurface(
|
|
|
171
171
|
prior: PRIOR,
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
|
|
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")
|
|
175
177
|
|
|
176
178
|
const html = `<!doctype html><html><head><meta charset="utf-8"/>
|
|
177
179
|
<script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script>
|
|
@@ -277,7 +279,7 @@ document.getElementByID("cap").innerHTML =
|
|
|
277
279
|
</script>
|
|
278
280
|
</body></html>`
|
|
279
281
|
|
|
280
|
-
|
|
282
|
+
await writeLocalFile(html, OUT_HTML)
|
|
281
283
|
report?.(`[written] ${OUT_HTML}`)
|
|
282
284
|
report?.(`λ=${LAMBDA} prior=${PRIOR.toFixed(2)} bits`)
|
|
283
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
|
+
}
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* The output requires an HTTP origin because the tile server does not serve `file:` origins.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
10
|
+
import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
|
|
11
|
+
import { writeLocalFile } from "@mailwoman/core/fs/writers"
|
|
13
12
|
import { isPresent } from "@mailwoman/core/objects"
|
|
14
|
-
import {
|
|
13
|
+
import type { AddressPointDatabase } from "@mailwoman/resolver-wof-sqlite/address"
|
|
15
14
|
import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial"
|
|
15
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
16
16
|
|
|
17
17
|
import { type MapFeatureData, toMapHTML } from "#index"
|
|
18
18
|
|
|
@@ -70,10 +70,10 @@ type Row = { lat: number; lon: number; source: string; number: string | null; st
|
|
|
70
70
|
/**
|
|
71
71
|
* Render the per-state address-point provenance map — see the module doc.
|
|
72
72
|
*/
|
|
73
|
-
export function sourceProvenanceMap(
|
|
73
|
+
export async function sourceProvenanceMap(
|
|
74
74
|
options: SourceProvenanceMapOptions = {},
|
|
75
75
|
report?: (line: string) => void
|
|
76
|
-
): { outHTML: string; points: number } {
|
|
76
|
+
): Promise<{ outHTML: string; points: number }> {
|
|
77
77
|
const STATE = (options.state || "ny").toLowerCase()
|
|
78
78
|
const DB = options.db || String(dataRootPath("address-points", `address-points-us-${STATE}.db`))
|
|
79
79
|
const OUT = options.outHTML || tempRootPath("source-provenance.html")
|
|
@@ -81,7 +81,7 @@ export function sourceProvenanceMap(
|
|
|
81
81
|
const OA_MOD = options.oaMod ?? 120 // keep ~1/120 of OpenAddresses points
|
|
82
82
|
const CAP = options.cap ?? 7000 // per-source marker cap
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
using db = new DatabaseClient<AddressPointDatabase>(DB, { readOnly: true })
|
|
85
85
|
|
|
86
86
|
// Two stratified samples so the smaller source (OpenAddresses, ~1/6 of NY) stays visible next to NAD.
|
|
87
87
|
// abs(random()) % mod == 0 keeps a spatially-uniform ~1/mod fraction; LIMIT caps the marker count.
|
|
@@ -99,8 +99,6 @@ export function sourceProvenanceMap(
|
|
|
99
99
|
...sample("source LIKE 'overture:OpenAddresses%'", OA_MOD),
|
|
100
100
|
]
|
|
101
101
|
|
|
102
|
-
db.close()
|
|
103
|
-
|
|
104
102
|
const counts = new Map<string, number>()
|
|
105
103
|
|
|
106
104
|
const features: GeoFeature<PointLiteral, MapFeatureData>[] = rows.map((r) => {
|
|
@@ -130,7 +128,7 @@ export function sourceProvenanceMap(
|
|
|
130
128
|
colorBy: "bucket",
|
|
131
129
|
})
|
|
132
130
|
|
|
133
|
-
|
|
131
|
+
await writeLocalFile(html, OUT)
|
|
134
132
|
report?.(`[written] ${OUT} (${features.length} points)`)
|
|
135
133
|
|
|
136
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?.(
|
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"}
|
package/out/address-key.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-key.js","sourceRoot":"","sources":["../address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,qBAAqB,EAAwB,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAI7D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IACnD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAA;IACtD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,CAAA;IAEnC,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAExC,OAAO,qBAAqB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAA;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;AACrD,CAAC"}
|
|
1
|
+
{"version":3,"file":"address-key.js","sourceRoot":"","sources":["../lib/address-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,qBAAqB,EAAwB,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAI7D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IACnD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAA;IACtD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,CAAA;IAEnC,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAExC,OAAO,qBAAqB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAA;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;AACrD,CAAC"}
|
package/out/geocode-handler.d.ts
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* The per-record geocode step, factored out of the worker so it unit-tests against a fake
|
|
7
|
-
* neural model / SQLite). `geocode-worker.ts` builds the real
|
|
6
|
+
* The per-record geocode step, factored out of the worker so it unit-tests against a fake geocoder (no
|
|
7
|
+
* neural model / SQLite). `geocode-worker.ts` builds the real geocoder from config and wraps this.
|
|
8
8
|
*/
|
|
9
|
-
import { type ColumnMapping, type GeocodeAddress } from "
|
|
10
|
-
import type { SourceRecord } from "
|
|
9
|
+
import { type ColumnMapping, type GeocodeAddress } from "#ingest";
|
|
10
|
+
import type { SourceRecord } from "#types";
|
|
11
11
|
/**
|
|
12
12
|
* Build the handler `geocodeStream` runs per normalized record: recompute the joined address string from `record.raw` +
|
|
13
|
-
* `mapping.address` (the worker can't receive the original closure), geocode it via `
|
|
13
|
+
* `mapping.address` (the worker can't receive the original closure), geocode it via `geocode`, and attach the result.
|
|
14
14
|
* Records with no mapped address pass through untouched (no geocode call). The default separator matches
|
|
15
15
|
* {@link ingestRow}'s `addressSeparator`.
|
|
16
16
|
*/
|
|
17
|
-
export declare function makeGeocodeHandler(
|
|
17
|
+
export declare function makeGeocodeHandler(geocode: GeocodeAddress, mapping: ColumnMapping, addressSeparator?: string): (record: SourceRecord) => Promise<SourceRecord>;
|
|
18
18
|
//# sourceMappingURL=geocode-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocode-handler.d.ts","sourceRoot":"","sources":["../geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"geocode-handler.d.ts","sourceRoot":"","sources":["../lib/geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAQ,MAAM,SAAS,CAAA;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,aAAa,EACtB,gBAAgB,SAAO,GACrB,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAYjD"}
|
package/out/geocode-handler.js
CHANGED
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* The per-record geocode step, factored out of the worker so it unit-tests against a fake
|
|
7
|
-
* neural model / SQLite). `geocode-worker.ts` builds the real
|
|
6
|
+
* The per-record geocode step, factored out of the worker so it unit-tests against a fake geocoder (no
|
|
7
|
+
* neural model / SQLite). `geocode-worker.ts` builds the real geocoder from config and wraps this.
|
|
8
8
|
*/
|
|
9
|
-
import { pick } from "
|
|
9
|
+
import { pick } from "#ingest";
|
|
10
10
|
/**
|
|
11
11
|
* Build the handler `geocodeStream` runs per normalized record: recompute the joined address string from `record.raw` +
|
|
12
|
-
* `mapping.address` (the worker can't receive the original closure), geocode it via `
|
|
12
|
+
* `mapping.address` (the worker can't receive the original closure), geocode it via `geocode`, and attach the result.
|
|
13
13
|
* Records with no mapped address pass through untouched (no geocode call). The default separator matches
|
|
14
14
|
* {@link ingestRow}'s `addressSeparator`.
|
|
15
15
|
*/
|
|
16
|
-
export function makeGeocodeHandler(
|
|
16
|
+
export function makeGeocodeHandler(geocode, mapping, addressSeparator = ", ") {
|
|
17
17
|
return async (record) => {
|
|
18
18
|
if (!record.raw)
|
|
19
19
|
return record;
|
|
20
20
|
const addressValue = pick(record.raw, mapping.address, addressSeparator);
|
|
21
21
|
if (!addressValue)
|
|
22
22
|
return record;
|
|
23
|
-
const address = (await
|
|
23
|
+
const address = (await geocode(addressValue)) ?? undefined;
|
|
24
24
|
return { ...record, address };
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocode-handler.js","sourceRoot":"","sources":["../geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA2C,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"geocode-handler.js","sourceRoot":"","sources":["../lib/geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA2C,IAAI,EAAE,MAAM,SAAS,CAAA;AAGvE;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CACjC,OAAuB,EACvB,OAAsB,EACtB,gBAAgB,GAAG,IAAI;IAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG;YAAE,OAAO,MAAM,CAAA;QAE9B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;QAExE,IAAI,CAAC,YAAY;YAAE,OAAO,MAAM,CAAA;QAEhC,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,SAAS,CAAA;QAE1D,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAA;IAC9B,CAAC,CAAA;AACF,CAAC"}
|
package/out/geojson.d.ts
CHANGED
|
@@ -9,8 +9,13 @@
|
|
|
9
9
|
* (so rooftop-precise entities can be styled apart from admin-centroid guesses). Entities without
|
|
10
10
|
* a coordinate are omitted (a Point feature needs one).
|
|
11
11
|
*/
|
|
12
|
-
import type { GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial";
|
|
13
|
-
import type { EntityGeoData, ResolvedEntity } from "
|
|
12
|
+
import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial";
|
|
13
|
+
import type { EntityGeoData, ResolvedEntity } from "#types";
|
|
14
|
+
/**
|
|
15
|
+
* One entity → one GeoJSON Point feature. `extra` merges over (and may override) the standard properties — the
|
|
16
|
+
* reconciliation flow adds its `bucket` and swaps the display name for the representative's org-or-person form.
|
|
17
|
+
*/
|
|
18
|
+
export declare function toFeature(entity: ResolvedEntity, extra?: Partial<EntityGeoData>): GeoFeature<PointLiteral, EntityGeoData>;
|
|
14
19
|
/**
|
|
15
20
|
* Convert resolved entities into a GeoJSON `FeatureCollection` of points, ready for QGIS. Entities with no resolved
|
|
16
21
|
* coordinate are skipped.
|
package/out/geojson.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson.d.ts","sourceRoot":"","sources":["../geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"geojson.d.ts","sourceRoot":"","sources":["../lib/geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAExF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,QAAQ,CAAA;AAkBzE;;;GAGG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,cAAc,EACtB,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,UAAU,CAAC,YAAY,EAAE,aAAa,CAAC,CAwBzC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAKhH"}
|
package/out/geojson.js
CHANGED
|
@@ -24,9 +24,10 @@ function displayName(record) {
|
|
|
24
24
|
return joined || null;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* One entity → one GeoJSON Point feature.
|
|
27
|
+
* One entity → one GeoJSON Point feature. `extra` merges over (and may override) the standard properties — the
|
|
28
|
+
* reconciliation flow adds its `bucket` and swaps the display name for the representative's org-or-person form.
|
|
28
29
|
*/
|
|
29
|
-
function toFeature(entity) {
|
|
30
|
+
export function toFeature(entity, extra) {
|
|
30
31
|
const rep = entity.representative;
|
|
31
32
|
return {
|
|
32
33
|
type: "Feature",
|
|
@@ -46,6 +47,7 @@ function toFeature(entity) {
|
|
|
46
47
|
organization: rep.organization?.canonical ?? null,
|
|
47
48
|
address: rep.address?.formatted ?? null,
|
|
48
49
|
geocodeTier: rep.address?.geocode?.tier ?? null,
|
|
50
|
+
...extra,
|
|
49
51
|
},
|
|
50
52
|
};
|
|
51
53
|
}
|
|
@@ -56,7 +58,7 @@ function toFeature(entity) {
|
|
|
56
58
|
export function toGeoJSON(entities) {
|
|
57
59
|
return {
|
|
58
60
|
type: "FeatureCollection",
|
|
59
|
-
features: entities.filter((entity) => entity.coordinate).map(toFeature),
|
|
61
|
+
features: entities.filter((entity) => entity.coordinate).map((entity) => toFeature(entity)),
|
|
60
62
|
};
|
|
61
63
|
}
|
|
62
64
|
//# sourceMappingURL=geojson.js.map
|
package/out/geojson.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson.js","sourceRoot":"","sources":["../geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKnD;;GAEG;AACH,SAAS,WAAW,CAAC,MAAoB;IACxC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IAExB,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;SAClG,MAAM,CAAC,SAAS,CAAC;SACjB,IAAI,CAAC,GAAG,CAAC;SACT,IAAI,EAAE,CAAA;IAER,OAAO,MAAM,IAAI,IAAI,CAAA;AACtB,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"geojson.js","sourceRoot":"","sources":["../lib/geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKnD;;GAEG;AACH,SAAS,WAAW,CAAC,MAAoB;IACxC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IAExB,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;SAClG,MAAM,CAAC,SAAS,CAAC;SACjB,IAAI,CAAC,GAAG,CAAC;SACT,IAAI,EAAE,CAAA;IAER,OAAO,MAAM,IAAI,IAAI,CAAA;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CACxB,MAAsB,EACtB,KAA8B;IAE9B,MAAM,GAAG,GAAG,MAAM,CAAC,cAAc,CAAA;IAEjC,OAAO;QACN,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,SAAS,EAAE,iCAAiC;QAChD,QAAQ,EAAE;YACT,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,CAAC,MAAM,CAAC,UAAW,CAAC,SAAS,EAAE,MAAM,CAAC,UAAW,CAAC,QAAQ,CAAC;SACxE;QACD,UAAU,EAAE;YACX,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;YAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1C,oGAAoG;YACpG,OAAO,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;YACrG,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC;YACtB,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,SAAS,IAAI,IAAI;YACjD,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,SAAS,IAAI,IAAI;YACvC,WAAW,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,IAAI,IAAI;YAC/C,GAAG,KAAK;SACR;KACD,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,QAAmC;IAC5D,OAAO;QACN,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KAC3F,CAAA;AACF,CAAC"}
|