@mailwoman/registry 10.8.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -98
- package/data/manifests/artifacts.json +32 -0
- package/data/manifests/coverage.json +56 -0
- package/data/manifests/sources.lock.json +48 -0
- package/data/normalized/iata-airports.json +126749 -0
- package/data/normalized/iso3166-1.json +2035 -0
- package/definitions/namespaces.json +63 -0
- package/definitions/sections.json +73 -0
- package/docs/data-policy.md +81 -0
- package/docs/performance.md +146 -0
- package/docs/rgy1.md +144 -0
- package/lib/artifacts/country-airport-collision.ts +28 -0
- package/lib/artifacts/iata-airport/membership.ts +28 -0
- package/lib/artifacts/iata-airport/records.ts +28 -0
- package/lib/artifacts/iso3166-1/alpha2-membership.ts +28 -0
- package/lib/artifacts/iso3166-1/alpha3-membership.ts +28 -0
- package/lib/artifacts/iso3166-1/records.ts +28 -0
- package/lib/errors.ts +47 -0
- package/lib/iata/airports/records.ts +173 -0
- package/lib/iata/airports/validate.ts +50 -0
- package/lib/index.ts +32 -18
- package/lib/inspect.ts +56 -0
- package/lib/iso3166/alpha2.ts +48 -0
- package/lib/iso3166/alpha3.ts +51 -0
- package/lib/iso3166/records.ts +150 -0
- package/lib/iso3166/relations.ts +30 -0
- package/lib/key.ts +148 -0
- package/lib/normalize.ts +35 -0
- package/lib/overlap/country-airport.ts +110 -0
- package/lib/rgy1/base64.ts +23 -0
- package/lib/rgy1/reader.ts +317 -0
- package/lib/rgy1/sections.generated.ts +80 -0
- package/lib/rgy1/views.ts +266 -0
- package/lib/types.ts +92 -77
- package/lib/wasm.ts +287 -0
- package/out/artifacts/country-airport-collision.d.ts +7 -0
- package/out/artifacts/country-airport-collision.d.ts.map +1 -0
- package/out/artifacts/country-airport-collision.js +22 -0
- package/out/artifacts/country-airport-collision.js.map +1 -0
- package/out/artifacts/iata-airport/membership.d.ts +7 -0
- package/out/artifacts/iata-airport/membership.d.ts.map +1 -0
- package/out/artifacts/iata-airport/membership.js +22 -0
- package/out/artifacts/iata-airport/membership.js.map +1 -0
- package/out/artifacts/iata-airport/records.d.ts +7 -0
- package/out/artifacts/iata-airport/records.d.ts.map +1 -0
- package/out/artifacts/iata-airport/records.js +22 -0
- package/out/artifacts/iata-airport/records.js.map +1 -0
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts +7 -0
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/alpha2-membership.js +22 -0
- package/out/artifacts/iso3166-1/alpha2-membership.js.map +1 -0
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts +7 -0
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/alpha3-membership.js +22 -0
- package/out/artifacts/iso3166-1/alpha3-membership.js.map +1 -0
- package/out/artifacts/iso3166-1/records.d.ts +7 -0
- package/out/artifacts/iso3166-1/records.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/records.js +22 -0
- package/out/artifacts/iso3166-1/records.js.map +1 -0
- package/out/errors.d.ts +38 -0
- package/out/errors.d.ts.map +1 -0
- package/out/errors.js +37 -0
- package/out/errors.js.map +1 -0
- package/out/iata/airports/records.d.ts +37 -0
- package/out/iata/airports/records.d.ts.map +1 -0
- package/out/iata/airports/records.js +135 -0
- package/out/iata/airports/records.js.map +1 -0
- package/out/iata/airports/validate.d.ts +19 -0
- package/out/iata/airports/validate.d.ts.map +1 -0
- package/out/iata/airports/validate.js +42 -0
- package/out/iata/airports/validate.js.map +1 -0
- package/out/index.d.ts +21 -18
- package/out/index.d.ts.map +1 -1
- package/out/index.js +12 -22
- package/out/index.js.map +1 -1
- package/out/inspect.d.ts +35 -0
- package/out/inspect.d.ts.map +1 -0
- package/out/inspect.js +32 -0
- package/out/inspect.js.map +1 -0
- package/out/iso3166/alpha2.d.ts +16 -0
- package/out/iso3166/alpha2.d.ts.map +1 -0
- package/out/iso3166/alpha2.js +40 -0
- package/out/iso3166/alpha2.js.map +1 -0
- package/out/iso3166/alpha3.d.ts +21 -0
- package/out/iso3166/alpha3.d.ts.map +1 -0
- package/out/iso3166/alpha3.js +43 -0
- package/out/iso3166/alpha3.js.map +1 -0
- package/out/iso3166/records.d.ts +27 -0
- package/out/iso3166/records.d.ts.map +1 -0
- package/out/iso3166/records.js +105 -0
- package/out/iso3166/records.js.map +1 -0
- package/out/iso3166/relations.d.ts +13 -0
- package/out/iso3166/relations.d.ts.map +1 -0
- package/out/iso3166/relations.js +26 -0
- package/out/iso3166/relations.js.map +1 -0
- package/out/key.d.ts +67 -0
- package/out/key.d.ts.map +1 -0
- package/out/key.js +123 -0
- package/out/key.js.map +1 -0
- package/out/normalize.d.ts +26 -0
- package/out/normalize.d.ts.map +1 -0
- package/out/normalize.js +11 -0
- package/out/normalize.js.map +1 -0
- package/out/overlap/country-airport.d.ts +43 -0
- package/out/overlap/country-airport.d.ts.map +1 -0
- package/out/overlap/country-airport.js +72 -0
- package/out/overlap/country-airport.js.map +1 -0
- package/out/rgy1/base64.d.ts +11 -0
- package/out/rgy1/base64.d.ts.map +1 -0
- package/out/rgy1/base64.js +20 -0
- package/out/rgy1/base64.js.map +1 -0
- package/out/rgy1/reader.d.ts +92 -0
- package/out/rgy1/reader.d.ts.map +1 -0
- package/out/rgy1/reader.js +230 -0
- package/out/rgy1/reader.js.map +1 -0
- package/out/rgy1/sections.generated.d.ts +52 -0
- package/out/rgy1/sections.generated.d.ts.map +1 -0
- package/out/rgy1/sections.generated.js +69 -0
- package/out/rgy1/sections.generated.js.map +1 -0
- package/out/rgy1/views.d.ts +89 -0
- package/out/rgy1/views.d.ts.map +1 -0
- package/out/rgy1/views.js +216 -0
- package/out/rgy1/views.js.map +1 -0
- package/out/sdk/fetch.d.ts +49 -0
- package/out/sdk/fetch.d.ts.map +1 -0
- package/out/sdk/fetch.js +105 -0
- package/out/sdk/fetch.js.map +1 -0
- package/out/sdk/fetch.run.d.ts +2 -0
- package/out/sdk/fetch.run.d.ts.map +1 -0
- package/out/sdk/fetch.run.js +19 -0
- package/out/sdk/fetch.run.js.map +1 -0
- package/out/sdk/sources.d.ts +102 -0
- package/out/sdk/sources.d.ts.map +1 -0
- package/out/sdk/sources.js +101 -0
- package/out/sdk/sources.js.map +1 -0
- package/out/tools/artifact-path.d.ts +5 -0
- package/out/tools/artifact-path.d.ts.map +1 -0
- package/out/tools/artifact-path.js +9 -0
- package/out/tools/artifact-path.js.map +1 -0
- package/out/tools/bench.run.d.ts +2 -0
- package/out/tools/bench.run.d.ts.map +1 -0
- package/out/tools/bench.run.js +207 -0
- package/out/tools/bench.run.js.map +1 -0
- package/out/tools/build-wasm.run.d.ts +2 -0
- package/out/tools/build-wasm.run.d.ts.map +1 -0
- package/out/tools/build-wasm.run.js +69 -0
- package/out/tools/build-wasm.run.js.map +1 -0
- package/out/tools/generate-sections.run.d.ts +2 -0
- package/out/tools/generate-sections.run.d.ts.map +1 -0
- package/out/tools/generate-sections.run.js +127 -0
- package/out/tools/generate-sections.run.js.map +1 -0
- package/out/tools/generate.run.d.ts +2 -0
- package/out/tools/generate.run.d.ts.map +1 -0
- package/out/tools/generate.run.js +115 -0
- package/out/tools/generate.run.js.map +1 -0
- package/out/tools/normalize.d.ts +143 -0
- package/out/tools/normalize.d.ts.map +1 -0
- package/out/tools/normalize.js +303 -0
- package/out/tools/normalize.js.map +1 -0
- package/out/tools/normalize.run.d.ts +2 -0
- package/out/tools/normalize.run.d.ts.map +1 -0
- package/out/tools/normalize.run.js +27 -0
- package/out/tools/normalize.run.js.map +1 -0
- package/out/types.d.ts +91 -79
- package/out/types.d.ts.map +1 -1
- package/out/types.js +15 -8
- package/out/types.js.map +1 -1
- package/out/wasm.d.ts +85 -0
- package/out/wasm.d.ts.map +1 -0
- package/out/wasm.js +138 -0
- package/out/wasm.js.map +1 -0
- package/package.json +54 -28
- package/sdk/fetch.run.ts +24 -0
- package/sdk/fetch.ts +145 -0
- package/sdk/sources.ts +166 -0
- package/tools/artifact-path.ts +9 -0
- package/tools/bench.run.ts +274 -0
- package/tools/build-wasm.run.ts +81 -0
- package/tools/generate-sections.run.ts +144 -0
- package/tools/generate.run.ts +144 -0
- package/tools/normalize.run.ts +35 -0
- package/tools/normalize.ts +475 -0
- package/wasm/registry-simd.wasm +0 -0
- package/wasm/registry.wasm +0 -0
- package/lib/address-key.ts +0 -46
- package/lib/geocode-handler.ts +0 -37
- package/lib/geojson.ts +0 -72
- package/lib/ingest.ts +0 -349
- package/lib/learned-scorer.ts +0 -134
- package/lib/map-html.ts +0 -287
- package/lib/models/crosssource-gbt-en-us.ts +0 -43
- package/lib/models/dedup-gbt-en-us.ts +0 -47
- package/lib/models/org-crosssource-gbt-en-us.ts +0 -43
- package/lib/reconcile.ts +0 -239
- package/lib/resolve.ts +0 -569
- package/out/address-key.d.ts +0 -34
- package/out/address-key.d.ts.map +0 -1
- package/out/address-key.js +0 -41
- package/out/address-key.js.map +0 -1
- package/out/geocode-handler.d.ts +0 -20
- package/out/geocode-handler.d.ts.map +0 -1
- package/out/geocode-handler.js +0 -29
- package/out/geocode-handler.js.map +0 -1
- package/out/geojson.d.ts +0 -28
- package/out/geojson.d.ts.map +0 -1
- package/out/geojson.js +0 -62
- package/out/geojson.js.map +0 -1
- package/out/ingest.d.ts +0 -173
- package/out/ingest.d.ts.map +0 -1
- package/out/ingest.js +0 -185
- package/out/ingest.js.map +0 -1
- package/out/learned-scorer.d.ts +0 -61
- package/out/learned-scorer.d.ts.map +0 -1
- package/out/learned-scorer.js +0 -91
- package/out/learned-scorer.js.map +0 -1
- package/out/map-html.d.ts +0 -39
- package/out/map-html.d.ts.map +0 -1
- package/out/map-html.js +0 -220
- package/out/map-html.js.map +0 -1
- package/out/models/crosssource-gbt-en-us.d.ts +0 -45
- package/out/models/crosssource-gbt-en-us.d.ts.map +0 -1
- package/out/models/crosssource-gbt-en-us.js +0 -40
- package/out/models/crosssource-gbt-en-us.js.map +0 -1
- package/out/models/dedup-gbt-en-us.d.ts +0 -44
- package/out/models/dedup-gbt-en-us.d.ts.map +0 -1
- package/out/models/dedup-gbt-en-us.js +0 -44
- package/out/models/dedup-gbt-en-us.js.map +0 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts +0 -45
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +0 -1
- package/out/models/org-crosssource-gbt-en-us.js +0 -40
- package/out/models/org-crosssource-gbt-en-us.js.map +0 -1
- package/out/reconcile.d.ts +0 -96
- package/out/reconcile.d.ts.map +0 -1
- package/out/reconcile.js +0 -127
- package/out/reconcile.js.map +0 -1
- package/out/resolve.d.ts +0 -264
- package/out/resolve.d.ts.map +0 -1
- package/out/resolve.js +0 -282
- package/out/resolve.js.map +0 -1
- package/out/tools/coverage-reconciliation.d.ts +0 -67
- package/out/tools/coverage-reconciliation.d.ts.map +0 -1
- package/out/tools/coverage-reconciliation.js +0 -113
- package/out/tools/coverage-reconciliation.js.map +0 -1
- package/out/tools/cross/dataset-correlation.d.ts +0 -61
- package/out/tools/cross/dataset-correlation.d.ts.map +0 -1
- package/out/tools/cross/dataset-correlation.js +0 -244
- package/out/tools/cross/dataset-correlation.js.map +0 -1
- package/out/tools/cross/source-threshold-sweep.d.ts +0 -60
- package/out/tools/cross/source-threshold-sweep.d.ts.map +0 -1
- package/out/tools/cross/source-threshold-sweep.js +0 -264
- package/out/tools/cross/source-threshold-sweep.js.map +0 -1
- package/out/tools/dedup-ceiling.d.ts +0 -62
- package/out/tools/dedup-ceiling.d.ts.map +0 -1
- package/out/tools/dedup-ceiling.js +0 -171
- package/out/tools/dedup-ceiling.js.map +0 -1
- package/out/tools/eval-geocoder.d.ts +0 -68
- package/out/tools/eval-geocoder.d.ts.map +0 -1
- package/out/tools/eval-geocoder.js +0 -13
- package/out/tools/eval-geocoder.js.map +0 -1
- package/out/tools/geocoder/namesake-probe.d.ts +0 -33
- package/out/tools/geocoder/namesake-probe.d.ts.map +0 -1
- package/out/tools/geocoder/namesake-probe.js +0 -60
- package/out/tools/geocoder/namesake-probe.js.map +0 -1
- package/out/tools/geocoder/vs-provided-coords.d.ts +0 -53
- package/out/tools/geocoder/vs-provided-coords.d.ts.map +0 -1
- package/out/tools/geocoder/vs-provided-coords.js +0 -161
- package/out/tools/geocoder/vs-provided-coords.js.map +0 -1
- package/out/tools/gold-set-sample.d.ts +0 -67
- package/out/tools/gold-set-sample.d.ts.map +0 -1
- package/out/tools/gold-set-sample.js +0 -81
- package/out/tools/gold-set-sample.js.map +0 -1
- package/out/tools/learned/scorer/clustering-eval.d.ts +0 -77
- package/out/tools/learned/scorer/clustering-eval.d.ts.map +0 -1
- package/out/tools/learned/scorer/clustering-eval.js +0 -207
- package/out/tools/learned/scorer/clustering-eval.js.map +0 -1
- package/out/tools/learned/scorer/crossstate-eval.d.ts +0 -65
- package/out/tools/learned/scorer/crossstate-eval.d.ts.map +0 -1
- package/out/tools/learned/scorer/crossstate-eval.js +0 -168
- package/out/tools/learned/scorer/crossstate-eval.js.map +0 -1
- package/out/tools/learned/scorer/eval.d.ts +0 -64
- package/out/tools/learned/scorer/eval.d.ts.map +0 -1
- package/out/tools/learned/scorer/eval.js +0 -275
- package/out/tools/learned/scorer/eval.js.map +0 -1
- package/out/tools/matcher-scale.d.ts +0 -40
- package/out/tools/matcher-scale.d.ts.map +0 -1
- package/out/tools/matcher-scale.js +0 -111
- package/out/tools/matcher-scale.js.map +0 -1
- package/out/tools/nppes/dedup-benchmark.d.ts +0 -82
- package/out/tools/nppes/dedup-benchmark.d.ts.map +0 -1
- package/out/tools/nppes/dedup-benchmark.js +0 -226
- package/out/tools/nppes/dedup-benchmark.js.map +0 -1
- package/out/tools/nppes/org-name.d.ts +0 -15
- package/out/tools/nppes/org-name.d.ts.map +0 -1
- package/out/tools/nppes/org-name.js +0 -6
- package/out/tools/nppes/org-name.js.map +0 -1
- package/out/tools/nppes/overmerge-packet.d.ts +0 -43
- package/out/tools/nppes/overmerge-packet.d.ts.map +0 -1
- package/out/tools/nppes/overmerge-packet.js +0 -54
- package/out/tools/nppes/overmerge-packet.js.map +0 -1
- package/out/tools/nppes/report.d.ts +0 -97
- package/out/tools/nppes/report.d.ts.map +0 -1
- package/out/tools/nppes/report.js +0 -178
- package/out/tools/nppes/report.js.map +0 -1
- package/out/tools/nppes/sample.d.ts +0 -101
- package/out/tools/nppes/sample.d.ts.map +0 -1
- package/out/tools/nppes/sample.js +0 -127
- package/out/tools/nppes/sample.js.map +0 -1
- package/out/tools/nppes/scoring.d.ts +0 -37
- package/out/tools/nppes/scoring.d.ts.map +0 -1
- package/out/tools/nppes/scoring.js +0 -81
- package/out/tools/nppes/scoring.js.map +0 -1
- package/out/tools/nppes/settings.d.ts +0 -41
- package/out/tools/nppes/settings.d.ts.map +0 -1
- package/out/tools/nppes/settings.js +0 -79
- package/out/tools/nppes/settings.js.map +0 -1
- package/out/tools/nppes/truth-grains.d.ts +0 -63
- package/out/tools/nppes/truth-grains.d.ts.map +0 -1
- package/out/tools/nppes/truth-grains.js +0 -142
- package/out/tools/nppes/truth-grains.js.map +0 -1
- package/out/tools/shared.d.ts +0 -325
- package/out/tools/shared.d.ts.map +0 -1
- package/out/tools/shared.js +0 -453
- package/out/tools/shared.js.map +0 -1
- package/out/tools/train/cross-gbt.d.ts +0 -89
- package/out/tools/train/cross-gbt.d.ts.map +0 -1
- package/out/tools/train/cross-gbt.js +0 -132
- package/out/tools/train/cross-gbt.js.map +0 -1
- package/out/tools/train/gbt.d.ts +0 -85
- package/out/tools/train/gbt.d.ts.map +0 -1
- package/out/tools/train/gbt.js +0 -155
- package/out/tools/train/gbt.js.map +0 -1
- package/out/tools/train/org-cross-gbt.d.ts +0 -85
- package/out/tools/train/org-cross-gbt.d.ts.map +0 -1
- package/out/tools/train/org-cross-gbt.js +0 -122
- package/out/tools/train/org-cross-gbt.js.map +0 -1
- package/out/tools/txhhsc-to-oarow.d.ts +0 -42
- package/out/tools/txhhsc-to-oarow.d.ts.map +0 -1
- package/out/tools/txhhsc-to-oarow.js +0 -78
- package/out/tools/txhhsc-to-oarow.js.map +0 -1
- package/out/tools/viz/browser.d.ts +0 -31
- package/out/tools/viz/browser.d.ts.map +0 -1
- package/out/tools/viz/browser.js +0 -26
- package/out/tools/viz/browser.js.map +0 -1
- package/out/tools/viz/cross-dataset-map.d.ts +0 -39
- package/out/tools/viz/cross-dataset-map.d.ts.map +0 -1
- package/out/tools/viz/cross-dataset-map.js +0 -84
- package/out/tools/viz/cross-dataset-map.js.map +0 -1
- package/out/tools/viz/geocode-first-surface.d.ts +0 -36
- package/out/tools/viz/geocode-first-surface.d.ts.map +0 -1
- package/out/tools/viz/geocode-first-surface.js +0 -234
- package/out/tools/viz/geocode-first-surface.js.map +0 -1
- package/out/tools/viz/render/map.d.ts +0 -42
- package/out/tools/viz/render/map.d.ts.map +0 -1
- package/out/tools/viz/render/map.js +0 -40
- package/out/tools/viz/render/map.js.map +0 -1
- package/out/tools/viz/render.d.ts +0 -46
- package/out/tools/viz/render.d.ts.map +0 -1
- package/out/tools/viz/render.js +0 -49
- package/out/tools/viz/render.js.map +0 -1
- package/out/tools/viz/source-provenance-map.d.ts +0 -57
- package/out/tools/viz/source-provenance-map.d.ts.map +0 -1
- package/out/tools/viz/source-provenance-map.js +0 -82
- package/out/tools/viz/source-provenance-map.js.map +0 -1
- package/out/tools/viz/yardstick-figure.d.ts +0 -22
- package/out/tools/viz/yardstick-figure.d.ts.map +0 -1
- package/out/tools/viz/yardstick-figure.js +0 -106
- package/out/tools/viz/yardstick-figure.js.map +0 -1
- package/tools/coverage-reconciliation.ts +0 -192
- package/tools/cross/dataset-correlation.ts +0 -380
- package/tools/cross/source-threshold-sweep.ts +0 -416
- package/tools/dedup-ceiling.ts +0 -225
- package/tools/eval-geocoder.ts +0 -77
- package/tools/geocoder/namesake-probe.ts +0 -91
- package/tools/geocoder/vs-provided-coords.ts +0 -232
- package/tools/gold-set-sample.ts +0 -147
- package/tools/learned/scorer/clustering-eval.ts +0 -349
- package/tools/learned/scorer/crossstate-eval.ts +0 -280
- package/tools/learned/scorer/eval.ts +0 -429
- package/tools/matcher-scale.ts +0 -185
- package/tools/nppes/dedup-benchmark.ts +0 -364
- package/tools/nppes/org-name.ts +0 -15
- package/tools/nppes/overmerge-packet.ts +0 -98
- package/tools/nppes/report.ts +0 -380
- package/tools/nppes/sample.ts +0 -250
- package/tools/nppes/scoring.ts +0 -115
- package/tools/nppes/settings.ts +0 -102
- package/tools/nppes/truth-grains.ts +0 -185
- package/tools/shared.ts +0 -743
- package/tools/train/cross-gbt.ts +0 -214
- package/tools/train/gbt.ts +0 -261
- package/tools/train/org-cross-gbt.ts +0 -189
- package/tools/txhhsc-to-oarow.ts +0 -118
- package/tools/viz/browser.ts +0 -41
- package/tools/viz/cross-dataset-map.ts +0 -133
- package/tools/viz/geocode-first-surface.ts +0 -305
- package/tools/viz/render/map.ts +0 -61
- package/tools/viz/render.ts +0 -103
- package/tools/viz/source-provenance-map.ts +0 -154
- package/tools/viz/yardstick-figure.ts +0 -197
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
* @file Pairwise cluster scoring for the NPPES benchmark — precision/recall/F1 and adjusted Rand of recovered clusters
|
|
6
|
-
* against a truth labeling, plus the over-merge / under-merge shape counts.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Pairs within a group of `n`.
|
|
10
|
-
*/
|
|
11
|
-
export const choose2 = (n) => (n * (n - 1)) / 2;
|
|
12
|
-
/**
|
|
13
|
-
* Score recovered clusters against a truth labeling.
|
|
14
|
-
*
|
|
15
|
-
* Pairwise rather than set-matching: a true pair is two records carrying the same `labelOf`,
|
|
16
|
-
* a predicted pair is two records in the same entity.
|
|
17
|
-
* `totalRecords` is the labeled population and only feeds the adjusted-Rand expectation,
|
|
18
|
-
* so it must be the whole record set rather than the clustered subset — a smaller value inflates ARI.
|
|
19
|
-
*/
|
|
20
|
-
export function scoreEntities(entities, labelOf, totalRecords) {
|
|
21
|
-
const npiTotals = new Map();
|
|
22
|
-
const npiClusters = new Map();
|
|
23
|
-
let sumCK = 0; // Σ C(n_ck, 2)
|
|
24
|
-
let sumCluster = 0; // Σ_c C(|c|, 2)
|
|
25
|
-
let singletons = 0;
|
|
26
|
-
let overMergedClusters = 0;
|
|
27
|
-
let recordsInOverMerged = 0;
|
|
28
|
-
let maxNpisFused = 0;
|
|
29
|
-
entities.forEach((e, ci) => {
|
|
30
|
-
const byNPI = new Map();
|
|
31
|
-
for (const rec of e.records) {
|
|
32
|
-
const lbl = labelOf(rec);
|
|
33
|
-
byNPI.set(lbl, (byNPI.get(lbl) ?? 0) + 1);
|
|
34
|
-
}
|
|
35
|
-
sumCluster += choose2(e.records.length);
|
|
36
|
-
if (e.records.length === 1) {
|
|
37
|
-
singletons++;
|
|
38
|
-
}
|
|
39
|
-
if (byNPI.size > 1) {
|
|
40
|
-
overMergedClusters++;
|
|
41
|
-
recordsInOverMerged += e.records.length;
|
|
42
|
-
maxNpisFused = Math.max(maxNpisFused, byNPI.size);
|
|
43
|
-
}
|
|
44
|
-
for (const [npi, n] of byNPI) {
|
|
45
|
-
sumCK += choose2(n);
|
|
46
|
-
npiTotals.set(npi, (npiTotals.get(npi) ?? 0) + n);
|
|
47
|
-
}
|
|
48
|
-
for (const rec of e.records) {
|
|
49
|
-
const lbl = labelOf(rec);
|
|
50
|
-
const s = npiClusters.get(lbl) ?? new Set();
|
|
51
|
-
s.add(ci);
|
|
52
|
-
npiClusters.set(lbl, s);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
let sumClass = 0;
|
|
56
|
-
// Σ_k C(|k|, 2)
|
|
57
|
-
for (const total of npiTotals.values()) {
|
|
58
|
-
sumClass += choose2(total);
|
|
59
|
-
}
|
|
60
|
-
const tp = sumCK;
|
|
61
|
-
const precision = tp + (sumCluster - tp) > 0 ? tp / sumCluster : 0;
|
|
62
|
-
const recall = sumClass > 0 ? tp / sumClass : 0;
|
|
63
|
-
const f1 = precision + recall > 0 ? (2 * precision * recall) / (precision + recall) : 0;
|
|
64
|
-
const expected = (sumCluster * sumClass) / choose2(totalRecords);
|
|
65
|
-
const maxIndex = (sumCluster + sumClass) / 2;
|
|
66
|
-
const ari = maxIndex - expected !== 0 ? (tp - expected) / (maxIndex - expected) : 1;
|
|
67
|
-
const splitNpis = [...npiClusters.values()].filter((s) => s.size > 1).length;
|
|
68
|
-
return {
|
|
69
|
-
precision,
|
|
70
|
-
recall,
|
|
71
|
-
f1,
|
|
72
|
-
ari,
|
|
73
|
-
clusters: entities.length,
|
|
74
|
-
singletons,
|
|
75
|
-
overMergedClusters,
|
|
76
|
-
recordsInOverMerged,
|
|
77
|
-
maxNpisFused,
|
|
78
|
-
splitNpis,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=scoring.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../../tools/nppes/scoring.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAkB/D;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC5B,QAAmC,EACnC,OAAsC,EACtC,YAAoB;IAEpB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC3C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAA;IAClD,IAAI,KAAK,GAAG,CAAC,CAAA,CAAC,eAAe;IAC7B,IAAI,UAAU,GAAG,CAAC,CAAA,CAAC,gBAAgB;IACnC,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,IAAI,kBAAkB,GAAG,CAAC,CAAA;IAC1B,IAAI,mBAAmB,GAAG,CAAC,CAAA;IAC3B,I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M,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAA;IAE5E,OAAO;QACN,SAAS;QACT,MAAM;QACN,EAAE;QACF,GAAG;QACH,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,UAAU;QACV,kBAAkB;QAClB,mBAAmB;QACnB,YAAY;QACZ,SAAS;KACT,CAAA;AACF,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The comparison-model setting progression the NPPES benchmark walks, where each row turns one
|
|
7
|
-
* setting on so its marginal effect is isolated.
|
|
8
|
-
*/
|
|
9
|
-
import type { TermFrequencyTable } from "@mailwoman/match";
|
|
10
|
-
/**
|
|
11
|
-
* The subset of `ResolveConfig` this progression varies.
|
|
12
|
-
*/
|
|
13
|
-
export interface SettingConfig {
|
|
14
|
-
addressFrequency?: TermFrequencyTable | false;
|
|
15
|
-
collapseSpatial?: boolean;
|
|
16
|
-
discriminators?: string[];
|
|
17
|
-
requireCorroboration?: boolean;
|
|
18
|
-
usePhone?: boolean;
|
|
19
|
-
linkage?: "single" | "average";
|
|
20
|
-
exactDiscriminators?: string[];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* One row of the progression.
|
|
24
|
-
*/
|
|
25
|
-
export interface Setting {
|
|
26
|
-
label: string;
|
|
27
|
-
config: SettingConfig;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Build the progression against a corpus-wide address-frequency table.
|
|
31
|
-
*
|
|
32
|
-
* Every row sets both `collapseSpatial` and `addressFrequency` explicitly,
|
|
33
|
-
* because the proven settings are default-on in `resolveEntities`.
|
|
34
|
-
* Leave either implicit and the flipped default silently follows the inverse-address-frequency row.
|
|
35
|
-
* That makes the delta read as 0.
|
|
36
|
-
*
|
|
37
|
-
* Every row is fed the corpus-wide table, the realistic deployment, so the zero-config
|
|
38
|
-
* default with its input-scoped table has to be measured separately.
|
|
39
|
-
*/
|
|
40
|
-
export declare function buildSettings(addressFrequency: TermFrequencyTable): Setting[];
|
|
41
|
-
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../tools/nppes/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAE1D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,gBAAgB,CAAC,EAAE,kBAAkB,GAAG,KAAK,CAAA;IAC7C,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,aAAa,CAAA;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,gBAAgB,EAAE,kBAAkB,GAAG,OAAO,EAAE,CA0D7E"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The comparison-model setting progression the NPPES benchmark walks, where each row turns one
|
|
7
|
-
* setting on so its marginal effect is isolated.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Build the progression against a corpus-wide address-frequency table.
|
|
11
|
-
*
|
|
12
|
-
* Every row sets both `collapseSpatial` and `addressFrequency` explicitly,
|
|
13
|
-
* because the proven settings are default-on in `resolveEntities`.
|
|
14
|
-
* Leave either implicit and the flipped default silently follows the inverse-address-frequency row.
|
|
15
|
-
* That makes the delta read as 0.
|
|
16
|
-
*
|
|
17
|
-
* Every row is fed the corpus-wide table, the realistic deployment, so the zero-config
|
|
18
|
-
* default with its input-scoped table has to be measured separately.
|
|
19
|
-
*/
|
|
20
|
-
export function buildSettings(addressFrequency) {
|
|
21
|
-
return [
|
|
22
|
-
{
|
|
23
|
-
label: "baseline (legacy: address-key + distance, settings OFF)",
|
|
24
|
-
config: { collapseSpatial: false, addressFrequency: false },
|
|
25
|
-
},
|
|
26
|
-
{ label: "+ inverse-address-frequency (#617, corpus-wide)", config: { collapseSpatial: false, addressFrequency } },
|
|
27
|
-
{ label: "+ collapsed spatial signal (A1, #625)", config: { collapseSpatial: true, addressFrequency } },
|
|
28
|
-
{
|
|
29
|
-
label: "+ authorized-official discriminator (#625)",
|
|
30
|
-
config: { collapseSpatial: true, addressFrequency, discriminators: ["authorizedOfficial"] },
|
|
31
|
-
},
|
|
32
|
-
// The over-merge settings each build on the collapsed-spatial and discriminator stack,
|
|
33
|
-
// so the marginal effect of each is isolated.
|
|
34
|
-
{
|
|
35
|
-
label: "+ require name/org corroboration (A2, #625)",
|
|
36
|
-
config: {
|
|
37
|
-
collapseSpatial: true,
|
|
38
|
-
addressFrequency,
|
|
39
|
-
discriminators: ["authorizedOfficial"],
|
|
40
|
-
requireCorroboration: true,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
label: "+ phone comparison (A3, #625)",
|
|
45
|
-
config: {
|
|
46
|
-
collapseSpatial: true,
|
|
47
|
-
addressFrequency,
|
|
48
|
-
discriminators: ["authorizedOfficial"],
|
|
49
|
-
requireCorroboration: true,
|
|
50
|
-
usePhone: true,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
label: "+ average-linkage clustering (A4, #625, full A1–A4 stack)",
|
|
55
|
-
config: {
|
|
56
|
-
collapseSpatial: true,
|
|
57
|
-
addressFrequency,
|
|
58
|
-
discriminators: ["authorizedOfficial"],
|
|
59
|
-
requireCorroboration: true,
|
|
60
|
-
usePhone: true,
|
|
61
|
-
linkage: "average",
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
// The taxonomy code-set discriminator uses set-overlap agreement over the NPI's 15 taxonomy slots.
|
|
65
|
-
// Co-located distinct providers mostly have disjoint sets, while an entity's
|
|
66
|
-
// own records always share theirs.
|
|
67
|
-
// It is stacked on the best prior classical config.
|
|
68
|
-
{
|
|
69
|
-
label: "+ taxonomy code-set discriminator (A5, #625)",
|
|
70
|
-
config: {
|
|
71
|
-
collapseSpatial: true,
|
|
72
|
-
addressFrequency,
|
|
73
|
-
discriminators: ["authorizedOfficial"],
|
|
74
|
-
exactDiscriminators: ["taxonomy"],
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../tools/nppes/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAyBH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,gBAAoC;IACjE,OAAO;QACN;YACC,KAAK,EAAE,yDAAyD;YAChE,MAAM,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE;SAC3D;QACD,EAAE,KAAK,EAAE,iDAAiD,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE;QAClH,EAAE,KAAK,EAAE,uCAAuC,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE;QACvG;YACC,KAAK,EAAE,4CAA4C;YACnD,MAAM,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC,oBAAoB,CAAC,EAAE;SAC3F;QACD,uFAAuF;QACvF,8CAA8C;QAC9C;YACC,KAAK,EAAE,6CAA6C;YACpD,MAAM,EAAE;gBACP,eAAe,EAAE,IAAI;gBACrB,gBAAgB;gBAChB,cAAc,EAAE,CAAC,oBAAoB,CAAC;gBACtC,oBAAoB,EAAE,IAAI;aAC1B;SACD;QACD;YACC,KAAK,EAAE,+BAA+B;YACtC,MAAM,EAAE;gBACP,eAAe,EAAE,IAAI;gBACrB,gBAAgB;gBAChB,cAAc,EAAE,CAAC,oBAAoB,CAAC;gBACtC,oBAAoB,EAAE,IAAI;gBAC1B,QAAQ,EAAE,IAAI;aACd;SACD;QACD;YACC,KAAK,EAAE,2DAA2D;YAClE,MAAM,EAAE;gBACP,eAAe,EAAE,IAAI;gBACrB,gBAAgB;gBAChB,cAAc,EAAE,CAAC,oBAAoB,CAAC;gBACtC,oBAAoB,EAAE,IAAI;gBAC1B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,SAAS;aAClB;SACD;QACD,mGAAmG;QACnG,6EAA6E;QAC7E,mCAAmC;QACnC,oDAAoD;QACpD;YACC,KAAK,EAAE,8CAA8C;YACrD,MAAM,EAAE;gBACP,eAAe,EAAE,IAAI;gBACrB,gBAAgB;gBAChB,cAAc,EAAE,CAAC,oBAAoB,CAAC;gBACtC,mBAAmB,EAAE,CAAC,UAAU,CAAC;aACjC;SACD;KACD,CAAA;AACF,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
* @file Defines union-find truth labels that group co-located NPIs for one organization.
|
|
6
|
-
* One label uses address strings. Another uses a haversine radius. The third uses H3 cells.
|
|
7
|
-
*/
|
|
8
|
-
import type { GeoCoordinate } from "@mailwoman/spatial";
|
|
9
|
-
import type { SourceRecord } from "#index";
|
|
10
|
-
import { type NPIPrimary } from "#tools/nppes/org-name";
|
|
11
|
-
/**
|
|
12
|
-
* Same-building distance for the coordinate grain — the `DEFAULT_DISTANCE_LEVELS` grain.
|
|
13
|
-
*/
|
|
14
|
-
export declare const COLOCATION_KM = 0.05;
|
|
15
|
-
/**
|
|
16
|
-
* A truth labeling: the entity class a record belongs to.
|
|
17
|
-
*/
|
|
18
|
-
export type TruthLabel = (rec: SourceRecord) => string;
|
|
19
|
-
/**
|
|
20
|
-
* An NPI's primary practice coordinate.
|
|
21
|
-
*
|
|
22
|
-
* Returns the first geocoded record for the NPI.
|
|
23
|
-
* The sample builder adds this primary row before alternate-name and mailing variants.
|
|
24
|
-
*/
|
|
25
|
-
export declare function collectPrimaryCoordinates(records: readonly SourceRecord[]): Map<string, GeoCoordinate>;
|
|
26
|
-
/**
|
|
27
|
-
* The string-keyed org-name truth: same NPI ⇒ same entity
|
|
28
|
-
* (so an NPI's records stay together and recall is preserved), plus union two NPIs
|
|
29
|
-
* at the same address KEY whose primary org names agree.
|
|
30
|
-
*
|
|
31
|
-
* The address-string block provides a conservative lower bound.
|
|
32
|
-
* `1504 Taub loop` and `1504 Taub LP STE 100` key apart even though they are one building,
|
|
33
|
-
* so a correct merge across them is still charged as an error.
|
|
34
|
-
* The coordinate grain below is the tighter reading.
|
|
35
|
-
*
|
|
36
|
-
* Neither method uses the NPPES subpart flag.
|
|
37
|
-
* The gold set misses 37% of cases when grouped by that flag.
|
|
38
|
-
*/
|
|
39
|
-
export declare function buildOrgNameGrain(npiPrimary: Map<string, NPIPrimary>): TruthLabel;
|
|
40
|
-
/**
|
|
41
|
-
* The coordinate-keyed org-name truth: union same-org NPIs whose primary practice
|
|
42
|
-
* coordinates fall within {@linkcode COLOCATION_KM}.
|
|
43
|
-
*
|
|
44
|
-
* A geocoded-building block catches same-building pairs that the address string keys apart,
|
|
45
|
-
* so this F1 is at or above the string grain's.
|
|
46
|
-
* The Jaccard test still blocks distinct co-located orgs.
|
|
47
|
-
*
|
|
48
|
-
* Compares every sampled NPI pair.
|
|
49
|
-
* This is small enough for the sample and has no cell-boundary artifact.
|
|
50
|
-
*/
|
|
51
|
-
export declare function buildOrgNameCoordGrain(npiPrimary: Map<string, NPIPrimary>, npiCoord: Map<string, GeoCoordinate>): TruthLabel;
|
|
52
|
-
/**
|
|
53
|
-
* The H3-cell org-name truth.
|
|
54
|
-
*
|
|
55
|
-
* The same building grain keyed on a cell instead of a radius, so co-location
|
|
56
|
-
* blocking is O(n) rather than O(n²).
|
|
57
|
-
*
|
|
58
|
-
* A robustness check on the coordinate grain rather than a replacement: a hard cell boundary can split
|
|
59
|
-
* a same-building pair into adjacent cells, so this slightly under-counts relative to the radius.
|
|
60
|
-
* Coarser resolutions absorb more of that.
|
|
61
|
-
*/
|
|
62
|
-
export declare function buildOrgNameH3Grain(npiPrimary: Map<string, NPIPrimary>, npiCoord: Map<string, GeoCoordinate>, h3Res: number): TruthLabel;
|
|
63
|
-
//# sourceMappingURL=truth-grains.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"truth-grains.d.ts","sourceRoot":"","sources":["../../../tools/nppes/truth-grains.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,aAAa,OAAO,CAAA;AAEjC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAA;AA2BtD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAYtG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,CAoBjF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAClC,UAAU,CA0BZ;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EACpC,KAAK,EAAE,MAAM,GACX,UAAU,CAqBZ"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
* @file Defines union-find truth labels that group co-located NPIs for one organization.
|
|
6
|
-
* One label uses address strings. Another uses a haversine radius. The third uses H3 cells.
|
|
7
|
-
*/
|
|
8
|
-
import { createUnionFind } from "@mailwoman/core/utils";
|
|
9
|
-
import { jaccard } from "@mailwoman/match";
|
|
10
|
-
import { haversine } from "@mailwoman/spatial/geometries/point/distance";
|
|
11
|
-
import { latLngToCell } from "@sister.software/h3";
|
|
12
|
-
import { ORG_TAU } from "#tools/nppes/org-name";
|
|
13
|
-
/**
|
|
14
|
-
* Same-building distance for the coordinate grain — the `DEFAULT_DISTANCE_LEVELS` grain.
|
|
15
|
-
*/
|
|
16
|
-
export const COLOCATION_KM = 0.05;
|
|
17
|
-
/**
|
|
18
|
-
* Union every pair in each block whose org names agree.
|
|
19
|
-
*
|
|
20
|
-
* Checks every pair within a block.
|
|
21
|
-
* This preserves the per-pair Jaccard test.
|
|
22
|
-
*
|
|
23
|
-
* Therefore, a chain of near-matches cannot transitively fuse two distinct
|
|
24
|
-
* co-located orgs unless some pair agrees.
|
|
25
|
-
*/
|
|
26
|
-
function unionAgreeingPairs(blocks, npiPrimary, uf) {
|
|
27
|
-
for (const group of blocks) {
|
|
28
|
-
for (let i = 0; i < group.length; i++) {
|
|
29
|
-
for (let j = i + 1; j < group.length; j++) {
|
|
30
|
-
if (jaccard(npiPrimary.get(group[i]).tokens, npiPrimary.get(group[j]).tokens) >= ORG_TAU) {
|
|
31
|
-
uf.union(group[i], group[j]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* An NPI's primary practice coordinate.
|
|
39
|
-
*
|
|
40
|
-
* Returns the first geocoded record for the NPI.
|
|
41
|
-
* The sample builder adds this primary row before alternate-name and mailing variants.
|
|
42
|
-
*/
|
|
43
|
-
export function collectPrimaryCoordinates(records) {
|
|
44
|
-
const npiCoord = new Map();
|
|
45
|
-
for (const rec of records) {
|
|
46
|
-
const c = rec.address?.geocode?.coordinate;
|
|
47
|
-
if (c && !npiCoord.has(rec.id)) {
|
|
48
|
-
npiCoord.set(rec.id, c);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return npiCoord;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* The string-keyed org-name truth: same NPI ⇒ same entity
|
|
55
|
-
* (so an NPI's records stay together and recall is preserved), plus union two NPIs
|
|
56
|
-
* at the same address KEY whose primary org names agree.
|
|
57
|
-
*
|
|
58
|
-
* The address-string block provides a conservative lower bound.
|
|
59
|
-
* `1504 Taub loop` and `1504 Taub LP STE 100` key apart even though they are one building,
|
|
60
|
-
* so a correct merge across them is still charged as an error.
|
|
61
|
-
* The coordinate grain below is the tighter reading.
|
|
62
|
-
*
|
|
63
|
-
* Neither method uses the NPPES subpart flag.
|
|
64
|
-
* The gold set misses 37% of cases when grouped by that flag.
|
|
65
|
-
*/
|
|
66
|
-
export function buildOrgNameGrain(npiPrimary) {
|
|
67
|
-
const uf = createUnionFind();
|
|
68
|
-
const byAddr = new Map();
|
|
69
|
-
for (const [npi, info] of npiPrimary) {
|
|
70
|
-
uf.find(npi);
|
|
71
|
-
// seed
|
|
72
|
-
if (!info.addrKey)
|
|
73
|
-
continue;
|
|
74
|
-
if (!byAddr.has(info.addrKey)) {
|
|
75
|
-
byAddr.set(info.addrKey, []);
|
|
76
|
-
}
|
|
77
|
-
byAddr.get(info.addrKey).push(npi);
|
|
78
|
-
}
|
|
79
|
-
unionAgreeingPairs(byAddr.values(), npiPrimary, uf);
|
|
80
|
-
return (rec) => (npiPrimary.has(rec.id) ? uf.find(rec.id) : rec.id);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* The coordinate-keyed org-name truth: union same-org NPIs whose primary practice
|
|
84
|
-
* coordinates fall within {@linkcode COLOCATION_KM}.
|
|
85
|
-
*
|
|
86
|
-
* A geocoded-building block catches same-building pairs that the address string keys apart,
|
|
87
|
-
* so this F1 is at or above the string grain's.
|
|
88
|
-
* The Jaccard test still blocks distinct co-located orgs.
|
|
89
|
-
*
|
|
90
|
-
* Compares every sampled NPI pair.
|
|
91
|
-
* This is small enough for the sample and has no cell-boundary artifact.
|
|
92
|
-
*/
|
|
93
|
-
export function buildOrgNameCoordGrain(npiPrimary, npiCoord) {
|
|
94
|
-
const uf = createUnionFind();
|
|
95
|
-
const coLocated = [...npiPrimary.keys()].filter((n) => npiCoord.has(n));
|
|
96
|
-
for (const n of npiPrimary.keys()) {
|
|
97
|
-
uf.find(n);
|
|
98
|
-
}
|
|
99
|
-
// seed every NPI (un-geocoded ones stay singletons)
|
|
100
|
-
for (let i = 0; i < coLocated.length; i++) {
|
|
101
|
-
for (let j = i + 1; j < coLocated.length; j++) {
|
|
102
|
-
const a = coLocated[i];
|
|
103
|
-
const b = coLocated[j];
|
|
104
|
-
const coordA = npiCoord.get(a);
|
|
105
|
-
const coordB = npiCoord.get(b);
|
|
106
|
-
if (haversine(coordA.latitude, coordA.longitude, coordB.latitude, coordB.longitude) > COLOCATION_KM)
|
|
107
|
-
continue;
|
|
108
|
-
if (jaccard(npiPrimary.get(a).tokens, npiPrimary.get(b).tokens) >= ORG_TAU) {
|
|
109
|
-
uf.union(a, b);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return (rec) => (npiPrimary.has(rec.id) ? uf.find(rec.id) : rec.id);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* The H3-cell org-name truth.
|
|
117
|
-
*
|
|
118
|
-
* The same building grain keyed on a cell instead of a radius, so co-location
|
|
119
|
-
* blocking is O(n) rather than O(n²).
|
|
120
|
-
*
|
|
121
|
-
* A robustness check on the coordinate grain rather than a replacement: a hard cell boundary can split
|
|
122
|
-
* a same-building pair into adjacent cells, so this slightly under-counts relative to the radius.
|
|
123
|
-
* Coarser resolutions absorb more of that.
|
|
124
|
-
*/
|
|
125
|
-
export function buildOrgNameH3Grain(npiPrimary, npiCoord, h3Res) {
|
|
126
|
-
const uf = createUnionFind();
|
|
127
|
-
const byCell = new Map();
|
|
128
|
-
for (const n of npiPrimary.keys()) {
|
|
129
|
-
uf.find(n); // seed every NPI (un-geocoded ones stay singletons)
|
|
130
|
-
const c = npiCoord.get(n);
|
|
131
|
-
if (!c)
|
|
132
|
-
continue;
|
|
133
|
-
const cell = latLngToCell(c.latitude, c.longitude, h3Res);
|
|
134
|
-
if (!byCell.has(cell)) {
|
|
135
|
-
byCell.set(cell, []);
|
|
136
|
-
}
|
|
137
|
-
byCell.get(cell).push(n);
|
|
138
|
-
}
|
|
139
|
-
unionAgreeingPairs(byCell.values(), npiPrimary, uf);
|
|
140
|
-
return (rec) => (npiPrimary.has(rec.id) ? uf.find(rec.id) : rec.id);
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=truth-grains.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tru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