@mailwoman/registry 10.7.0 → 11.0.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 +26 -0
- package/lib/artifacts/iata-airport/membership.ts +26 -0
- package/lib/artifacts/iata-airport/records.ts +26 -0
- package/lib/artifacts/iso3166-1/alpha2-membership.ts +26 -0
- package/lib/artifacts/iso3166-1/alpha3-membership.ts +26 -0
- package/lib/artifacts/iso3166-1/records.ts +26 -0
- package/lib/errors.ts +44 -0
- package/lib/iata/airports/records.ts +174 -0
- package/lib/iata/airports/validate.ts +49 -0
- package/lib/index.ts +25 -15
- 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 +149 -0
- package/lib/iso3166/relations.ts +30 -0
- package/lib/key.ts +146 -0
- package/lib/normalize.ts +31 -0
- package/lib/overlap/country-airport.ts +108 -0
- package/lib/rgy1/base64.ts +24 -0
- package/lib/rgy1/reader.ts +316 -0
- package/lib/rgy1/sections.generated.ts +79 -0
- package/lib/rgy1/views.ts +267 -0
- package/lib/types.ts +88 -74
- package/lib/wasm.ts +285 -0
- package/out/artifacts/country-airport-collision.d.ts +15 -0
- package/out/artifacts/country-airport-collision.d.ts.map +1 -0
- package/out/artifacts/country-airport-collision.js +21 -0
- package/out/artifacts/country-airport-collision.js.map +1 -0
- package/out/artifacts/iata-airport/membership.d.ts +15 -0
- package/out/artifacts/iata-airport/membership.d.ts.map +1 -0
- package/out/artifacts/iata-airport/membership.js +21 -0
- package/out/artifacts/iata-airport/membership.js.map +1 -0
- package/out/artifacts/iata-airport/records.d.ts +15 -0
- package/out/artifacts/iata-airport/records.d.ts.map +1 -0
- package/out/artifacts/iata-airport/records.js +21 -0
- package/out/artifacts/iata-airport/records.js.map +1 -0
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts +15 -0
- package/out/artifacts/iso3166-1/alpha2-membership.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/alpha2-membership.js +21 -0
- package/out/artifacts/iso3166-1/alpha2-membership.js.map +1 -0
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts +15 -0
- package/out/artifacts/iso3166-1/alpha3-membership.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/alpha3-membership.js +21 -0
- package/out/artifacts/iso3166-1/alpha3-membership.js.map +1 -0
- package/out/artifacts/iso3166-1/records.d.ts +15 -0
- package/out/artifacts/iso3166-1/records.d.ts.map +1 -0
- package/out/artifacts/iso3166-1/records.js +21 -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 +35 -0
- package/out/errors.js.map +1 -0
- package/out/iata/airports/records.d.ts +44 -0
- package/out/iata/airports/records.d.ts.map +1 -0
- package/out/iata/airports/records.js +137 -0
- package/out/iata/airports/records.js.map +1 -0
- package/out/iata/airports/validate.d.ts +27 -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 +19 -15
- package/out/index.d.ts.map +1 -1
- package/out/index.js +14 -15
- package/out/index.js.map +1 -1
- package/out/inspect.d.ts +38 -0
- package/out/inspect.d.ts.map +1 -0
- package/out/inspect.js +33 -0
- package/out/inspect.js.map +1 -0
- package/out/iso3166/alpha2.d.ts +24 -0
- package/out/iso3166/alpha2.d.ts.map +1 -0
- package/out/iso3166/alpha2.js +41 -0
- package/out/iso3166/alpha2.js.map +1 -0
- package/out/iso3166/alpha3.d.ts +29 -0
- package/out/iso3166/alpha3.d.ts.map +1 -0
- package/out/iso3166/alpha3.js +44 -0
- package/out/iso3166/alpha3.js.map +1 -0
- package/out/iso3166/records.d.ts +38 -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 +20 -0
- package/out/iso3166/relations.d.ts.map +1 -0
- package/out/iso3166/relations.js +27 -0
- package/out/iso3166/relations.js.map +1 -0
- package/out/key.d.ts +68 -0
- package/out/key.d.ts.map +1 -0
- package/out/key.js +122 -0
- package/out/key.js.map +1 -0
- package/out/normalize.d.ts +25 -0
- package/out/normalize.d.ts.map +1 -0
- package/out/normalize.js +21 -0
- package/out/normalize.js.map +1 -0
- package/out/overlap/country-airport.d.ts +57 -0
- package/out/overlap/country-airport.d.ts.map +1 -0
- package/out/overlap/country-airport.js +71 -0
- package/out/overlap/country-airport.js.map +1 -0
- package/out/rgy1/base64.d.ts +15 -0
- package/out/rgy1/base64.d.ts.map +1 -0
- package/out/rgy1/base64.js +22 -0
- package/out/rgy1/base64.js.map +1 -0
- package/out/rgy1/reader.d.ts +103 -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 +54 -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 +96 -0
- package/out/rgy1/views.d.ts.map +1 -0
- package/out/rgy1/views.js +218 -0
- package/out/rgy1/views.js.map +1 -0
- package/out/sdk/fetch.d.ts +53 -0
- package/out/sdk/fetch.d.ts.map +1 -0
- package/out/sdk/fetch.js +107 -0
- package/out/sdk/fetch.js.map +1 -0
- package/out/sdk/fetch.run.d.ts +14 -0
- package/out/sdk/fetch.run.d.ts.map +1 -0
- package/out/sdk/fetch.run.js +20 -0
- package/out/sdk/fetch.run.js.map +1 -0
- package/out/sdk/sources.d.ts +111 -0
- package/out/sdk/sources.d.ts.map +1 -0
- package/out/sdk/sources.js +98 -0
- package/out/sdk/sources.js.map +1 -0
- package/out/tools/artifact-path.d.ts +10 -0
- package/out/tools/artifact-path.d.ts.map +1 -0
- package/out/tools/artifact-path.js +12 -0
- package/out/tools/artifact-path.js.map +1 -0
- package/out/tools/bench.run.d.ts +19 -0
- package/out/tools/bench.run.d.ts.map +1 -0
- package/out/tools/bench.run.js +204 -0
- package/out/tools/bench.run.js.map +1 -0
- package/out/tools/build-wasm.run.d.ts +18 -0
- package/out/tools/build-wasm.run.d.ts.map +1 -0
- package/out/tools/build-wasm.run.js +71 -0
- package/out/tools/build-wasm.run.js.map +1 -0
- package/out/tools/generate-sections.run.d.ts +13 -0
- package/out/tools/generate-sections.run.d.ts.map +1 -0
- package/out/tools/generate-sections.run.js +136 -0
- package/out/tools/generate-sections.run.js.map +1 -0
- package/out/tools/generate.run.d.ts +18 -0
- package/out/tools/generate.run.d.ts.map +1 -0
- package/out/tools/generate.run.js +118 -0
- package/out/tools/generate.run.js.map +1 -0
- package/out/tools/normalize.d.ts +155 -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 +14 -0
- package/out/tools/normalize.run.d.ts.map +1 -0
- package/out/tools/normalize.run.js +29 -0
- package/out/tools/normalize.run.js.map +1 -0
- package/out/types.d.ts +90 -76
- package/out/types.d.ts.map +1 -1
- package/out/types.js +20 -4
- package/out/types.js.map +1 -1
- package/out/wasm.d.ts +98 -0
- package/out/wasm.d.ts.map +1 -0
- package/out/wasm.js +137 -0
- package/out/wasm.js.map +1 -0
- package/package.json +49 -28
- package/sdk/fetch.run.ts +24 -0
- package/sdk/fetch.ts +146 -0
- package/sdk/sources.ts +162 -0
- package/tools/artifact-path.ts +12 -0
- package/tools/bench.run.ts +265 -0
- package/tools/build-wasm.run.ts +82 -0
- package/tools/generate-sections.run.ts +152 -0
- package/tools/generate.run.ts +146 -0
- package/tools/normalize.run.ts +36 -0
- package/tools/normalize.ts +474 -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 -73
- 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 -570
- 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 -63
- 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 -139
- 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 -181
- 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
package/lib/ingest.ts
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Column mapping and normalization are pure. The caller injects geocoding, so this package never imports the neural parser, resolver, or extracts.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { isPresent } from "@mailwoman/core/objects"
|
|
10
|
-
import type { AddressGeocode, PostalAddress } from "@mailwoman/record"
|
|
11
|
-
import { canonicalizeOrganizationName, parsePersonName, toPostalAddress, withGeocode } from "@mailwoman/record"
|
|
12
|
-
import type { PathBuilderLike } from "path-ts"
|
|
13
|
-
import { type AsyncSequence, CSVSpliterator, Delimiters } from "spliterator"
|
|
14
|
-
|
|
15
|
-
import type { SourceRecord } from "#types"
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Resolve a raw address string into a {@link PostalAddress}, the entry point to mailwoman's geocoder.
|
|
19
|
-
*/
|
|
20
|
-
export type GeocodeAddress = (raw: string) => Promise<PostalAddress | null> | PostalAddress | null
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The column delimiters a tabular source may declare, by name, each the spliterator's own byte.
|
|
24
|
-
*
|
|
25
|
-
* The `satisfies` clause makes a delimiter name spliterator no longer ships a compile error
|
|
26
|
-
* rather than a silently parallel vocabulary.
|
|
27
|
-
*/
|
|
28
|
-
const COLUMN_DELIMITERS = {
|
|
29
|
-
comma: Delimiters.Comma,
|
|
30
|
-
tab: Delimiters.Tab,
|
|
31
|
-
} as const satisfies Partial<Record<Lowercase<keyof typeof Delimiters>, (typeof Delimiters)[keyof typeof Delimiters]>>
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Column delimiter of a delimited source.
|
|
35
|
-
*/
|
|
36
|
-
export type Delimiter = keyof typeof COLUMN_DELIMITERS
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Infer the delimiter from a path's extension (`.tsv` → tab, else comma).
|
|
40
|
-
*/
|
|
41
|
-
export function delimiterFor(path: string): Delimiter {
|
|
42
|
-
return /\.tsv$/i.test(path) ? "tab" : "comma"
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Stream a delimited file's rows lazily as header-keyed objects.
|
|
47
|
-
*
|
|
48
|
-
* @returns The spliterator's own {@linkcode AsyncSequence}, whose `map`/`filter`
|
|
49
|
-
* fuse into the same pull loop.
|
|
50
|
-
* An `async function*` wrapper would add an async frame per row and remove those operators.
|
|
51
|
-
*/
|
|
52
|
-
export function streamRows(
|
|
53
|
-
source: PathBuilderLike,
|
|
54
|
-
opts: { delimiter?: Delimiter } = {}
|
|
55
|
-
): AsyncSequence<Record<string, string>> {
|
|
56
|
-
const path = source.toString()
|
|
57
|
-
|
|
58
|
-
return CSVSpliterator.fromAsync<Record<string, string>>(path, {
|
|
59
|
-
columnDelimiter: COLUMN_DELIMITERS[opts.delimiter ?? delimiterFor(path)],
|
|
60
|
-
// A {@linkcode ColumnMapping} holds columns in the publisher's spelling rather than a
|
|
61
|
-
// normalized key such as `facility_name`, so the keys must arrive as the file writes them.
|
|
62
|
-
// The reader's default normalizes.
|
|
63
|
-
normalizeKeys: false,
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Maps dataset columns to record fields, where a field may draw from several columns joined with spaces.
|
|
69
|
-
*/
|
|
70
|
-
export interface ColumnMapping {
|
|
71
|
-
/**
|
|
72
|
-
* Column holding a stable row id, falling back to the row index.
|
|
73
|
-
*/
|
|
74
|
-
id?: string
|
|
75
|
-
/**
|
|
76
|
-
* A literal provenance label for every row (not a column).
|
|
77
|
-
*/
|
|
78
|
-
source?: string
|
|
79
|
-
name?: string | string[]
|
|
80
|
-
organization?: string | string[]
|
|
81
|
-
address?: string | string[]
|
|
82
|
-
phone?: string
|
|
83
|
-
email?: string
|
|
84
|
-
/**
|
|
85
|
-
* Extra secondary-identifier fields mapped to the column(s) to draw each from, landing
|
|
86
|
-
* on `SourceRecord.attributes` under the same key for the matcher's `discriminators`.
|
|
87
|
-
*/
|
|
88
|
-
attributes?: Record<string, string | string[]>
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Best-effort {@link ColumnMapping} inferred from a header row, the "point it at any CSV" convenience.
|
|
93
|
-
*/
|
|
94
|
-
export function inferMapping(header: readonly string[]): ColumnMapping {
|
|
95
|
-
// Pad to whole-token boundaries so "state" doesn't match inside "statement".
|
|
96
|
-
const tok = (h: string) =>
|
|
97
|
-
` ${h
|
|
98
|
-
.toLowerCase()
|
|
99
|
-
.replaceAll(/[^a-z0-9]+/g, " ")
|
|
100
|
-
.trim()} `
|
|
101
|
-
|
|
102
|
-
const mapping: ColumnMapping = {}
|
|
103
|
-
const name: string[] = []
|
|
104
|
-
const address: string[] = []
|
|
105
|
-
|
|
106
|
-
for (const column of header) {
|
|
107
|
-
const h = tok(column)
|
|
108
|
-
const has = (...words: string[]): boolean => words.some((w) => h.includes(` ${w} `))
|
|
109
|
-
|
|
110
|
-
if (!mapping.email && has("email", "e mail")) {
|
|
111
|
-
mapping.email = column
|
|
112
|
-
} else if (!mapping.phone && has("phone", "telephone", "tel", "mobile", "cell")) {
|
|
113
|
-
mapping.phone = column
|
|
114
|
-
} else if (!mapping.id && has("id", "npi", "ein", "frn", "spin", "uuid", "guid", "key")) {
|
|
115
|
-
mapping.id = column
|
|
116
|
-
} else if (has("org", "organization", "organisation", "company", "business", "facility", "agency", "employer")) {
|
|
117
|
-
mapping.organization ??= column
|
|
118
|
-
} else if (
|
|
119
|
-
has(
|
|
120
|
-
"street",
|
|
121
|
-
"address",
|
|
122
|
-
"addr",
|
|
123
|
-
"city",
|
|
124
|
-
"town",
|
|
125
|
-
"state",
|
|
126
|
-
"province",
|
|
127
|
-
"zip",
|
|
128
|
-
"zipcode",
|
|
129
|
-
"postal",
|
|
130
|
-
"postcode",
|
|
131
|
-
"county"
|
|
132
|
-
)
|
|
133
|
-
) {
|
|
134
|
-
address.push(column)
|
|
135
|
-
} else if (has("name", "first", "last", "given", "family", "middle", "surname", "fullname", "contact")) {
|
|
136
|
-
name.push(column)
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (name.length) {
|
|
141
|
-
mapping.name = name.length === 1 ? name[0]! : name
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (address.length) {
|
|
145
|
-
mapping.address = address
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return mapping
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Options for {@link ingestRows}.
|
|
153
|
-
*/
|
|
154
|
-
export interface IngestOptions {
|
|
155
|
-
/**
|
|
156
|
-
* The geocoding interface.
|
|
157
|
-
*
|
|
158
|
-
* Without it records include name/org but have no resolved address.
|
|
159
|
-
*/
|
|
160
|
-
geocodeAddress?: GeocodeAddress
|
|
161
|
-
/**
|
|
162
|
-
* Separator for joining a multi-column address mapping, comma-join giving the parser
|
|
163
|
-
* delimited input rather than a concatenated run (name/org always join with a space).
|
|
164
|
-
*
|
|
165
|
-
* @defaultValue `", "`
|
|
166
|
-
*/
|
|
167
|
-
addressSeparator?: string
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Join the selected columns of a row into a single trimmed string, or null if empty.
|
|
172
|
-
*/
|
|
173
|
-
export function pick(row: Record<string, string>, columns?: string | string[], separator = " "): string | null {
|
|
174
|
-
if (!columns) return null
|
|
175
|
-
const list = Array.isArray(columns) ? columns : [columns]
|
|
176
|
-
|
|
177
|
-
const value = list
|
|
178
|
-
.map((c) => row[c])
|
|
179
|
-
.filter(isPresent)
|
|
180
|
-
.join(separator)
|
|
181
|
-
.trim()
|
|
182
|
-
|
|
183
|
-
return value || null
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Normalize one tabular row into a {@link SourceRecord} under a {@link ColumnMapping},
|
|
188
|
-
* pure aside from the optional geocode interface so the deterministic normalization
|
|
189
|
-
* can run single-threaded while geocoding is offloaded.
|
|
190
|
-
*/
|
|
191
|
-
export async function ingestRow(
|
|
192
|
-
row: Record<string, string>,
|
|
193
|
-
mapping: ColumnMapping,
|
|
194
|
-
index: number,
|
|
195
|
-
opts: IngestOptions = {}
|
|
196
|
-
): Promise<SourceRecord> {
|
|
197
|
-
const id = (mapping.id ? row[mapping.id] : "") || String(index)
|
|
198
|
-
const nameValue = pick(row, mapping.name)
|
|
199
|
-
const orgValue = pick(row, mapping.organization)
|
|
200
|
-
const addressValue = pick(row, mapping.address, opts.addressSeparator ?? ", ")
|
|
201
|
-
|
|
202
|
-
let attributes: Record<string, string> | null = null
|
|
203
|
-
|
|
204
|
-
if (mapping.attributes) {
|
|
205
|
-
for (const [key, columns] of Object.entries(mapping.attributes)) {
|
|
206
|
-
const value = pick(row, columns)
|
|
207
|
-
|
|
208
|
-
if (value) {
|
|
209
|
-
;(attributes ??= {})[key] = value
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return {
|
|
215
|
-
id,
|
|
216
|
-
source: mapping.source ?? null,
|
|
217
|
-
name: nameValue ? parsePersonName(nameValue) : null,
|
|
218
|
-
organization: orgValue ? canonicalizeOrganizationName(orgValue) : null,
|
|
219
|
-
phone: (mapping.phone && row[mapping.phone]) || null,
|
|
220
|
-
email: (mapping.email && row[mapping.email]?.toLowerCase()) || null,
|
|
221
|
-
address: addressValue && opts.geocodeAddress ? ((await opts.geocodeAddress(addressValue)) ?? null) : null,
|
|
222
|
-
attributes,
|
|
223
|
-
raw: row,
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Normalize tabular rows into {@link SourceRecord}s under a {@link ColumnMapping}.
|
|
229
|
-
*
|
|
230
|
-
* @see {@link streamRows} for the streaming path. It is preferred for multi-GB files.
|
|
231
|
-
*/
|
|
232
|
-
export async function ingestRows(
|
|
233
|
-
rows: Iterable<Record<string, string>> | AsyncIterable<Record<string, string>>,
|
|
234
|
-
mapping: ColumnMapping,
|
|
235
|
-
opts: IngestOptions = {}
|
|
236
|
-
): Promise<SourceRecord[]> {
|
|
237
|
-
const records: SourceRecord[] = []
|
|
238
|
-
let index = 0
|
|
239
|
-
|
|
240
|
-
for await (const row of rows) {
|
|
241
|
-
records.push(await ingestRow(row, mapping, index, opts))
|
|
242
|
-
|
|
243
|
-
index++
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return records
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Stream a delimited file as normalized {@link SourceRecord}s in file order with no geocoding.
|
|
251
|
-
* Geocode separately through `geocodeStream`.
|
|
252
|
-
*/
|
|
253
|
-
export function normalizeCSV(
|
|
254
|
-
source: PathBuilderLike,
|
|
255
|
-
opts: { mapping: ColumnMapping; delimiter?: Delimiter }
|
|
256
|
-
): AsyncSequence<SourceRecord> {
|
|
257
|
-
return streamRows(source, { delimiter: opts.delimiter }).map((row, index) => ingestRow(row, opts.mapping, index))
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* The subset of mailwoman's `GeocodeResult` the adapter consumes, kept structural
|
|
262
|
-
* so this package never imports the heavy geocoder.
|
|
263
|
-
*/
|
|
264
|
-
export interface RawGeocode {
|
|
265
|
-
lat: number | null
|
|
266
|
-
lon: number | null
|
|
267
|
-
resolution_tier: AddressGeocode["tier"]
|
|
268
|
-
uncertainty_m: number | null
|
|
269
|
-
hierarchy?: AddressGeocode["hierarchy"]
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* The component map {@link toPostalAddress} consumes
|
|
274
|
-
* (kept structural so this package never imports the geocoder).
|
|
275
|
-
*/
|
|
276
|
-
type GeocodeComponents = Parameters<typeof toPostalAddress>[0]
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* What every shape of {@link geocodeAddressVia}'s dependencies includes.
|
|
280
|
-
*/
|
|
281
|
-
export interface GeocodeDepsBase {
|
|
282
|
-
/**
|
|
283
|
-
* Country (ISO-2 or name) the address is formatted under.
|
|
284
|
-
*
|
|
285
|
-
* When omitted, {@link toPostalAddress} reads the parsed `country` component instead.
|
|
286
|
-
*/
|
|
287
|
-
country?: string
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Two independent calls: parse the address, then geocode it.
|
|
292
|
-
*
|
|
293
|
-
* Mailwoman's `geocodeAddress` re-parses internally, so the address is read twice
|
|
294
|
-
* unless the two callbacks share a parser.
|
|
295
|
-
*/
|
|
296
|
-
export interface TwoStepGeocodeDeps extends GeocodeDepsBase {
|
|
297
|
-
parse: (raw: string) => Promise<GeocodeComponents> | GeocodeComponents
|
|
298
|
-
geocode: (raw: string) => Promise<RawGeocode | null> | RawGeocode | null
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Parse the address once and answer both the components and the geocode, for
|
|
303
|
-
* when the parse is the expensive step you'd rather not pay for twice.
|
|
304
|
-
*/
|
|
305
|
-
export interface OneStepGeocodeDeps extends GeocodeDepsBase {
|
|
306
|
-
parseAndGeocode: (raw: string) => Promise<{ components: GeocodeComponents; geo: RawGeocode | null }>
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* The dependencies {@link geocodeAddressVia} builds a {@link GeocodeAddress} from;
|
|
311
|
-
* `"parseAndGeocode" in deps` tells the two shapes apart.
|
|
312
|
-
*/
|
|
313
|
-
export type GeocodeAddressViaDeps = TwoStepGeocodeDeps | OneStepGeocodeDeps
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Build a {@link GeocodeAddress} from injected parse and geocode primitives.
|
|
317
|
-
*
|
|
318
|
-
* When geocoding can't place the address, the parsed-but-unlocated address is still returned.
|
|
319
|
-
*/
|
|
320
|
-
export function geocodeAddressVia(deps: GeocodeAddressViaDeps): GeocodeAddress {
|
|
321
|
-
return async (raw: string): Promise<PostalAddress | null> => {
|
|
322
|
-
let components: GeocodeComponents
|
|
323
|
-
let resolved: RawGeocode | null
|
|
324
|
-
|
|
325
|
-
if ("parseAndGeocode" in deps) {
|
|
326
|
-
const r = await deps.parseAndGeocode(raw)
|
|
327
|
-
components = r.components
|
|
328
|
-
resolved = r.geo
|
|
329
|
-
} else {
|
|
330
|
-
components = await deps.parse(raw)
|
|
331
|
-
resolved = await deps.geocode(raw)
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const base = toPostalAddress(components, { country: deps.country, raw })
|
|
335
|
-
|
|
336
|
-
if (!resolved || resolved.lat === null || resolved.lon === null) return base
|
|
337
|
-
|
|
338
|
-
const geocode: AddressGeocode = {
|
|
339
|
-
coordinate: { latitude: resolved.lat, longitude: resolved.lon },
|
|
340
|
-
tier: resolved.resolution_tier,
|
|
341
|
-
uncertaintyMeters: resolved.uncertainty_m,
|
|
342
|
-
hierarchy: resolved.hierarchy ?? null,
|
|
343
|
-
poBox: null,
|
|
344
|
-
multiUnit: null,
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return withGeocode(base, geocode)
|
|
348
|
-
}
|
|
349
|
-
}
|
package/lib/learned-scorer.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The learned scorer, the production wiring for the gradient-boosted-tree model behind
|
|
7
|
-
* {@link ResolveConfig.scorer}.
|
|
8
|
-
*
|
|
9
|
-
* {@link createMatchFeaturizer} is the one feature extractor for a candidate pair, used
|
|
10
|
-
* identically at train time (`registry/tools/train-gbt.ts`), eval time and inference time.
|
|
11
|
-
* {@link createGBTScorer} wraps a trained {@link GBT} and the featurizer into the `(a, b) => number`
|
|
12
|
-
* the resolve pipeline's `scorer` hook expects (a logit, threshold-comparable with the
|
|
13
|
-
* Fellegi-Sunter weight it replaces).
|
|
14
|
-
*
|
|
15
|
-
* Both take the comparison set as input rather than importing {@link buildDefaultModel}, so this
|
|
16
|
-
* module has no dependency cycle with `resolve.ts`. Feed the comparisons from
|
|
17
|
-
* `buildDefaultModel({ collapseSpatial: true, addressFrequency })`, since that config fixes the
|
|
18
|
-
* feature layout.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
agreementPattern,
|
|
23
|
-
type Comparison,
|
|
24
|
-
type GBT,
|
|
25
|
-
gbtScore,
|
|
26
|
-
nameSimilarity,
|
|
27
|
-
type TermFrequencyTable,
|
|
28
|
-
} from "@mailwoman/match"
|
|
29
|
-
|
|
30
|
-
import type { SourceRecord } from "#types"
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Similarity at which two official names count as the same organization.
|
|
34
|
-
*
|
|
35
|
-
* Set high because the feature is a near-exact agreement signal rather than a fuzzy one.
|
|
36
|
-
*/
|
|
37
|
-
const OFFICIAL_NAME_AGREEMENT = 0.93
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Inputs shared by the featurizer + the scorer factory.
|
|
41
|
-
*/
|
|
42
|
-
export interface LearnedFeatureConfig {
|
|
43
|
-
/**
|
|
44
|
-
* The comparison set the features are built over.
|
|
45
|
-
*
|
|
46
|
-
* It must be `buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons`
|
|
47
|
-
* so the feature layout matches the trained model.
|
|
48
|
-
*
|
|
49
|
-
* `usePhone` and `discriminators` are not part of the learned feature model,
|
|
50
|
-
* since the GBT replaces the Fellegi-Sunter weight wholesale and owns its feature vector.
|
|
51
|
-
*/
|
|
52
|
-
comparisons: Comparison<SourceRecord>[]
|
|
53
|
-
/**
|
|
54
|
-
* Address-frequency table for the crowdedness feature (a crowded shared address is weak identity).
|
|
55
|
-
*/
|
|
56
|
-
addressFrequency: TermFrequencyTable
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Build the per-pair feature extractor.
|
|
61
|
-
*
|
|
62
|
-
* The vector is: one-hot of each comparison's agreement level, then the two over-merge
|
|
63
|
-
* interaction terms (spatial-exact × name-disagree, spatial-exact × org-disagree,
|
|
64
|
-
* the "same place, different names" signature that drives co-located over-merges),
|
|
65
|
-
* then address crowdedness scaled into [0, 1].
|
|
66
|
-
* Deterministic and EM-independent, so it is identical across train / eval / inference.
|
|
67
|
-
*/
|
|
68
|
-
export function createMatchFeaturizer(config: LearnedFeatureConfig): (a: SourceRecord, b: SourceRecord) => number[] {
|
|
69
|
-
const { comparisons, addressFrequency } = config
|
|
70
|
-
const levelCounts = comparisons.map((c) => c.levels.length)
|
|
71
|
-
const index = Object.fromEntries(comparisons.map((c, i) => [c.name, i])) as Record<string, number | undefined>
|
|
72
|
-
const spatialI = index["spatial"]
|
|
73
|
-
const givenI = index["given"]
|
|
74
|
-
const familyI = index["family"]
|
|
75
|
-
const orgI = index["organization"]
|
|
76
|
-
const lastLevel = (i: number): number => levelCounts[i]! - 1
|
|
77
|
-
|
|
78
|
-
return (a, b) => {
|
|
79
|
-
const pat = agreementPattern(comparisons, a, b)
|
|
80
|
-
const f: number[] = []
|
|
81
|
-
|
|
82
|
-
for (let i = 0; i < pat.length; i++) {
|
|
83
|
-
const lvl = pat[i]!
|
|
84
|
-
|
|
85
|
-
for (let l = 0; l < levelCounts[i]!; l++) {
|
|
86
|
-
f.push(lvl === l ? 1 : 0)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const spatialExact = spatialI !== undefined && pat[spatialI] === 0 ? 1 : 0
|
|
91
|
-
|
|
92
|
-
const nameDisagree =
|
|
93
|
-
givenI !== undefined &&
|
|
94
|
-
familyI !== undefined &&
|
|
95
|
-
pat[givenI] === lastLevel(givenI) &&
|
|
96
|
-
pat[familyI] === lastLevel(familyI)
|
|
97
|
-
? 1
|
|
98
|
-
: 0
|
|
99
|
-
|
|
100
|
-
const orgDisagree = orgI !== undefined && pat[orgI] === lastLevel(orgI) ? 1 : 0
|
|
101
|
-
f.push(spatialExact * nameDisagree)
|
|
102
|
-
f.push(spatialExact * orgDisagree)
|
|
103
|
-
const freq = a.address?.raw ? addressFrequency.frequency(a.address.raw) : 0
|
|
104
|
-
f.push(Math.min(1, freq * 1000))
|
|
105
|
-
// Roll-up signature: a shared corporate address can host differently-branded
|
|
106
|
-
// operating entities whose authorized official also agrees.
|
|
107
|
-
// The official is not in the comparison set, so these three features express that evidence directly.
|
|
108
|
-
// They are appended at the end, so models trained without them keep scoring unchanged.
|
|
109
|
-
const offA = a.attributes?.["authorizedOfficial"]?.trim()
|
|
110
|
-
const offB = b.attributes?.["authorizedOfficial"]?.trim()
|
|
111
|
-
const officialAgree = offA && offB && nameSimilarity(offA, offB) >= OFFICIAL_NAME_AGREEMENT ? 1 : 0
|
|
112
|
-
f.push(officialAgree)
|
|
113
|
-
f.push(officialAgree * orgDisagree)
|
|
114
|
-
f.push(officialAgree * orgDisagree * spatialExact)
|
|
115
|
-
|
|
116
|
-
return f
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Wrap a trained {@link GBT} into the `(a, b) => number` link scorer for {@link ResolveConfig.scorer}.
|
|
122
|
-
*
|
|
123
|
-
* The returned weight is the model's logit.
|
|
124
|
-
* Same threshold-comparable units as the Fellegi-Sunter weight it replaces,
|
|
125
|
-
* so the pipeline's clustering + threshold semantics are unchanged.
|
|
126
|
-
*/
|
|
127
|
-
export function createGBTScorer(
|
|
128
|
-
config: LearnedFeatureConfig & { model: GBT }
|
|
129
|
-
): (a: SourceRecord, b: SourceRecord) => number {
|
|
130
|
-
const featurize = createMatchFeaturizer(config)
|
|
131
|
-
const { model } = config
|
|
132
|
-
|
|
133
|
-
return (a, b) => gbtScore(model, featurize(a, b))
|
|
134
|
-
}
|