@mailwoman/entity-resolution 0.0.0-stage → 10.8.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 +114 -2
- package/lib/address-key.ts +46 -0
- package/lib/geocode-handler.ts +37 -0
- package/lib/geojson.ts +72 -0
- package/lib/index.ts +23 -0
- package/lib/ingest.ts +349 -0
- package/lib/learned-scorer.ts +134 -0
- package/lib/map-html.ts +287 -0
- package/lib/models/crosssource-gbt-en-us.ts +43 -0
- package/lib/models/dedup-gbt-en-us.ts +47 -0
- package/lib/models/org-crosssource-gbt-en-us.ts +43 -0
- package/lib/reconcile.ts +239 -0
- package/lib/resolve.ts +569 -0
- package/lib/types.ts +110 -0
- package/out/address-key.d.ts +34 -0
- package/out/address-key.d.ts.map +1 -0
- package/out/address-key.js +41 -0
- package/out/address-key.js.map +1 -0
- package/out/geocode-handler.d.ts +20 -0
- package/out/geocode-handler.d.ts.map +1 -0
- package/out/geocode-handler.js +29 -0
- package/out/geocode-handler.js.map +1 -0
- package/out/geojson.d.ts +28 -0
- package/out/geojson.d.ts.map +1 -0
- package/out/geojson.js +62 -0
- package/out/geojson.js.map +1 -0
- package/out/index.d.ts +23 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +23 -0
- package/out/index.js.map +1 -0
- package/out/ingest.d.ts +173 -0
- package/out/ingest.d.ts.map +1 -0
- package/out/ingest.js +185 -0
- package/out/ingest.js.map +1 -0
- package/out/learned-scorer.d.ts +61 -0
- package/out/learned-scorer.d.ts.map +1 -0
- package/out/learned-scorer.js +91 -0
- package/out/learned-scorer.js.map +1 -0
- package/out/map-html.d.ts +39 -0
- package/out/map-html.d.ts.map +1 -0
- package/out/map-html.js +220 -0
- package/out/map-html.js.map +1 -0
- package/out/models/crosssource-gbt-en-us.d.ts +45 -0
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -0
- package/out/models/crosssource-gbt-en-us.js +40 -0
- package/out/models/crosssource-gbt-en-us.js.map +1 -0
- package/out/models/dedup-gbt-en-us.d.ts +44 -0
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -0
- package/out/models/dedup-gbt-en-us.js +44 -0
- package/out/models/dedup-gbt-en-us.js.map +1 -0
- package/out/models/org-crosssource-gbt-en-us.d.ts +45 -0
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -0
- package/out/models/org-crosssource-gbt-en-us.js +40 -0
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -0
- package/out/reconcile.d.ts +96 -0
- package/out/reconcile.d.ts.map +1 -0
- package/out/reconcile.js +127 -0
- package/out/reconcile.js.map +1 -0
- package/out/resolve.d.ts +264 -0
- package/out/resolve.d.ts.map +1 -0
- package/out/resolve.js +282 -0
- package/out/resolve.js.map +1 -0
- package/out/tools/coverage-reconciliation.d.ts +67 -0
- package/out/tools/coverage-reconciliation.d.ts.map +1 -0
- package/out/tools/coverage-reconciliation.js +113 -0
- package/out/tools/coverage-reconciliation.js.map +1 -0
- package/out/tools/cross/dataset-correlation.d.ts +61 -0
- package/out/tools/cross/dataset-correlation.d.ts.map +1 -0
- package/out/tools/cross/dataset-correlation.js +244 -0
- package/out/tools/cross/dataset-correlation.js.map +1 -0
- package/out/tools/cross/source-threshold-sweep.d.ts +60 -0
- package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -0
- package/out/tools/cross/source-threshold-sweep.js +264 -0
- package/out/tools/cross/source-threshold-sweep.js.map +1 -0
- package/out/tools/dedup-ceiling.d.ts +62 -0
- package/out/tools/dedup-ceiling.d.ts.map +1 -0
- package/out/tools/dedup-ceiling.js +171 -0
- package/out/tools/dedup-ceiling.js.map +1 -0
- package/out/tools/eval-geocoder.d.ts +68 -0
- package/out/tools/eval-geocoder.d.ts.map +1 -0
- package/out/tools/eval-geocoder.js +13 -0
- package/out/tools/eval-geocoder.js.map +1 -0
- package/out/tools/geocoder/namesake-probe.d.ts +33 -0
- package/out/tools/geocoder/namesake-probe.d.ts.map +1 -0
- package/out/tools/geocoder/namesake-probe.js +60 -0
- package/out/tools/geocoder/namesake-probe.js.map +1 -0
- package/out/tools/geocoder/vs-provided-coords.d.ts +53 -0
- package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -0
- package/out/tools/geocoder/vs-provided-coords.js +161 -0
- package/out/tools/geocoder/vs-provided-coords.js.map +1 -0
- package/out/tools/gold-set-sample.d.ts +67 -0
- package/out/tools/gold-set-sample.d.ts.map +1 -0
- package/out/tools/gold-set-sample.js +81 -0
- package/out/tools/gold-set-sample.js.map +1 -0
- package/out/tools/learned/scorer/clustering-eval.d.ts +77 -0
- package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -0
- package/out/tools/learned/scorer/clustering-eval.js +207 -0
- package/out/tools/learned/scorer/clustering-eval.js.map +1 -0
- package/out/tools/learned/scorer/crossstate-eval.d.ts +65 -0
- package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -0
- package/out/tools/learned/scorer/crossstate-eval.js +168 -0
- package/out/tools/learned/scorer/crossstate-eval.js.map +1 -0
- package/out/tools/learned/scorer/eval.d.ts +64 -0
- package/out/tools/learned/scorer/eval.d.ts.map +1 -0
- package/out/tools/learned/scorer/eval.js +275 -0
- package/out/tools/learned/scorer/eval.js.map +1 -0
- package/out/tools/matcher-scale.d.ts +40 -0
- package/out/tools/matcher-scale.d.ts.map +1 -0
- package/out/tools/matcher-scale.js +111 -0
- package/out/tools/matcher-scale.js.map +1 -0
- package/out/tools/nppes/dedup-benchmark.d.ts +82 -0
- package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -0
- package/out/tools/nppes/dedup-benchmark.js +226 -0
- package/out/tools/nppes/dedup-benchmark.js.map +1 -0
- package/out/tools/nppes/org-name.d.ts +15 -0
- package/out/tools/nppes/org-name.d.ts.map +1 -0
- package/out/tools/nppes/org-name.js +6 -0
- package/out/tools/nppes/org-name.js.map +1 -0
- package/out/tools/nppes/overmerge-packet.d.ts +43 -0
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -0
- package/out/tools/nppes/overmerge-packet.js +54 -0
- package/out/tools/nppes/overmerge-packet.js.map +1 -0
- package/out/tools/nppes/report.d.ts +97 -0
- package/out/tools/nppes/report.d.ts.map +1 -0
- package/out/tools/nppes/report.js +178 -0
- package/out/tools/nppes/report.js.map +1 -0
- package/out/tools/nppes/sample.d.ts +101 -0
- package/out/tools/nppes/sample.d.ts.map +1 -0
- package/out/tools/nppes/sample.js +127 -0
- package/out/tools/nppes/sample.js.map +1 -0
- package/out/tools/nppes/scoring.d.ts +37 -0
- package/out/tools/nppes/scoring.d.ts.map +1 -0
- package/out/tools/nppes/scoring.js +81 -0
- package/out/tools/nppes/scoring.js.map +1 -0
- package/out/tools/nppes/settings.d.ts +41 -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 +63 -0
- package/out/tools/nppes/truth-grains.d.ts.map +1 -0
- package/out/tools/nppes/truth-grains.js +142 -0
- package/out/tools/nppes/truth-grains.js.map +1 -0
- package/out/tools/shared.d.ts +325 -0
- package/out/tools/shared.d.ts.map +1 -0
- package/out/tools/shared.js +453 -0
- package/out/tools/shared.js.map +1 -0
- package/out/tools/train/cross-gbt.d.ts +89 -0
- package/out/tools/train/cross-gbt.d.ts.map +1 -0
- package/out/tools/train/cross-gbt.js +132 -0
- package/out/tools/train/cross-gbt.js.map +1 -0
- package/out/tools/train/gbt.d.ts +85 -0
- package/out/tools/train/gbt.d.ts.map +1 -0
- package/out/tools/train/gbt.js +155 -0
- package/out/tools/train/gbt.js.map +1 -0
- package/out/tools/train/org-cross-gbt.d.ts +85 -0
- package/out/tools/train/org-cross-gbt.d.ts.map +1 -0
- package/out/tools/train/org-cross-gbt.js +122 -0
- package/out/tools/train/org-cross-gbt.js.map +1 -0
- package/out/tools/txhhsc-to-oarow.d.ts +42 -0
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -0
- package/out/tools/txhhsc-to-oarow.js +78 -0
- package/out/tools/txhhsc-to-oarow.js.map +1 -0
- package/out/tools/viz/browser.d.ts +31 -0
- package/out/tools/viz/browser.d.ts.map +1 -0
- package/out/tools/viz/browser.js +26 -0
- package/out/tools/viz/browser.js.map +1 -0
- package/out/tools/viz/cross-dataset-map.d.ts +39 -0
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -0
- package/out/tools/viz/cross-dataset-map.js +84 -0
- package/out/tools/viz/cross-dataset-map.js.map +1 -0
- package/out/tools/viz/geocode-first-surface.d.ts +36 -0
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -0
- package/out/tools/viz/geocode-first-surface.js +234 -0
- package/out/tools/viz/geocode-first-surface.js.map +1 -0
- package/out/tools/viz/render/map.d.ts +42 -0
- package/out/tools/viz/render/map.d.ts.map +1 -0
- package/out/tools/viz/render/map.js +40 -0
- package/out/tools/viz/render/map.js.map +1 -0
- package/out/tools/viz/render.d.ts +46 -0
- package/out/tools/viz/render.d.ts.map +1 -0
- package/out/tools/viz/render.js +49 -0
- package/out/tools/viz/render.js.map +1 -0
- package/out/tools/viz/source-provenance-map.d.ts +57 -0
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -0
- package/out/tools/viz/source-provenance-map.js +82 -0
- package/out/tools/viz/source-provenance-map.js.map +1 -0
- package/out/tools/viz/yardstick-figure.d.ts +22 -0
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -0
- package/out/tools/viz/yardstick-figure.js +106 -0
- package/out/tools/viz/yardstick-figure.js.map +1 -0
- package/out/types.d.ts +108 -0
- package/out/types.d.ts.map +1 -0
- package/out/types.js +11 -0
- package/out/types.js.map +1 -0
- package/package.json +113 -3
- package/tools/coverage-reconciliation.ts +192 -0
- package/tools/cross/dataset-correlation.ts +380 -0
- package/tools/cross/source-threshold-sweep.ts +416 -0
- package/tools/dedup-ceiling.ts +225 -0
- package/tools/eval-geocoder.ts +77 -0
- package/tools/geocoder/namesake-probe.ts +91 -0
- package/tools/geocoder/vs-provided-coords.ts +232 -0
- package/tools/gold-set-sample.ts +147 -0
- package/tools/learned/scorer/clustering-eval.ts +349 -0
- package/tools/learned/scorer/crossstate-eval.ts +280 -0
- package/tools/learned/scorer/eval.ts +429 -0
- package/tools/matcher-scale.ts +185 -0
- package/tools/nppes/dedup-benchmark.ts +364 -0
- package/tools/nppes/org-name.ts +15 -0
- package/tools/nppes/overmerge-packet.ts +98 -0
- package/tools/nppes/report.ts +380 -0
- package/tools/nppes/sample.ts +250 -0
- package/tools/nppes/scoring.ts +115 -0
- package/tools/nppes/settings.ts +102 -0
- package/tools/nppes/truth-grains.ts +185 -0
- package/tools/shared.ts +743 -0
- package/tools/train/cross-gbt.ts +214 -0
- package/tools/train/gbt.ts +261 -0
- package/tools/train/org-cross-gbt.ts +189 -0
- package/tools/txhhsc-to-oarow.ts +118 -0
- package/tools/viz/browser.ts +41 -0
- package/tools/viz/cross-dataset-map.ts +133 -0
- package/tools/viz/geocode-first-surface.ts +305 -0
- package/tools/viz/render/map.ts +61 -0
- package/tools/viz/render.ts +103 -0
- package/tools/viz/source-provenance-map.ts +154 -0
- package/tools/viz/yardstick-figure.ts +197 -0
package/package.json
CHANGED
|
@@ -1,6 +1,116 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/entity-resolution",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "10.8.0",
|
|
4
|
+
"description": "The geocode-first record-matching application: resolve messy contact/organization records into canonical, geocoded entities (block → score → cluster) and export them as GeoJSON for spatial analysis. The clinic-funding use case mailwoman was built for.",
|
|
5
|
+
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/sister-software/mailwoman.git",
|
|
9
|
+
"directory": "packages/entity-resolution"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"out/**/*.js",
|
|
13
|
+
"out/**/*.js.map",
|
|
14
|
+
"out/**/*.d.ts",
|
|
15
|
+
"out/**/*.d.ts.map",
|
|
16
|
+
"lib/**/*.ts",
|
|
17
|
+
"lib/**/*.tsx",
|
|
18
|
+
"tools/**/*.ts",
|
|
19
|
+
"!**/*.test.ts",
|
|
20
|
+
"!**/*.test.tsx"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"imports": {
|
|
25
|
+
"#tools/*": {
|
|
26
|
+
"types": "./out/tools/*.d.ts",
|
|
27
|
+
"node": "./out/tools/*.js",
|
|
28
|
+
"default": "./out/tools/*.js"
|
|
29
|
+
},
|
|
30
|
+
"#index": {
|
|
31
|
+
"types": "./out/index.d.ts",
|
|
32
|
+
"node": "./out/index.js",
|
|
33
|
+
"default": "./out/index.js"
|
|
34
|
+
},
|
|
35
|
+
"#*": {
|
|
36
|
+
"types": "./out/*.d.ts",
|
|
37
|
+
"node": "./out/*.js",
|
|
38
|
+
"default": "./out/*.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"exports": {
|
|
42
|
+
"./package.json": "./package.json",
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./out/index.d.ts",
|
|
45
|
+
"node": "./out/index.js",
|
|
46
|
+
"default": "./out/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./tools/*": {
|
|
49
|
+
"types": "./out/tools/*.d.ts",
|
|
50
|
+
"node": "./out/tools/*.js",
|
|
51
|
+
"default": "./out/tools/*.js"
|
|
52
|
+
},
|
|
53
|
+
"./*": {
|
|
54
|
+
"types": "./out/*.d.ts",
|
|
55
|
+
"node": "./out/*.js",
|
|
56
|
+
"default": "./out/*.js"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public",
|
|
61
|
+
"exports": {
|
|
62
|
+
"./package.json": "./package.json",
|
|
63
|
+
".": {
|
|
64
|
+
"types": "./out/index.d.ts",
|
|
65
|
+
"node": "./out/index.js",
|
|
66
|
+
"default": "./out/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./tools/*": {
|
|
69
|
+
"types": "./out/tools/*.d.ts",
|
|
70
|
+
"node": "./out/tools/*.js",
|
|
71
|
+
"default": "./out/tools/*.js"
|
|
72
|
+
},
|
|
73
|
+
"./*": {
|
|
74
|
+
"types": "./out/*.d.ts",
|
|
75
|
+
"node": "./out/*.js",
|
|
76
|
+
"default": "./out/*.js"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"imports": {
|
|
80
|
+
"#tools/*": {
|
|
81
|
+
"types": "./out/tools/*.d.ts",
|
|
82
|
+
"node": "./out/tools/*.js",
|
|
83
|
+
"default": "./out/tools/*.js"
|
|
84
|
+
},
|
|
85
|
+
"#index": {
|
|
86
|
+
"types": "./out/index.d.ts",
|
|
87
|
+
"node": "./out/index.js",
|
|
88
|
+
"default": "./out/index.js"
|
|
89
|
+
},
|
|
90
|
+
"#*": {
|
|
91
|
+
"types": "./out/*.d.ts",
|
|
92
|
+
"node": "./out/*.js",
|
|
93
|
+
"default": "./out/*.js"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"dependencies": {
|
|
98
|
+
"@mailwoman/address-id": "10.8.0",
|
|
99
|
+
"@mailwoman/annotations": "10.8.0",
|
|
100
|
+
"@mailwoman/core": "10.8.0",
|
|
101
|
+
"@mailwoman/match": "10.8.0",
|
|
102
|
+
"@mailwoman/record": "10.8.0",
|
|
103
|
+
"@mailwoman/resolver-wof-sqlite": "10.8.0",
|
|
104
|
+
"@mailwoman/spatial": "10.8.0",
|
|
105
|
+
"@mailwoman/sqlite": "10.8.0",
|
|
106
|
+
"@protomaps/basemaps": "^5.7.2",
|
|
107
|
+
"@sister.software/h3": "^1.1.0",
|
|
108
|
+
"spliterator": "^10.1.1"
|
|
109
|
+
},
|
|
110
|
+
"devDependencies": {
|
|
111
|
+
"@mailwoman/browser": "10.5.0",
|
|
112
|
+
"@types/node": "^26.6.6",
|
|
113
|
+
"path-ts": "^2.5.0",
|
|
114
|
+
"playwright": "^1.64.1"
|
|
115
|
+
}
|
|
6
116
|
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Coverage reconciliation, the product output that replaces inspecting the map by eye.
|
|
7
|
+
*
|
|
8
|
+
* Each resolved entity is classified by the kind of source its records come from. An eligibility
|
|
9
|
+
* source holds providers and facilities, such as NPPES org NPIs or TX HHSC nursing facilities. A
|
|
10
|
+
* funding source holds entities enrolled in a funding program, such as FCC Rural Health Care
|
|
11
|
+
* filings.
|
|
12
|
+
*
|
|
13
|
+
* The buckets are enrolled (both an eligibility and a funding record), eligible rather than
|
|
14
|
+
* enrolled (an eligibility record with no funding record resolving to it), and funded rather than
|
|
15
|
+
* in the eligibility set (a funding record with no eligibility record resolving to it).
|
|
16
|
+
*
|
|
17
|
+
* This is strictly a set-membership reconciliation, never an allegation.
|
|
18
|
+
*
|
|
19
|
+
* Run: `mailwoman registry scorer-eval coverage-reconciliation [--cap 2000] [--wof <admin.db>]
|
|
20
|
+
* [--data-root <dir>] [--out-md <md>] [--out-geojson <geojson>]`
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { dataRootPath } from "@mailwoman/core/data-root"
|
|
24
|
+
import { writeLocalFile, writeLocalJSONFile } from "@mailwoman/core/fs/writers"
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
ingestRows,
|
|
28
|
+
reconcileCoverage,
|
|
29
|
+
reconciliationGeoJSON,
|
|
30
|
+
reconciliationReport,
|
|
31
|
+
resolveEntities,
|
|
32
|
+
streamRows,
|
|
33
|
+
type GeocodeAddress,
|
|
34
|
+
type ReconcileConfig,
|
|
35
|
+
type SourceRecord,
|
|
36
|
+
} from "#index"
|
|
37
|
+
import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
|
|
38
|
+
import { buildSpecs, stateOption } from "#tools/shared"
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Options for {@linkcode coverageReconciliation}.
|
|
42
|
+
*/
|
|
43
|
+
export interface CoverageReconciliationOptions {
|
|
44
|
+
/**
|
|
45
|
+
* The injected geocoder factory.
|
|
46
|
+
*
|
|
47
|
+
* The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
|
|
48
|
+
*/
|
|
49
|
+
createGeocoder: EvalGeocoderFactory
|
|
50
|
+
/**
|
|
51
|
+
* Record-matcher sources directory.
|
|
52
|
+
*
|
|
53
|
+
* @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
|
|
54
|
+
*/
|
|
55
|
+
sources?: string
|
|
56
|
+
/**
|
|
57
|
+
* Rows kept per source.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue `2000`
|
|
60
|
+
*/
|
|
61
|
+
cap?: number
|
|
62
|
+
/**
|
|
63
|
+
* State filter.
|
|
64
|
+
*
|
|
65
|
+
* @defaultValue TX.
|
|
66
|
+
*/
|
|
67
|
+
state?: string
|
|
68
|
+
/**
|
|
69
|
+
* Also write the markdown report here.
|
|
70
|
+
*/
|
|
71
|
+
outMd?: string
|
|
72
|
+
/**
|
|
73
|
+
* Also write the bucket-tagged GeoJSON here.
|
|
74
|
+
*/
|
|
75
|
+
outGeojson?: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Which kind of source a record's provenance label denotes.
|
|
80
|
+
*/
|
|
81
|
+
const ELIGIBILITY = new Set(["nppes", "txhhsc-nursing"])
|
|
82
|
+
const FUNDING = new Set(["fcc-rhc"])
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Reconcile eligibility and funding sources.
|
|
86
|
+
* Emit the markdown report to stdout.
|
|
87
|
+
*/
|
|
88
|
+
export async function coverageReconciliation(
|
|
89
|
+
options: CoverageReconciliationOptions,
|
|
90
|
+
report?: (line: string) => void
|
|
91
|
+
): Promise<{ markdown: string }> {
|
|
92
|
+
const SOURCES = options.sources || dataRootPath("record-matcher", "sources")
|
|
93
|
+
const CAP = options.cap ?? 2000
|
|
94
|
+
const STATE = stateOption(options)
|
|
95
|
+
const OUT_MD = options.outMd || ""
|
|
96
|
+
const OUT_GEOJSON = options.outGeojson || ""
|
|
97
|
+
const SPECS = buildSpecs(`${SOURCES}`, STATE)
|
|
98
|
+
|
|
99
|
+
const rawBySource = new Map<string, Record<string, string>[]>()
|
|
100
|
+
|
|
101
|
+
for (const spec of SPECS) {
|
|
102
|
+
report?.(`[A] ${spec.source}: streaming + ${STATE} filter (cap ${CAP})…`)
|
|
103
|
+
const kept: Record<string, string>[] = []
|
|
104
|
+
|
|
105
|
+
for await (const row of streamRows(spec.path)) {
|
|
106
|
+
if (!spec.inState(row)) continue
|
|
107
|
+
kept.push(row)
|
|
108
|
+
|
|
109
|
+
if (kept.length >= CAP) break
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
rawBySource.set(spec.source, kept)
|
|
113
|
+
report?.(` ${spec.source}: ${kept.length} rows`)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
report?.("[B] building the geocoder…")
|
|
117
|
+
const geocoder = await options.createGeocoder()
|
|
118
|
+
|
|
119
|
+
let geo = 0
|
|
120
|
+
let total = 0
|
|
121
|
+
|
|
122
|
+
const geocodeForIngest: GeocodeAddress = async (raw) => {
|
|
123
|
+
const g = await geocoder.geocodeAddress(raw)
|
|
124
|
+
|
|
125
|
+
total++
|
|
126
|
+
|
|
127
|
+
if (g?.geocode) {
|
|
128
|
+
geo++
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return g
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
report?.("[C] geocoding + ingesting…")
|
|
135
|
+
const records: SourceRecord[] = []
|
|
136
|
+
|
|
137
|
+
for (const spec of SPECS) {
|
|
138
|
+
const recs = await ingestRows(rawBySource.get(spec.source)!, spec.mapping, { geocodeAddress: geocodeForIngest })
|
|
139
|
+
|
|
140
|
+
for (const r of recs) {
|
|
141
|
+
r.id = `${spec.source}:${r.id}`
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
records.push(...recs)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
geocoder[Symbol.dispose]()
|
|
148
|
+
report?.(` ${records.length} records; geocoded ${geo}/${total} (${((100 * geo) / total).toFixed(1)}%)`)
|
|
149
|
+
|
|
150
|
+
report?.("[D] resolving + reconciling…")
|
|
151
|
+
// Use the Fellegi-Sunter baseline for this cross-dataset join.
|
|
152
|
+
// It is recall-oriented because the signal is the same facility under a different operational name.
|
|
153
|
+
// The dedup-calibrated GBT default rejects that pair.
|
|
154
|
+
const { entities } = resolveEntities(records, { trainEM: true, collapseSpatial: true, learnedScorer: false })
|
|
155
|
+
|
|
156
|
+
// Reconcile through the shared @mailwoman/entity-resolution code path, so the script and the CLI agree.
|
|
157
|
+
const config: ReconcileConfig = { eligibilitySources: [...ELIGIBILITY], fundingSources: [...FUNDING] }
|
|
158
|
+
const result = reconcileCoverage(entities, config)
|
|
159
|
+
const geojson = reconciliationGeoJSON(result)
|
|
160
|
+
|
|
161
|
+
const md = reconciliationReport(result, {
|
|
162
|
+
title: "Coverage reconciliation — eligibility ↔ enrollment (#621)",
|
|
163
|
+
scopeNote:
|
|
164
|
+
`Generated by \`mailwoman registry scorer-eval coverage-reconciliation\`. ${STATE}-scoped, ≤${CAP} rows per ` +
|
|
165
|
+
`source, resolved BLIND across sources. **Eligibility** = NPPES org NPIs + TX HHSC nursing facilities. ` +
|
|
166
|
+
`**Funding/enrollment** = FCC Rural Health Care filings. Each resolved entity is classified by which kinds ` +
|
|
167
|
+
`of source its records span.`,
|
|
168
|
+
scorerNote:
|
|
169
|
+
`Scored with the Fellegi-Sunter baseline (\`learnedScorer: false\`): this is a cross-dataset eligibility ↔ ` +
|
|
170
|
+
`funding join (recall-oriented), so the dedup-calibrated GBT default (#603) — trained to reject the ` +
|
|
171
|
+
`"same place, different operational name" pattern that IS the cross-source signal — is pinned off. See #655.`,
|
|
172
|
+
sampleNote:
|
|
173
|
+
`This is a **capped sample** (≤${CAP}/source), so "eligible, not enrolled" includes entities that ARE ` +
|
|
174
|
+
`enrolled in reality but whose funding record fell outside the sample — a **sampling artifact, not a ` +
|
|
175
|
+
`finding**. At full scale the anti-join tightens, but it is STILL only a set of candidates.`,
|
|
176
|
+
spotCheckLimit: 15,
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
console.log(md)
|
|
180
|
+
|
|
181
|
+
if (OUT_MD) {
|
|
182
|
+
await writeLocalFile(md, OUT_MD)
|
|
183
|
+
report?.(`[written] ${OUT_MD}`)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (OUT_GEOJSON) {
|
|
187
|
+
await writeLocalJSONFile(geojson, OUT_GEOJSON)
|
|
188
|
+
report?.(`[written] ${OUT_GEOJSON} (${geojson.features.length} features)`)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return { markdown: md }
|
|
192
|
+
}
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { dataRootPath } from "@mailwoman/core/data-root"
|
|
8
|
+
import { writeLocalFile, writeLocalJSONFile } from "@mailwoman/core/fs/writers"
|
|
9
|
+
import { isPresent } from "@mailwoman/core/objects"
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
addressFrequencyKey,
|
|
13
|
+
ingestRows,
|
|
14
|
+
repName,
|
|
15
|
+
resolveEntities,
|
|
16
|
+
streamRows,
|
|
17
|
+
toGeoJSON,
|
|
18
|
+
type GeocodeAddress,
|
|
19
|
+
type SourceRecord,
|
|
20
|
+
} from "#index"
|
|
21
|
+
import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
|
|
22
|
+
import { buildSpecs, norm, pct, stateOption, type SourceSpec } from "#tools/shared"
|
|
23
|
+
|
|
24
|
+
const MIN_TRIPLE_SOURCES = 3
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Options for {@linkcode crossDatasetCorrelation}.
|
|
28
|
+
*/
|
|
29
|
+
export interface CrossDatasetCorrelationOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Creates the geocoder that resolves the sampled rows.
|
|
32
|
+
*/
|
|
33
|
+
createGeocoder: EvalGeocoderFactory
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The record-matcher sources directory.
|
|
37
|
+
*
|
|
38
|
+
* @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
|
|
39
|
+
*/
|
|
40
|
+
sources?: string
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The number of in-state rows sampled per source for geocoding.
|
|
44
|
+
*
|
|
45
|
+
* @defaultValue `300`
|
|
46
|
+
*/
|
|
47
|
+
cap?: number
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The state filter.
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue {@linkcode TX}
|
|
53
|
+
*/
|
|
54
|
+
state?: string
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Whether to scan every in-state row to build a corpus-wide address-frequency table.
|
|
58
|
+
*
|
|
59
|
+
* The scan reads the full source files, including the multi-gigabyte NPPES file.
|
|
60
|
+
* When it is false, `resolveEntities` computes frequencies from the sample only.
|
|
61
|
+
*
|
|
62
|
+
* @defaultValue `true`
|
|
63
|
+
*/
|
|
64
|
+
corpusFrequency?: boolean
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* An optional path for the Markdown report.
|
|
68
|
+
*/
|
|
69
|
+
outMd?: string
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* An optional path for the entity GeoJSON FeatureCollection.
|
|
73
|
+
*/
|
|
74
|
+
outGeojson?: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function composeAddress(row: Record<string, string>, columns: string | string[] | null | undefined): string {
|
|
78
|
+
if (!columns) return ""
|
|
79
|
+
const list = Array.isArray(columns) ? columns : [columns]
|
|
80
|
+
|
|
81
|
+
return list
|
|
82
|
+
.map((c) => norm(row[c]))
|
|
83
|
+
.filter(isPresent)
|
|
84
|
+
.join(" ")
|
|
85
|
+
.trim()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const commitmentsSpec = (S: string, STATE: string): SourceSpec => ({
|
|
89
|
+
source: "fcc-rhc-commitments",
|
|
90
|
+
path: `${S}/fcc-rhc_commitments-disbursements_form462-466-466a_20260615.tsv`,
|
|
91
|
+
mapping: {
|
|
92
|
+
id: "hcpID",
|
|
93
|
+
organization: "hcpName",
|
|
94
|
+
address: ["hcpStreet", "hcpCity", "hcpState", "hcpZip"],
|
|
95
|
+
source: "fcc-rhc-commitments",
|
|
96
|
+
},
|
|
97
|
+
inState: (r) =>
|
|
98
|
+
norm(r["Filing HCP State"]).toUpperCase() === STATE || norm(r["Participating HCP State"]).toUpperCase() === STATE,
|
|
99
|
+
explode: (r) => {
|
|
100
|
+
const out: Record<string, string>[] = []
|
|
101
|
+
|
|
102
|
+
const add = (prefix: string, role: string): void => {
|
|
103
|
+
const id = norm(r[`${prefix} HCP`])
|
|
104
|
+
const state = norm(r[`${prefix} HCP State`]).toUpperCase()
|
|
105
|
+
|
|
106
|
+
if (id && state === STATE) {
|
|
107
|
+
out.push({
|
|
108
|
+
hcpID: `${role}-${id}`,
|
|
109
|
+
hcpName: norm(r[`${prefix} HCP Name`]),
|
|
110
|
+
hcpStreet: norm(r[`${prefix} HCP Street`]),
|
|
111
|
+
hcpCity: norm(r[`${prefix} HCP City`]),
|
|
112
|
+
hcpState: state,
|
|
113
|
+
hcpZip: norm(r[`${prefix} HCP Zip Code`]),
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
add("Filing", "filing")
|
|
119
|
+
add("Participating", "participating")
|
|
120
|
+
|
|
121
|
+
return out
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Geocodes a sample of each source dataset in one state, resolves the records into entities across sources.
|
|
127
|
+
* It returns a Markdown report of the cross-source links.
|
|
128
|
+
*
|
|
129
|
+
* Progress lines go to `report`.
|
|
130
|
+
* The function also writes the report and GeoJSON when `outMd` or `outGeojson` is set.
|
|
131
|
+
*/
|
|
132
|
+
export async function crossDatasetCorrelation(
|
|
133
|
+
options: CrossDatasetCorrelationOptions,
|
|
134
|
+
report?: (line: string) => void
|
|
135
|
+
): Promise<{ markdown: string }> {
|
|
136
|
+
const SOURCES = options.sources || dataRootPath("record-matcher", "sources")
|
|
137
|
+
const CAP = options.cap ?? 300
|
|
138
|
+
const STATE = stateOption(options)
|
|
139
|
+
const OUT_MD = options.outMd || ""
|
|
140
|
+
const OUT_GEOJSON = options.outGeojson || ""
|
|
141
|
+
const CORPUS_FREQ = options.corpusFrequency ?? true
|
|
142
|
+
const SPECS = [...buildSpecs(`${SOURCES}`, STATE), commitmentsSpec(`${SOURCES}`, STATE)]
|
|
143
|
+
|
|
144
|
+
const rawBySource = new Map<string, Record<string, string>[]>()
|
|
145
|
+
const addrCounts = new Map<string, number>()
|
|
146
|
+
let addrTotal = 0
|
|
147
|
+
|
|
148
|
+
for (const spec of SPECS) {
|
|
149
|
+
report?.(`[A] ${spec.source}: streaming + ${STATE} filter (sample ${CAP}${CORPUS_FREQ ? ", full freq scan" : ""})…`)
|
|
150
|
+
const kept: Record<string, string>[] = []
|
|
151
|
+
|
|
152
|
+
for await (const row of streamRows(spec.path)) {
|
|
153
|
+
if (!spec.inState(row)) continue
|
|
154
|
+
const exploded = spec.explode ? spec.explode(row) : [row]
|
|
155
|
+
|
|
156
|
+
for (const e of exploded) {
|
|
157
|
+
if (CORPUS_FREQ) {
|
|
158
|
+
const a = composeAddress(e, spec.mapping.address)
|
|
159
|
+
|
|
160
|
+
if (a) {
|
|
161
|
+
const k = addressFrequencyKey(a)
|
|
162
|
+
addrCounts.set(k, (addrCounts.get(k) ?? 0) + 1)
|
|
163
|
+
|
|
164
|
+
addrTotal++
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (kept.length < CAP) {
|
|
169
|
+
kept.push(e)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!CORPUS_FREQ && kept.length >= CAP) break
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
rawBySource.set(spec.source, kept)
|
|
177
|
+
report?.(` ${spec.source}: ${kept.length} sampled`)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const addressFrequency = CORPUS_FREQ
|
|
181
|
+
? {
|
|
182
|
+
total: addrTotal,
|
|
183
|
+
distinct: addrCounts.size,
|
|
184
|
+
frequency: (v: string) => (v ? (addrCounts.get(addressFrequencyKey(v)) ?? 0) / addrTotal : 0),
|
|
185
|
+
}
|
|
186
|
+
: null
|
|
187
|
+
|
|
188
|
+
if (CORPUS_FREQ) {
|
|
189
|
+
report?.(` address-frequency table: ${addrCounts.size} distinct over ${addrTotal} ${STATE} addresses`)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
report?.("[B] building the geocoder…")
|
|
193
|
+
const geocoder = await options.createGeocoder()
|
|
194
|
+
|
|
195
|
+
let geo = 0
|
|
196
|
+
let total = 0
|
|
197
|
+
|
|
198
|
+
const geocodeForIngest: GeocodeAddress = async (raw) => {
|
|
199
|
+
const g = await geocoder.geocodeAddress(raw)
|
|
200
|
+
|
|
201
|
+
total++
|
|
202
|
+
|
|
203
|
+
if (g?.geocode) {
|
|
204
|
+
geo++
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return g
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
report?.("[C] geocoding + ingesting all sources…")
|
|
211
|
+
const records: SourceRecord[] = []
|
|
212
|
+
|
|
213
|
+
for (const spec of SPECS) {
|
|
214
|
+
const rows = rawBySource.get(spec.source)!
|
|
215
|
+
|
|
216
|
+
const g0 = geo
|
|
217
|
+
const t0 = total
|
|
218
|
+
const recs = await ingestRows(rows, spec.mapping, { geocodeAddress: geocodeForIngest })
|
|
219
|
+
const dg = geo - g0
|
|
220
|
+
const dt = total - t0
|
|
221
|
+
report?.(` ${spec.source}: geocoded ${dg}/${dt} (${dt ? ((100 * dg) / dt).toFixed(1) : "0"}%)`)
|
|
222
|
+
|
|
223
|
+
for (const r of recs) {
|
|
224
|
+
r.id = `${spec.source}:${r.id}`
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
records.push(...recs)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
geocoder[Symbol.dispose]()
|
|
231
|
+
report?.(` ${records.length} records; geocoded ${geo}/${total} (${((100 * geo) / total).toFixed(1)}%)`)
|
|
232
|
+
|
|
233
|
+
report?.("[D] resolving across sources…")
|
|
234
|
+
|
|
235
|
+
const { entities, candidatePairs } = resolveEntities(records, {
|
|
236
|
+
trainEM: true,
|
|
237
|
+
learnedScorer: false,
|
|
238
|
+
...(addressFrequency ? { addressFrequency } : {}),
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
const sourceOf = (r: SourceRecord) => r.source ?? "?"
|
|
242
|
+
|
|
243
|
+
const crossSource = entities
|
|
244
|
+
.map((e) => ({ e, sources: new Set(e.records.map(sourceOf)) }))
|
|
245
|
+
.filter((x) => x.sources.size >= 2)
|
|
246
|
+
.toSorted((a, b) => b.sources.size - a.sources.size || b.e.records.length - a.e.records.length)
|
|
247
|
+
|
|
248
|
+
const pairCounts = new Map<string, number>()
|
|
249
|
+
|
|
250
|
+
for (const { sources } of crossSource) {
|
|
251
|
+
const list = [...sources].toSorted()
|
|
252
|
+
|
|
253
|
+
for (let i = 0; i < list.length; i++) {
|
|
254
|
+
for (let j = i + 1; j < list.length; j++) {
|
|
255
|
+
const k = `${list[i]} ↔ ${list[j]}`
|
|
256
|
+
pairCounts.set(k, (pairCounts.get(k) ?? 0) + 1)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const lines: string[] = [
|
|
262
|
+
`# Cross-dataset correlation (#618 / #87 real-data run)`,
|
|
263
|
+
"",
|
|
264
|
+
`_Generated by \`mailwoman registry scorer-eval cross-dataset\`. ${STATE}-scoped, ≤${CAP} rows per ` +
|
|
265
|
+
`source geocoded, resolved BLIND across sources (geo-first block → Fellegi-Sunter + EM → cluster) with the ` +
|
|
266
|
+
`proven changes default-on (#86). The sources share no key; an entity spanning ≥2 sources is a cross-dataset ` +
|
|
267
|
+
`link we surface for review — interpretation is the consumer's._`,
|
|
268
|
+
"",
|
|
269
|
+
`## Sources`,
|
|
270
|
+
"",
|
|
271
|
+
]
|
|
272
|
+
|
|
273
|
+
const blurb: Record<string, string> = {
|
|
274
|
+
"txhhsc-nursing": "TX HHSC licensed nursing facilities",
|
|
275
|
+
"fcc-rhc": "FCC Rural Health Care posted-services filings",
|
|
276
|
+
"fcc-rhc-commitments": "FCC RHC funding commitments (Filing + Participating HCP, exploded)",
|
|
277
|
+
nppes: "NPPES organization NPIs",
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
lines.push(`| source | rows | what it is |`)
|
|
281
|
+
lines.push(`|---|---:|---|`)
|
|
282
|
+
|
|
283
|
+
for (const spec of SPECS) {
|
|
284
|
+
lines.push(`| \`${spec.source}\` | ${rawBySource.get(spec.source)!.length} | ${blurb[spec.source] ?? ""} |`)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
lines.push("")
|
|
288
|
+
|
|
289
|
+
lines.push(
|
|
290
|
+
`Combined: **${records.length} records**, geocoded ${pct(geo / total)}%. Resolved to ` +
|
|
291
|
+
`**${entities.length} entities** from ${candidatePairs} candidate pairs.`
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
lines.push("")
|
|
295
|
+
|
|
296
|
+
lines.push(
|
|
297
|
+
addressFrequency
|
|
298
|
+
? `Matched with the proven changes default-on (#86): collapsed spatial (A1) + inverse-address-frequency, fed ` +
|
|
299
|
+
`a corpus-wide table built from the full source files (**${addressFrequency.distinct.toLocaleString()}** distinct ` +
|
|
300
|
+
`addresses over **${addressFrequency.total.toLocaleString()}** ${STATE} rows — a crowded shared campus is ` +
|
|
301
|
+
`down-weighted as weak identity evidence).`
|
|
302
|
+
: `Matched with the zero-config default (#86): collapsed spatial (A1) + an input-scoped address-frequency table ` +
|
|
303
|
+
`(\`--no-corpus-frequency\`; pass nothing to build the corpus-wide table from the full files instead).`
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
lines.push("")
|
|
307
|
+
|
|
308
|
+
lines.push(
|
|
309
|
+
`Scored with the Fellegi-Sunter baseline (\`learnedScorer: false\`): cross-dataset link discovery is ` +
|
|
310
|
+
`recall-oriented — the same facility under different operational names across sources is the signal — so the ` +
|
|
311
|
+
`dedup-calibrated GBT default (#603), which is trained to REJECT "same place, different name," is pinned off ` +
|
|
312
|
+
`here. A cross-objective GBT threshold is the follow-up (#655).`
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
lines.push("")
|
|
316
|
+
lines.push(`## Cross-dataset links (entities spanning ≥2 sources)`)
|
|
317
|
+
lines.push("")
|
|
318
|
+
lines.push(`**${crossSource.length}** entities resolve across ≥2 sources.`)
|
|
319
|
+
lines.push("")
|
|
320
|
+
|
|
321
|
+
if (pairCounts.size) {
|
|
322
|
+
lines.push(`| source pair | entities linked |`)
|
|
323
|
+
lines.push(`|---|---:|`)
|
|
324
|
+
|
|
325
|
+
for (const [k, v] of [...pairCounts.entries()].toSorted((a, b) => b[1] - a[1])) {
|
|
326
|
+
lines.push(`| ${k} | ${v} |`)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
lines.push("")
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const triple = crossSource.filter((x) => x.sources.size >= MIN_TRIPLE_SOURCES).length
|
|
333
|
+
|
|
334
|
+
if (triple) {
|
|
335
|
+
lines.push(`Of those, **${triple}** span all three sources.`)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
lines.push("")
|
|
339
|
+
lines.push(`## Spot-check — the first 12 cross-source entities (verify by eye)`)
|
|
340
|
+
lines.push("")
|
|
341
|
+
lines.push(`| entity | sources | name (representative) | coordinate |`)
|
|
342
|
+
lines.push(`|---|---|---|---|`)
|
|
343
|
+
|
|
344
|
+
for (const { e, sources } of crossSource.slice(0, 12)) {
|
|
345
|
+
const coord = e.coordinate ? `${e.coordinate.latitude.toFixed(4)}, ${e.coordinate.longitude.toFixed(4)}` : "—"
|
|
346
|
+
lines.push(`| ${e.id} | ${[...sources].toSorted().join(", ")} | ${repName(e)} | ${coord} |`)
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
lines.push("")
|
|
350
|
+
lines.push(`## Reading`)
|
|
351
|
+
lines.push("")
|
|
352
|
+
|
|
353
|
+
lines.push(
|
|
354
|
+
`${SPECS.length} datasets with no shared key — a provider registry, a federal funding program (two of its forms, ` +
|
|
355
|
+
`the commitments form exploded into its Filing + Participating HCP per row), and a state facility registry — ` +
|
|
356
|
+
`resolve into a single entity model where ${crossSource.length} entities are corroborated by ≥2 independent ` +
|
|
357
|
+
`sources (${triple} by all three kinds), purely on geocoded location + name/org agreement, in pure Node without ` +
|
|
358
|
+
`Elasticsearch or a server. Each cross-source entity is a candidate "same place, multiple records" surfaced for ` +
|
|
359
|
+
`review; whether a correlation means anything is the data consumer's call, not ours.`
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
lines.push("")
|
|
363
|
+
|
|
364
|
+
const md = lines.join("\n")
|
|
365
|
+
|
|
366
|
+
console.log(md)
|
|
367
|
+
|
|
368
|
+
if (OUT_MD) {
|
|
369
|
+
await writeLocalFile(md, OUT_MD)
|
|
370
|
+
report?.(`\n[written] ${OUT_MD}`)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (OUT_GEOJSON) {
|
|
374
|
+
const fc = toGeoJSON(entities)
|
|
375
|
+
await writeLocalJSONFile(fc, OUT_GEOJSON)
|
|
376
|
+
report?.(`[written] ${OUT_GEOJSON} — ${fc.features.length} entity features (${crossSource.length} cross-source)`)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return { markdown: md }
|
|
380
|
+
}
|