@mailwoman/corpus 11.1.0 → 11.2.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 +20 -14
- package/data/address-source-register.json +618 -13
- package/data/builds/v0.8.19-overlay/OVERLAY_PLAN.json +4778 -0
- package/data/builds/v0.8.19-rebuild/inputs.json +128 -0
- package/data/builds/v0.8.20-overlay/OVERLAY_PLAN.json +3595 -0
- package/data/builds/v0.8.20-rebuild/inputs.json +131 -0
- package/data/builds/v0.8.21-overlay/OVERLAY_PLAN.json +72 -0
- package/data/corpus-source-inputs.json +104 -2
- package/data/holdout/evaluation-groups.v0.8.18.json +90511 -0
- package/data/holdout/evaluation-groups.v0.8.19.json +100537 -0
- package/data/holdout/evaluation-groups.v0.8.20.json +129215 -0
- package/data/holdout/evaluation-groups.v0.8.21.json +173286 -0
- package/data/holdout/probe-text-collisions.v0.8.20.json +1478 -0
- package/data/license-decisions.json +393 -3
- package/data/licenses/PROVENANCE.md +15 -9
- package/data/licenses/au-acnc-cc-by-3.0-au.md +37 -0
- package/data/licenses/es-sanidad-aviso-legal.md +26 -0
- package/data/licenses/it-miur-iodl-2.0.md +41 -0
- package/data/licenses/nz-charities-cc-by-3.0-nz.md +36 -0
- package/data/region-slot-second-level.json +966 -0
- package/data/source-additions.json +126 -6
- package/data/source-resolutions.json +97 -0
- package/data/training-configs/v8.7.0-base-c6-90k-usgs-structures-s42.yaml +801 -0
- package/data/training-configs/v8.7.0-base-c6-90k-usgs-structures-s43.yaml +726 -0
- package/data/training-configs/v8.8.0-base-c6-90k-v0820-county-s42.yaml +944 -0
- package/data/training-configs/v8.9.0-base-c6-90k-v0821-s42.yaml +848 -0
- package/data/training-manifests/v0.8.19-retention-overlay.json +4553 -0
- package/data/training-manifests/v0.8.20-retention-overlay.json +4579 -0
- package/data/training-manifests/v0.8.21-retention-overlay.effective.json +2521 -0
- package/data/training-manifests/v0.8.21-retention-overlay.json +4579 -0
- package/lib/adapters/cordis/adapter.ts +10 -2
- package/lib/adapters/gleif/adapter.ts +23 -5
- package/lib/adapters/osm/adapter.ts +2 -2
- package/lib/adapters/street/repetition.ts +87 -0
- package/lib/adapters/street/unit.ts +14 -0
- package/lib/adapters/wof/admin/json/adapter.ts +34 -21
- package/lib/adapters/wof/admin/json/dual-role.ts +274 -0
- package/lib/adapters/wof/admin/json/explore.ts +4 -4
- package/lib/adapters/wof/admin/json/region-codes.ts +74 -3
- package/lib/adapters/wof/json-rows.ts +36 -21
- package/lib/adapters/wof/postalcode-json/adapter.ts +10 -28
- package/lib/adapters/wof/sample.ts +15 -3
- package/lib/adapters/wof/stored-records.ts +162 -0
- package/lib/adapters.ts +18 -6
- package/lib/au/adapters/acnc-register/adapter.ts +40 -0
- package/lib/au/evaluation/acnc-register.ts +144 -0
- package/lib/build/align/range.ts +9 -0
- package/lib/build/align/totals.ts +23 -0
- package/lib/build/align.ts +74 -4
- package/lib/build/budget.ts +11 -45
- package/lib/build/checkpoint.ts +11 -0
- package/lib/build/component-check.ts +99 -3
- package/lib/build/manifest.ts +4 -0
- package/lib/build/parallel.ts +8 -34
- package/lib/build/region-names.ts +609 -0
- package/lib/build/source-record.ts +7 -0
- package/lib/build/types.ts +20 -0
- package/lib/build/worker.ts +3 -1
- package/lib/build.ts +3 -6
- package/lib/de/recipes/locale.ts +3 -2
- package/lib/env.ts +0 -6
- package/lib/es/adapters/sanidad-centros-ap/adapter.ts +40 -0
- package/lib/es/evaluation/sanidad-centros-ap.ts +164 -0
- package/lib/evaluation/corpus-adapter.ts +153 -0
- package/lib/evaluation/source.ts +209 -0
- package/lib/evaluation/sources.ts +25 -0
- package/lib/fr/adapters/laposte-poincont/adapter.ts +381 -0
- package/lib/fr/recipes/unit-line-guideline.ts +9 -4
- package/lib/fr/structures/laposte.ts +139 -0
- package/lib/fr/tools/fetch/laposte-poincont.ts +234 -0
- package/lib/it/adapters/miur-scuole/adapter.ts +39 -0
- package/lib/it/evaluation/miur-scuole.ts +125 -0
- package/lib/jp/adapters/wof-admin/adapter.ts +4 -4
- package/lib/nc/adapters/opt-nc/adapter.ts +237 -0
- package/lib/nc/structures/opt-nc.ts +101 -0
- package/lib/nc/tools/fetch/opt-nc.ts +249 -0
- package/lib/nz/adapters/charities-register/adapter.ts +40 -0
- package/lib/nz/evaluation/charities-register.ts +149 -0
- package/lib/recipes/bare/postcode.ts +14 -11
- package/lib/recipes/deepseek/batches.ts +8 -8
- package/lib/recipes/po/box/cedex/recipe.ts +12 -1
- package/lib/recipes/po/box/cedex/us.ts +43 -2
- package/lib/recipes/scaffold.ts +1 -1
- package/lib/recipes/sources.ts +16 -0
- package/lib/recipes.ts +2 -0
- package/lib/registers.ts +28 -2
- package/lib/{post-offices → structures}/source.ts +49 -16
- package/lib/structures/sources.ts +26 -0
- package/lib/synthesizers/house-venue.ts +11 -6
- package/lib/synthesizers/tail.ts +27 -3
- package/lib/tools/audit.ts +1 -1
- package/lib/tools/fetch/storage.ts +18 -4
- package/lib/tools/fetch.ts +10 -2
- package/lib/tools/overlay/kryptonite.ts +6 -2
- package/lib/tools/overlay/split/attribute.ts +14 -2
- package/lib/tools/overlay/split/overlay.ts +36 -7
- package/lib/tools/postcode/triples.ts +3 -3
- package/lib/tools/region-slot-census.run.ts +184 -0
- package/lib/training/config/load.ts +19 -0
- package/lib/training/config/schema.ts +6 -0
- package/lib/tw/registers.ts +15 -4
- package/lib/tw/structures/chunghwa-post.ts +191 -0
- package/lib/tw/tools/fetch/chunghwa-post.ts +174 -0
- package/lib/us/adapters/state/ny-notaries/adapter.ts +7 -2
- package/lib/us/adapters/state/tx-notaries/adapter.ts +126 -21
- package/lib/us/adapters/usgov/nad/adapter.ts +111 -31
- package/lib/us/adapters/usgov/nppes/adapter.ts +8 -11
- package/lib/us/adapters/usgov/{usgs-post-offices → usgs-structures}/adapter.ts +65 -35
- package/lib/us/recipes/county.ts +474 -0
- package/lib/us/street-unit.ts +15 -5
- package/lib/us/structures/usgs/layers.ts +171 -0
- package/lib/us/structures/usgs/national-map.ts +95 -0
- package/lib/us/tools/fetch/usgs/gnis.ts +288 -0
- package/lib/us/tools/fetch/usgs/structures.ts +362 -0
- package/lib/utils/align.ts +2 -2
- package/lib/utils/evaluation-groups.ts +172 -0
- package/lib/utils/split.ts +40 -4
- package/lib/utils/tokenize.ts +7 -7
- package/lib/utils/validation-groups.ts +292 -0
- package/lib/utils/wof-json.ts +96 -134
- package/out/adapters/cordis/adapter.d.ts +3 -1
- package/out/adapters/cordis/adapter.d.ts.map +1 -1
- package/out/adapters/cordis/adapter.js +8 -2
- package/out/adapters/cordis/adapter.js.map +1 -1
- package/out/adapters/gleif/adapter.d.ts.map +1 -1
- package/out/adapters/gleif/adapter.js +19 -5
- package/out/adapters/gleif/adapter.js.map +1 -1
- package/out/adapters/osm/adapter.js +2 -2
- package/out/adapters/osm/adapter.js.map +1 -1
- package/out/adapters/street/repetition.d.ts +19 -0
- package/out/adapters/street/repetition.d.ts.map +1 -0
- package/out/adapters/street/repetition.js +71 -0
- package/out/adapters/street/repetition.js.map +1 -0
- package/out/adapters/street/unit.d.ts +10 -0
- package/out/adapters/street/unit.d.ts.map +1 -1
- package/out/adapters/street/unit.js +6 -0
- package/out/adapters/street/unit.js.map +1 -1
- package/out/adapters/wof/admin/json/adapter.d.ts +8 -0
- package/out/adapters/wof/admin/json/adapter.d.ts.map +1 -1
- package/out/adapters/wof/admin/json/adapter.js +26 -22
- package/out/adapters/wof/admin/json/adapter.js.map +1 -1
- package/out/adapters/wof/admin/json/dual-role.d.ts +83 -0
- package/out/adapters/wof/admin/json/dual-role.d.ts.map +1 -0
- package/out/adapters/wof/admin/json/dual-role.js +183 -0
- package/out/adapters/wof/admin/json/dual-role.js.map +1 -0
- package/out/adapters/wof/admin/json/explore.d.ts.map +1 -1
- package/out/adapters/wof/admin/json/explore.js +4 -4
- package/out/adapters/wof/admin/json/explore.js.map +1 -1
- package/out/adapters/wof/admin/json/region-codes.d.ts +16 -0
- package/out/adapters/wof/admin/json/region-codes.d.ts.map +1 -1
- package/out/adapters/wof/admin/json/region-codes.js +62 -3
- package/out/adapters/wof/admin/json/region-codes.js.map +1 -1
- package/out/adapters/wof/json-rows.d.ts +28 -6
- package/out/adapters/wof/json-rows.d.ts.map +1 -1
- package/out/adapters/wof/json-rows.js +9 -15
- package/out/adapters/wof/json-rows.js.map +1 -1
- package/out/adapters/wof/postalcode-json/adapter.d.ts +1 -1
- package/out/adapters/wof/postalcode-json/adapter.d.ts.map +1 -1
- package/out/adapters/wof/postalcode-json/adapter.js +9 -26
- package/out/adapters/wof/postalcode-json/adapter.js.map +1 -1
- package/out/adapters/wof/sample.d.ts +8 -1
- package/out/adapters/wof/sample.d.ts.map +1 -1
- package/out/adapters/wof/sample.js +12 -4
- package/out/adapters/wof/sample.js.map +1 -1
- package/out/adapters/wof/stored-records.d.ts +62 -0
- package/out/adapters/wof/stored-records.d.ts.map +1 -0
- package/out/adapters/wof/stored-records.js +91 -0
- package/out/adapters/wof/stored-records.js.map +1 -0
- package/out/adapters.d.ts +1 -1
- package/out/adapters.d.ts.map +1 -1
- package/out/adapters.js +15 -3
- package/out/adapters.js.map +1 -1
- package/out/au/adapters/acnc-register/adapter.d.ts +9 -0
- package/out/au/adapters/acnc-register/adapter.d.ts.map +1 -0
- package/out/au/adapters/acnc-register/adapter.js +37 -0
- package/out/au/adapters/acnc-register/adapter.js.map +1 -0
- package/out/au/evaluation/acnc-register.d.ts +56 -0
- package/out/au/evaluation/acnc-register.d.ts.map +1 -0
- package/out/au/evaluation/acnc-register.js +84 -0
- package/out/au/evaluation/acnc-register.js.map +1 -0
- package/out/build/align/range.d.ts.map +1 -1
- package/out/build/align/range.js +9 -0
- package/out/build/align/range.js.map +1 -1
- package/out/build/align/totals.d.ts +5 -0
- package/out/build/align/totals.d.ts.map +1 -1
- package/out/build/align/totals.js +15 -0
- package/out/build/align/totals.js.map +1 -1
- package/out/build/align.d.ts +26 -0
- package/out/build/align.d.ts.map +1 -1
- package/out/build/align.js +35 -2
- package/out/build/align.js.map +1 -1
- package/out/build/budget.d.ts +9 -26
- package/out/build/budget.d.ts.map +1 -1
- package/out/build/budget.js +10 -31
- package/out/build/budget.js.map +1 -1
- package/out/build/checkpoint.d.ts +11 -0
- package/out/build/checkpoint.d.ts.map +1 -1
- package/out/build/checkpoint.js.map +1 -1
- package/out/build/component-check.d.ts +55 -1
- package/out/build/component-check.d.ts.map +1 -1
- package/out/build/component-check.js +65 -3
- package/out/build/component-check.js.map +1 -1
- package/out/build/manifest.d.ts.map +1 -1
- package/out/build/manifest.js +4 -0
- package/out/build/manifest.js.map +1 -1
- package/out/build/parallel.d.ts.map +1 -1
- package/out/build/parallel.js +8 -24
- package/out/build/parallel.js.map +1 -1
- package/out/build/region-names.d.ts +120 -0
- package/out/build/region-names.d.ts.map +1 -0
- package/out/build/region-names.js +430 -0
- package/out/build/region-names.js.map +1 -0
- package/out/build/source-record.d.ts.map +1 -1
- package/out/build/source-record.js +4 -0
- package/out/build/source-record.js.map +1 -1
- package/out/build/types.d.ts +20 -0
- package/out/build/types.d.ts.map +1 -1
- package/out/build/worker.js +3 -1
- package/out/build/worker.js.map +1 -1
- package/out/build.d.ts +0 -1
- package/out/build.d.ts.map +1 -1
- package/out/build.js +3 -5
- package/out/build.js.map +1 -1
- package/out/de/recipes/locale.d.ts.map +1 -1
- package/out/de/recipes/locale.js +3 -2
- package/out/de/recipes/locale.js.map +1 -1
- package/out/env.d.ts +0 -2
- package/out/env.d.ts.map +1 -1
- package/out/env.js +0 -5
- package/out/env.js.map +1 -1
- package/out/es/adapters/sanidad-centros-ap/adapter.d.ts +9 -0
- package/out/es/adapters/sanidad-centros-ap/adapter.d.ts.map +1 -0
- package/out/es/adapters/sanidad-centros-ap/adapter.js +36 -0
- package/out/es/adapters/sanidad-centros-ap/adapter.js.map +1 -0
- package/out/es/evaluation/sanidad-centros-ap.d.ts +34 -0
- package/out/es/evaluation/sanidad-centros-ap.d.ts.map +1 -0
- package/out/es/evaluation/sanidad-centros-ap.js +128 -0
- package/out/es/evaluation/sanidad-centros-ap.js.map +1 -0
- package/out/evaluation/corpus-adapter.d.ts +60 -0
- package/out/evaluation/corpus-adapter.d.ts.map +1 -0
- package/out/evaluation/corpus-adapter.js +100 -0
- package/out/evaluation/corpus-adapter.js.map +1 -0
- package/out/evaluation/source.d.ts +134 -0
- package/out/evaluation/source.d.ts.map +1 -0
- package/out/evaluation/source.js +80 -0
- package/out/evaluation/source.js.map +1 -0
- package/out/evaluation/sources.d.ts +6 -0
- package/out/evaluation/sources.d.ts.map +1 -0
- package/out/evaluation/sources.js +22 -0
- package/out/evaluation/sources.js.map +1 -0
- package/out/fr/adapters/laposte-poincont/adapter.d.ts +110 -0
- package/out/fr/adapters/laposte-poincont/adapter.d.ts.map +1 -0
- package/out/fr/adapters/laposte-poincont/adapter.js +315 -0
- package/out/fr/adapters/laposte-poincont/adapter.js.map +1 -0
- package/out/fr/recipes/unit-line-guideline.d.ts.map +1 -1
- package/out/fr/recipes/unit-line-guideline.js +8 -4
- package/out/fr/recipes/unit-line-guideline.js.map +1 -1
- package/out/fr/structures/laposte.d.ts +27 -0
- package/out/fr/structures/laposte.d.ts.map +1 -0
- package/out/fr/structures/laposte.js +96 -0
- package/out/fr/structures/laposte.js.map +1 -0
- package/out/fr/tools/fetch/laposte-poincont.d.ts +95 -0
- package/out/fr/tools/fetch/laposte-poincont.d.ts.map +1 -0
- package/out/fr/tools/fetch/laposte-poincont.js +135 -0
- package/out/fr/tools/fetch/laposte-poincont.js.map +1 -0
- package/out/it/adapters/miur-scuole/adapter.d.ts +9 -0
- package/out/it/adapters/miur-scuole/adapter.d.ts.map +1 -0
- package/out/it/adapters/miur-scuole/adapter.js +35 -0
- package/out/it/adapters/miur-scuole/adapter.js.map +1 -0
- package/out/it/evaluation/miur-scuole.d.ts +53 -0
- package/out/it/evaluation/miur-scuole.d.ts.map +1 -0
- package/out/it/evaluation/miur-scuole.js +68 -0
- package/out/it/evaluation/miur-scuole.js.map +1 -0
- package/out/jp/adapters/wof-admin/adapter.js +4 -4
- package/out/nc/adapters/opt-nc/adapter.d.ts +84 -0
- package/out/nc/adapters/opt-nc/adapter.d.ts.map +1 -0
- package/out/nc/adapters/opt-nc/adapter.js +173 -0
- package/out/nc/adapters/opt-nc/adapter.js.map +1 -0
- package/out/nc/structures/opt-nc.d.ts +12 -0
- package/out/nc/structures/opt-nc.d.ts.map +1 -0
- package/out/nc/structures/opt-nc.js +64 -0
- package/out/nc/structures/opt-nc.js.map +1 -0
- package/out/nc/tools/fetch/opt-nc.d.ts +81 -0
- package/out/nc/tools/fetch/opt-nc.d.ts.map +1 -0
- package/out/nc/tools/fetch/opt-nc.js +162 -0
- package/out/nc/tools/fetch/opt-nc.js.map +1 -0
- package/out/nz/adapters/charities-register/adapter.d.ts +9 -0
- package/out/nz/adapters/charities-register/adapter.d.ts.map +1 -0
- package/out/nz/adapters/charities-register/adapter.js +36 -0
- package/out/nz/adapters/charities-register/adapter.js.map +1 -0
- package/out/nz/evaluation/charities-register.d.ts +60 -0
- package/out/nz/evaluation/charities-register.d.ts.map +1 -0
- package/out/nz/evaluation/charities-register.js +84 -0
- package/out/nz/evaluation/charities-register.js.map +1 -0
- package/out/recipes/bare/postcode.d.ts +2 -1
- package/out/recipes/bare/postcode.d.ts.map +1 -1
- package/out/recipes/bare/postcode.js +14 -11
- package/out/recipes/bare/postcode.js.map +1 -1
- package/out/recipes/deepseek/batches.d.ts +11 -1
- package/out/recipes/deepseek/batches.d.ts.map +1 -1
- package/out/recipes/deepseek/batches.js +8 -7
- package/out/recipes/deepseek/batches.js.map +1 -1
- package/out/recipes/po/box/cedex/recipe.d.ts.map +1 -1
- package/out/recipes/po/box/cedex/recipe.js +12 -1
- package/out/recipes/po/box/cedex/recipe.js.map +1 -1
- package/out/recipes/po/box/cedex/us.d.ts +12 -0
- package/out/recipes/po/box/cedex/us.d.ts.map +1 -1
- package/out/recipes/po/box/cedex/us.js +36 -2
- package/out/recipes/po/box/cedex/us.js.map +1 -1
- package/out/recipes/scaffold.d.ts +1 -1
- package/out/recipes/sources.d.ts.map +1 -1
- package/out/recipes/sources.js +16 -0
- package/out/recipes/sources.js.map +1 -1
- package/out/recipes.d.ts.map +1 -1
- package/out/recipes.js +2 -0
- package/out/recipes.js.map +1 -1
- package/out/registers.d.ts +28 -2
- package/out/registers.d.ts.map +1 -1
- package/out/registers.js +28 -2
- package/out/registers.js.map +1 -1
- package/out/{post-offices → structures}/source.d.ts +34 -16
- package/out/structures/source.d.ts.map +1 -0
- package/out/structures/source.js +39 -0
- package/out/structures/source.js.map +1 -0
- package/out/structures/sources.d.ts +6 -0
- package/out/structures/sources.d.ts.map +1 -0
- package/out/structures/sources.js +23 -0
- package/out/structures/sources.js.map +1 -0
- package/out/synthesizers/house-venue.d.ts.map +1 -1
- package/out/synthesizers/house-venue.js +2 -1
- package/out/synthesizers/house-venue.js.map +1 -1
- package/out/synthesizers/tail.d.ts +15 -1
- package/out/synthesizers/tail.d.ts.map +1 -1
- package/out/synthesizers/tail.js +8 -3
- package/out/synthesizers/tail.js.map +1 -1
- package/out/tools/audit.js +1 -1
- package/out/tools/audit.js.map +1 -1
- package/out/tools/fetch/storage.d.ts +10 -2
- package/out/tools/fetch/storage.d.ts.map +1 -1
- package/out/tools/fetch/storage.js +18 -4
- package/out/tools/fetch/storage.js.map +1 -1
- package/out/tools/fetch.d.ts +10 -2
- package/out/tools/fetch.d.ts.map +1 -1
- package/out/tools/fetch.js +10 -2
- package/out/tools/fetch.js.map +1 -1
- package/out/tools/overlay/kryptonite.d.ts.map +1 -1
- package/out/tools/overlay/kryptonite.js +5 -2
- package/out/tools/overlay/kryptonite.js.map +1 -1
- package/out/tools/overlay/split/attribute.d.ts +7 -1
- package/out/tools/overlay/split/attribute.d.ts.map +1 -1
- package/out/tools/overlay/split/attribute.js +4 -1
- package/out/tools/overlay/split/attribute.js.map +1 -1
- package/out/tools/overlay/split/overlay.d.ts +10 -0
- package/out/tools/overlay/split/overlay.d.ts.map +1 -1
- package/out/tools/overlay/split/overlay.js +17 -4
- package/out/tools/overlay/split/overlay.js.map +1 -1
- package/out/tools/postcode/triples.js +3 -3
- package/out/tools/postcode/triples.js.map +1 -1
- package/out/tools/region-slot-census.run.d.ts +2 -0
- package/out/tools/region-slot-census.run.d.ts.map +1 -0
- package/out/tools/region-slot-census.run.js +134 -0
- package/out/tools/region-slot-census.run.js.map +1 -0
- package/out/training/config/load.d.ts.map +1 -1
- package/out/training/config/load.js +10 -0
- package/out/training/config/load.js.map +1 -1
- package/out/training/config/schema.d.ts +13 -0
- package/out/training/config/schema.d.ts.map +1 -1
- package/out/training/config/schema.js +6 -0
- package/out/training/config/schema.js.map +1 -1
- package/out/tw/registers.d.ts +9 -0
- package/out/tw/registers.d.ts.map +1 -1
- package/out/tw/registers.js +11 -4
- package/out/tw/registers.js.map +1 -1
- package/out/tw/structures/chunghwa-post.d.ts +39 -0
- package/out/tw/structures/chunghwa-post.d.ts.map +1 -0
- package/out/tw/structures/chunghwa-post.js +150 -0
- package/out/tw/structures/chunghwa-post.js.map +1 -0
- package/out/tw/tools/fetch/chunghwa-post.d.ts +55 -0
- package/out/tw/tools/fetch/chunghwa-post.d.ts.map +1 -0
- package/out/tw/tools/fetch/chunghwa-post.js +110 -0
- package/out/tw/tools/fetch/chunghwa-post.js.map +1 -0
- package/out/us/adapters/state/ny-notaries/adapter.d.ts.map +1 -1
- package/out/us/adapters/state/ny-notaries/adapter.js +7 -2
- package/out/us/adapters/state/ny-notaries/adapter.js.map +1 -1
- package/out/us/adapters/state/tx-notaries/adapter.d.ts +42 -0
- package/out/us/adapters/state/tx-notaries/adapter.d.ts.map +1 -1
- package/out/us/adapters/state/tx-notaries/adapter.js +92 -19
- package/out/us/adapters/state/tx-notaries/adapter.js.map +1 -1
- package/out/us/adapters/usgov/nad/adapter.d.ts +35 -2
- package/out/us/adapters/usgov/nad/adapter.d.ts.map +1 -1
- package/out/us/adapters/usgov/nad/adapter.js +90 -27
- package/out/us/adapters/usgov/nad/adapter.js.map +1 -1
- package/out/us/adapters/usgov/nppes/adapter.d.ts.map +1 -1
- package/out/us/adapters/usgov/nppes/adapter.js +8 -11
- package/out/us/adapters/usgov/nppes/adapter.js.map +1 -1
- package/out/us/adapters/usgov/usgs-structures/adapter.d.ts +87 -0
- package/out/us/adapters/usgov/usgs-structures/adapter.d.ts.map +1 -0
- package/out/us/adapters/usgov/{usgs-post-offices → usgs-structures}/adapter.js +36 -27
- package/out/us/adapters/usgov/usgs-structures/adapter.js.map +1 -0
- package/out/us/recipes/county.d.ts +124 -0
- package/out/us/recipes/county.d.ts.map +1 -0
- package/out/us/recipes/county.js +295 -0
- package/out/us/recipes/county.js.map +1 -0
- package/out/us/street-unit.d.ts +10 -3
- package/out/us/street-unit.d.ts.map +1 -1
- package/out/us/street-unit.js +14 -6
- package/out/us/street-unit.js.map +1 -1
- package/out/us/structures/usgs/layers.d.ts +57 -0
- package/out/us/structures/usgs/layers.d.ts.map +1 -0
- package/out/us/structures/usgs/layers.js +121 -0
- package/out/us/structures/usgs/layers.js.map +1 -0
- package/out/us/structures/usgs/national-map.d.ts +14 -0
- package/out/us/structures/usgs/national-map.d.ts.map +1 -0
- package/out/us/{post-offices/usgs-national-map.js → structures/usgs/national-map.js} +16 -14
- package/out/us/structures/usgs/national-map.js.map +1 -0
- package/out/us/tools/fetch/usgs/gnis.d.ts +118 -0
- package/out/us/tools/fetch/usgs/gnis.d.ts.map +1 -0
- package/out/us/tools/fetch/usgs/gnis.js +177 -0
- package/out/us/tools/fetch/usgs/gnis.js.map +1 -0
- package/out/us/tools/fetch/usgs/structures.d.ts +99 -0
- package/out/us/tools/fetch/usgs/structures.d.ts.map +1 -0
- package/out/us/tools/fetch/usgs/structures.js +233 -0
- package/out/us/tools/fetch/usgs/structures.js.map +1 -0
- package/out/utils/align.js.map +1 -1
- package/out/utils/evaluation-groups.d.ts +98 -0
- package/out/utils/evaluation-groups.d.ts.map +1 -0
- package/out/utils/evaluation-groups.js +92 -0
- package/out/utils/evaluation-groups.js.map +1 -0
- package/out/utils/split.d.ts +26 -1
- package/out/utils/split.d.ts.map +1 -1
- package/out/utils/split.js +28 -3
- package/out/utils/split.js.map +1 -1
- package/out/utils/tokenize.d.ts +3 -3
- package/out/utils/tokenize.d.ts.map +1 -1
- package/out/utils/tokenize.js.map +1 -1
- package/out/utils/validation-groups.d.ts +168 -0
- package/out/utils/validation-groups.d.ts.map +1 -0
- package/out/utils/validation-groups.js +135 -0
- package/out/utils/validation-groups.js.map +1 -0
- package/out/utils/wof-json.d.ts +31 -57
- package/out/utils/wof-json.d.ts.map +1 -1
- package/out/utils/wof-json.js +81 -98
- package/out/utils/wof-json.js.map +1 -1
- package/package.json +18 -18
- package/lib/adapters/wof/record-cache.ts +0 -118
- package/lib/build/heap.ts +0 -60
- package/lib/post-offices/sources.ts +0 -18
- package/lib/us/post-offices/usgs-national-map.ts +0 -89
- package/lib/us/tools/fetch/usgs-post-offices.ts +0 -362
- package/out/adapters/wof/record-cache.d.ts +0 -22
- package/out/adapters/wof/record-cache.d.ts.map +0 -1
- package/out/adapters/wof/record-cache.js +0 -89
- package/out/adapters/wof/record-cache.js.map +0 -1
- package/out/build/heap.d.ts +0 -26
- package/out/build/heap.d.ts.map +0 -1
- package/out/build/heap.js +0 -52
- package/out/build/heap.js.map +0 -1
- package/out/post-offices/source.d.ts.map +0 -1
- package/out/post-offices/source.js +0 -21
- package/out/post-offices/source.js.map +0 -1
- package/out/post-offices/sources.d.ts +0 -13
- package/out/post-offices/sources.d.ts.map +0 -1
- package/out/post-offices/sources.js +0 -8
- package/out/post-offices/sources.js.map +0 -1
- package/out/us/adapters/usgov/usgs-post-offices/adapter.d.ts +0 -66
- package/out/us/adapters/usgov/usgs-post-offices/adapter.d.ts.map +0 -1
- package/out/us/adapters/usgov/usgs-post-offices/adapter.js.map +0 -1
- package/out/us/post-offices/usgs-national-map.d.ts +0 -14
- package/out/us/post-offices/usgs-national-map.d.ts.map +0 -1
- package/out/us/post-offices/usgs-national-map.js.map +0 -1
- package/out/us/tools/fetch/usgs-post-offices.d.ts +0 -99
- package/out/us/tools/fetch/usgs-post-offices.d.ts.map +0 -1
- package/out/us/tools/fetch/usgs-post-offices.js +0 -246
- package/out/us/tools/fetch/usgs-post-offices.js.map +0 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Fetches Chunghwa Post's list of its post offices (中華郵政全國營業據點, data.gov.tw dataset 5950),
|
|
6
|
+
* the source of Taiwan's post offices in the structures layer (`#tw/structures/chunghwa-post`).
|
|
7
|
+
*
|
|
8
|
+
* The dataset record at `https://data.gov.tw/api/v2/rest/dataset/5950` names the provider
|
|
9
|
+
* (提供機關 中華郵政股份有限公司), the license (政府資料開放授權條款-第1版, the Open Government Data License, Taiwan, v1.0)
|
|
10
|
+
* and the CSV distribution on `www.post.gov.tw`.
|
|
11
|
+
* The record is saved beside the CSV as `dataset.json`, because it holds the license
|
|
12
|
+
* and the update date the attribution cites.
|
|
13
|
+
*
|
|
14
|
+
* The CSV is downloaded to a staging file and moves into place only once it parses
|
|
15
|
+
* and holds the columns the adapter reads.
|
|
16
|
+
* A failed run leaves the previous file as it was.
|
|
17
|
+
*
|
|
18
|
+
* Invoke via `mailwoman corpus fetch tw-chunghwa-post-offices`.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { APIClient } from "@mailwoman/core/api"
|
|
22
|
+
import { isSuccessStatus } from "@mailwoman/core/api/responses"
|
|
23
|
+
import { ByteFormatter } from "@mailwoman/core/fs/formatters"
|
|
24
|
+
import { statPath } from "@mailwoman/core/fs/readers/stat"
|
|
25
|
+
import {
|
|
26
|
+
makeDirectories,
|
|
27
|
+
movePath,
|
|
28
|
+
removePathIfPresent,
|
|
29
|
+
stagingSiblingPath,
|
|
30
|
+
writeLocalJSONFile,
|
|
31
|
+
} from "@mailwoman/core/fs/writers"
|
|
32
|
+
import { sha256File } from "@mailwoman/core/hash"
|
|
33
|
+
import { PathBuilder, type PathBuilderLike } from "path-ts"
|
|
34
|
+
|
|
35
|
+
import { readCSVRecords } from "#recipes/scaffold"
|
|
36
|
+
import type { BaseFetchOptions, FetchSummary, SourceManifest } from "#tools/fetch/download"
|
|
37
|
+
import { DEFAULT_RETRY_DELAY_MS, streamDownload, writeManifest } from "#tools/fetch/download"
|
|
38
|
+
import {
|
|
39
|
+
TW_CHUNGHWA_POST_COLUMNS,
|
|
40
|
+
TW_CHUNGHWA_POST_FILENAME,
|
|
41
|
+
TW_CHUNGHWA_POST_SOURCE_ID,
|
|
42
|
+
} from "#tw/structures/chunghwa-post"
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The dataset record on data.gov.tw.
|
|
46
|
+
*/
|
|
47
|
+
export const TW_CHUNGHWA_POST_DATASET_URL = "https://data.gov.tw/api/v2/rest/dataset/5950"
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The CSV distribution the dataset record names.
|
|
51
|
+
*/
|
|
52
|
+
export const TW_CHUNGHWA_POST_CSV_URL =
|
|
53
|
+
"https://www.post.gov.tw/post/internet/Templates/getOpenDataFile.jsp?vkey=B484EB27-B3F0-4D02-8F62-047D20C64078"
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The file the dataset record is saved to, beside the CSV.
|
|
57
|
+
*/
|
|
58
|
+
export const TW_CHUNGHWA_POST_DATASET_FILENAME = "dataset.json"
|
|
59
|
+
|
|
60
|
+
const SLUG = TW_CHUNGHWA_POST_SOURCE_ID
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The parts of the data.gov.tw dataset record a fetch reads.
|
|
64
|
+
*/
|
|
65
|
+
interface TWDatasetRecord {
|
|
66
|
+
success?: boolean
|
|
67
|
+
result?: { title?: string; modifiedDate?: string; license?: string; publisher?: string }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* What one run recorded.
|
|
72
|
+
* `publisher_version` is the record's `modifiedDate`.
|
|
73
|
+
*/
|
|
74
|
+
export interface TWChunghwaPostManifest extends SourceManifest {
|
|
75
|
+
dataset_url: string
|
|
76
|
+
records: number
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface DownloadTWChunghwaPostOptions {
|
|
80
|
+
outputDir: PathBuilderLike
|
|
81
|
+
retryDelayMs?: number
|
|
82
|
+
report?: (line: string) => void
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Downloads the CSV into `<outputDir>/post-offices.csv` and writes the dataset record and the manifest.
|
|
87
|
+
*
|
|
88
|
+
* @throws When the CSV answers an error status, or lacks a column the adapter reads.
|
|
89
|
+
*/
|
|
90
|
+
export async function downloadTWChunghwaPost(
|
|
91
|
+
client: Pick<APIClient, "fetch">,
|
|
92
|
+
options: DownloadTWChunghwaPostOptions
|
|
93
|
+
): Promise<FetchSummary> {
|
|
94
|
+
const { report } = options
|
|
95
|
+
const destDir = PathBuilder.from(options.outputDir)
|
|
96
|
+
const csvPath = destDir(TW_CHUNGHWA_POST_FILENAME)
|
|
97
|
+
|
|
98
|
+
report?.(`=== ${SLUG} / ${TW_CHUNGHWA_POST_FILENAME}`)
|
|
99
|
+
|
|
100
|
+
const { data: dataset } = await client.fetch<TWDatasetRecord>({ url: TW_CHUNGHWA_POST_DATASET_URL })
|
|
101
|
+
const result = dataset?.result ?? {}
|
|
102
|
+
|
|
103
|
+
report?.(` ${result.title ?? "untitled"}; modified ${result.modifiedDate ?? "unstated"}`)
|
|
104
|
+
|
|
105
|
+
await makeDirectories(destDir)
|
|
106
|
+
|
|
107
|
+
const staging = stagingSiblingPath(csvPath)
|
|
108
|
+
let records = 0
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const status = await streamDownload(TW_CHUNGHWA_POST_CSV_URL, staging, {
|
|
112
|
+
timeoutMs: 300_000,
|
|
113
|
+
retries: 3,
|
|
114
|
+
retryDelayMs: options.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS,
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
if (!isSuccessStatus(status)) throw new Error(`${SLUG}: ${TW_CHUNGHWA_POST_CSV_URL} answered HTTP ${status}`)
|
|
118
|
+
|
|
119
|
+
for await (const record of readCSVRecords(staging)) {
|
|
120
|
+
if (records === 0) {
|
|
121
|
+
const missing = TW_CHUNGHWA_POST_COLUMNS.filter((column) => !(column in record))
|
|
122
|
+
|
|
123
|
+
if (missing.length) throw new Error(`${SLUG}: the CSV has no column ${missing.join(", ")}`)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
records++
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!records) throw new Error(`${SLUG}: the CSV holds no row`)
|
|
130
|
+
|
|
131
|
+
await movePath(staging, csvPath)
|
|
132
|
+
} finally {
|
|
133
|
+
await removePathIfPresent(staging)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
await writeLocalJSONFile((dataset ?? {}) as Record<string, unknown>, destDir(TW_CHUNGHWA_POST_DATASET_FILENAME))
|
|
137
|
+
|
|
138
|
+
const sha256 = await sha256File(csvPath)
|
|
139
|
+
const { size: bytes } = await statPath(csvPath)
|
|
140
|
+
|
|
141
|
+
const manifest: TWChunghwaPostManifest = {
|
|
142
|
+
source_url: TW_CHUNGHWA_POST_CSV_URL,
|
|
143
|
+
dataset_url: TW_CHUNGHWA_POST_DATASET_URL,
|
|
144
|
+
filename: TW_CHUNGHWA_POST_FILENAME,
|
|
145
|
+
records,
|
|
146
|
+
bytes,
|
|
147
|
+
sha256,
|
|
148
|
+
...(result.modifiedDate ? { publisher_version: result.modifiedDate } : {}),
|
|
149
|
+
downloaded_at: new Date().toISOString(),
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
await writeManifest(destDir("MANIFEST.json"), manifest)
|
|
153
|
+
|
|
154
|
+
report?.(` ✓ ${records.toLocaleString()} rows, ${ByteFormatter.formatIEC(bytes)} sha256=${sha256}`)
|
|
155
|
+
|
|
156
|
+
return { fetched: 1, skipped: 0, failed: 0, failedCodes: [] }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The registry entry.
|
|
161
|
+
*/
|
|
162
|
+
export async function fetchTWChunghwaPost(
|
|
163
|
+
options: BaseFetchOptions,
|
|
164
|
+
report?: (line: string) => void
|
|
165
|
+
): Promise<FetchSummary> {
|
|
166
|
+
await using client = new APIClient({ displayName: SLUG, retry: true })
|
|
167
|
+
|
|
168
|
+
// Awaited rather than returned: `await using` disposes the client when this scope exits.
|
|
169
|
+
return await downloadTWChunghwaPost(client, {
|
|
170
|
+
outputDir: options.outRoot(SLUG),
|
|
171
|
+
retryDelayMs: options.retryDelayMs,
|
|
172
|
+
report,
|
|
173
|
+
})
|
|
174
|
+
}
|
|
@@ -23,7 +23,7 @@ import { SourceRegister } from "#registers"
|
|
|
23
23
|
import { streetIndexOpener } from "#street-index/reader"
|
|
24
24
|
import { AddressRole, type AdapterOptions, type CanonicalRow, type CorpusAdapter, SurfaceOrigin } from "#types"
|
|
25
25
|
import { lookupStateAbbreviation } from "#us/fips-state"
|
|
26
|
-
import { splitUSStreetLine } from "#us/street-unit"
|
|
26
|
+
import { splitUSStreetLine, usPOBoxLine } from "#us/street-unit"
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Registry id for this adapter.
|
|
@@ -81,8 +81,13 @@ export function createStateNyNotariesAdapter(): CorpusAdapter {
|
|
|
81
81
|
|
|
82
82
|
if (!state) continue
|
|
83
83
|
|
|
84
|
+
// A business line followed by a box line (`ONE PLEASANT AVE`, `POB 1424`)
|
|
85
|
+
// is delivered to the box, the line above the city.
|
|
86
|
+
// When either line is a whole-line box, the row keeps that line as its `po_box`
|
|
87
|
+
// and leaves the other line out.
|
|
88
|
+
const boxLine = usPOBoxLine(address2) ?? usPOBoxLine(address1)
|
|
84
89
|
const fullAddress = [address1, address2].filter(isPresent).join(" ")
|
|
85
|
-
const line = splitUSStreetLine(fullAddress, units)
|
|
90
|
+
const line = boxLine ?? splitUSStreetLine(fullAddress, units)
|
|
86
91
|
|
|
87
92
|
if (!line) continue
|
|
88
93
|
|
|
@@ -16,16 +16,18 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { formatAddressRow } from "@mailwoman/codex/address/format"
|
|
19
|
+
import { isPresent } from "@mailwoman/core/objects"
|
|
19
20
|
import { formatPersonName } from "@mailwoman/record/name"
|
|
20
21
|
import { CSVSpliterator } from "spliterator"
|
|
21
22
|
|
|
22
23
|
import { stableSourceID } from "#adapters/source-id"
|
|
24
|
+
import { splitStreetLine } from "#adapters/street/line"
|
|
23
25
|
import { createUnitSplitter } from "#adapters/street/unit"
|
|
24
26
|
import { SourceRegister } from "#registers"
|
|
25
27
|
import { streetIndexOpener } from "#street-index/reader"
|
|
26
28
|
import { AddressRole, type AdapterOptions, type CanonicalRow, type CorpusAdapter, SurfaceOrigin } from "#types"
|
|
27
|
-
import { lookupStateAbbreviation } from "#us/fips-state"
|
|
28
|
-
import { splitUSStreetLine } from "#us/street-unit"
|
|
29
|
+
import { lookupStateAbbreviation, type USStateInfo } from "#us/fips-state"
|
|
30
|
+
import { splitUSStreetLine, unitLine } from "#us/street-unit"
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Registry id for this adapter.
|
|
@@ -40,9 +42,116 @@ export const STATE_TX_NOTARIES_ADAPTER_ID = "state-tx-notaries"
|
|
|
40
42
|
export const STATE_TX_NOTARIES_DEFAULT_LICENSE = "Public Domain"
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
45
|
+
* The trailing `, ST ZIP` or `, ST` the registry writes after the city.
|
|
44
46
|
*/
|
|
45
|
-
const
|
|
47
|
+
const STATE_ZIP_SUFFIX = /,\s*([A-Z]{2})\s*(\d{5}(?:-\d{4})?)?\s*$/i
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* An address field split into the street text before its city, the city,
|
|
51
|
+
* its state abbreviation and its ZIP Code.
|
|
52
|
+
*/
|
|
53
|
+
export interface TxNotaryAddress {
|
|
54
|
+
street: string
|
|
55
|
+
city: string
|
|
56
|
+
state: USStateInfo
|
|
57
|
+
zip: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Splits a registry `Address` field, such as `"1215 mcmillan DR\nCEDAR hill, TX 75104"`,
|
|
62
|
+
* at its trailing city, state and ZIP Code, or returns `null` when the state isn't
|
|
63
|
+
* a US one or no comma-separated city precedes it.
|
|
64
|
+
*
|
|
65
|
+
* The registry appends its own `, ST ZIP` to the city a notary typed, and that city
|
|
66
|
+
* sometimes already ends in the state, a country or the ZIP Code: `Houston, TX, TX 77043`,
|
|
67
|
+
* `San Antonio TX, TX 78245`, `Godley, Texas 76044, TX 76044`, `Houston TX 77006, US, TX 77006`.
|
|
68
|
+
* Those repetitions are removed before the city is read, so the city is `Houston`
|
|
69
|
+
* and the state isn't taken for the city.
|
|
70
|
+
*/
|
|
71
|
+
export function parseTxNotaryAddress(rawAddress: string): TxNotaryAddress | null {
|
|
72
|
+
const line = rawAddress.replaceAll("\n", ", ")
|
|
73
|
+
const suffix = STATE_ZIP_SUFFIX.exec(line)
|
|
74
|
+
const state = lookupStateAbbreviation(suffix?.[1] ?? null)
|
|
75
|
+
|
|
76
|
+
if (!suffix || !state) return null
|
|
77
|
+
|
|
78
|
+
const zip = suffix[2] ?? ""
|
|
79
|
+
|
|
80
|
+
const repetitions = [
|
|
81
|
+
`[\\s,]+(?:${state.abbreviation}\\.?|${state.name})`,
|
|
82
|
+
",\\s*USA?",
|
|
83
|
+
...(zip ? [`[\\s,]+${zip}`] : []),
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
const repeated = new RegExp(`(?:${repetitions.join("|")})\\s*$`, "iu")
|
|
87
|
+
|
|
88
|
+
let head = line.slice(0, suffix.index)
|
|
89
|
+
|
|
90
|
+
for (let match = repeated.exec(head); match; match = repeated.exec(head)) {
|
|
91
|
+
head = head.slice(0, match.index)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const comma = head.lastIndexOf(",")
|
|
95
|
+
|
|
96
|
+
if (comma === -1) return null
|
|
97
|
+
|
|
98
|
+
return { street: head.slice(0, comma).replace(/,\s*$/u, "").trim(), city: head.slice(comma + 1).trim(), state, zip }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A notary's street text as its first line and the unit lines typed after it.
|
|
103
|
+
*/
|
|
104
|
+
export interface TxNotaryStreetLines {
|
|
105
|
+
line: string
|
|
106
|
+
units: string[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Splits the street text {@linkcode parseTxNotaryAddress} returns into its first line
|
|
111
|
+
* and the unit lines typed after it, in their written order.
|
|
112
|
+
*
|
|
113
|
+
* Notaries type a suite or department as its own line (`555 N. Carancahua, Suite 620`),
|
|
114
|
+
* and some type the street line twice (`231 Blanco Dr, 231 Blanco Dr`).
|
|
115
|
+
* A trailing comma-separated segment that {@linkcode unitLine} reads as a unit joins `units`,
|
|
116
|
+
* and one that repeats the first line, with or without its house number, is removed.
|
|
117
|
+
*
|
|
118
|
+
* The split stops at the first trailing segment that's neither, so the street keeps every segment before it.
|
|
119
|
+
*/
|
|
120
|
+
export function splitTxNotaryStreetLines(street: string): TxNotaryStreetLines {
|
|
121
|
+
// The unit splitter collapses a line's inner whitespace when it splits one, so a peeled line does too.
|
|
122
|
+
const collapse = (text: string) => text.trim().replaceAll(/\s+/gu, " ")
|
|
123
|
+
const comparable = (text: string) => collapse(text).toLowerCase()
|
|
124
|
+
const first = street.split(",")[0] ?? ""
|
|
125
|
+
const repeats = new Set([first, splitStreetLine(first)?.street ?? first].map(comparable))
|
|
126
|
+
const units: string[] = []
|
|
127
|
+
let line = street
|
|
128
|
+
|
|
129
|
+
for (let comma = line.lastIndexOf(","); comma > 0; comma = line.lastIndexOf(",")) {
|
|
130
|
+
const last = line.slice(comma + 1)
|
|
131
|
+
const unit = unitLine(last)
|
|
132
|
+
|
|
133
|
+
if (unit) {
|
|
134
|
+
units.unshift(unit)
|
|
135
|
+
} else if (last.trim() && !repeats.has(comparable(last))) {
|
|
136
|
+
break
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
line = line.slice(0, comma).trimEnd()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (line === street) return { line, units }
|
|
143
|
+
|
|
144
|
+
return { line: collapse(line), units: units.map(collapse) }
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The `unit` component for a street line's own trailing unit followed by the unit lines typed after it.
|
|
149
|
+
*/
|
|
150
|
+
function withUnitLines(trailing: string | undefined, typed: readonly string[]): { unit?: string } {
|
|
151
|
+
const unit = [trailing, ...typed].filter(isPresent).join(" ")
|
|
152
|
+
|
|
153
|
+
return unit ? { unit } : {}
|
|
154
|
+
}
|
|
46
155
|
|
|
47
156
|
interface TxNotaryRow {
|
|
48
157
|
"Notary ID": string
|
|
@@ -87,29 +196,25 @@ export function createStateTxNotariesAdapter(): CorpusAdapter {
|
|
|
87
196
|
const lastName = record["Last Name"] ?? ""
|
|
88
197
|
const notaryID = record["Notary ID"] ?? ""
|
|
89
198
|
|
|
90
|
-
|
|
91
|
-
// Addresses look like: "1215 mcmillan DR\nCEDAR hill, TX 75104"
|
|
92
|
-
const addrSingleLine = rawAddress.replaceAll("\n", ", ")
|
|
93
|
-
const cszMatch = CITY_STATE_ZIP_SUFFIX.exec(addrSingleLine)
|
|
94
|
-
|
|
95
|
-
if (!cszMatch) continue
|
|
96
|
-
|
|
97
|
-
const city = (cszMatch[1] ?? "").trim()
|
|
98
|
-
const stateAbbr = (cszMatch[2] ?? "").trim()
|
|
99
|
-
const zip = (cszMatch[3] ?? "").trim()
|
|
199
|
+
const address = parseTxNotaryAddress(rawAddress)
|
|
100
200
|
|
|
101
|
-
if (!city
|
|
201
|
+
if (!address?.city) continue
|
|
102
202
|
|
|
103
|
-
const state =
|
|
203
|
+
const { city, state, zip, street: streetPortion } = address
|
|
104
204
|
|
|
105
|
-
if (!
|
|
205
|
+
if (!streetPortion) continue
|
|
106
206
|
|
|
107
|
-
|
|
108
|
-
const
|
|
207
|
+
const typed = splitTxNotaryStreetLines(streetPortion)
|
|
208
|
+
const split = splitUSStreetLine(typed.line, units)
|
|
109
209
|
|
|
110
|
-
if (!
|
|
210
|
+
if (!split) continue
|
|
111
211
|
|
|
112
|
-
|
|
212
|
+
// A PO box row emits no unit, so a box followed by a unit line keeps its whole street text.
|
|
213
|
+
const line = !("po_box" in split)
|
|
214
|
+
? { ...split, ...withUnitLines(split.unit, typed.units) }
|
|
215
|
+
: typed.units.length
|
|
216
|
+
? splitUSStreetLine(streetPortion, units)
|
|
217
|
+
: split
|
|
113
218
|
|
|
114
219
|
if (!line) continue
|
|
115
220
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { formatAddressRow } from "@mailwoman/codex/address/format"
|
|
9
|
+
import { namesUSCounty } from "@mailwoman/codex/us/county"
|
|
9
10
|
import { US_STATE_ABBREVIATIONS } from "@mailwoman/codex/us/state"
|
|
10
11
|
import { isPresent } from "@mailwoman/core/objects"
|
|
11
12
|
import type { PathBuilderLike } from "path-ts"
|
|
@@ -143,7 +144,36 @@ export function normalizeNADUUID(value: string | null | undefined): string | nul
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
/**
|
|
146
|
-
*
|
|
147
|
+
* The spellings NAD contributors write in a text column to mean the column is empty,
|
|
148
|
+
* matched case-insensitively after trimming: `<Null>`, `NULL`, `None`, `N/A`,
|
|
149
|
+
* `NA`, `Unknown`, and runs of `-` or `.`.
|
|
150
|
+
*/
|
|
151
|
+
const NAD_PLACEHOLDER_TEXT = /^(?:<null>|null|none|n\/?a|unknown|-+|\.+)$/iu
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* A NAD record with each text column that holds a {@link NAD_PLACEHOLDER_TEXT}
|
|
155
|
+
* spelling read as absent, and its UUID normalized.
|
|
156
|
+
*
|
|
157
|
+
* `Placement` is left as published, because there `Unknown` is a value of the
|
|
158
|
+
* column's own domain that names how the point was placed.
|
|
159
|
+
*/
|
|
160
|
+
export function normalizeNADRecord(record: NADRecord): NADRecord {
|
|
161
|
+
const normalized: Record<string, unknown> = { ...record }
|
|
162
|
+
|
|
163
|
+
for (const column of NAD_RECORD_COLUMNS) {
|
|
164
|
+
const value = record[column]
|
|
165
|
+
|
|
166
|
+
if (column !== "Placement" && typeof value === "string" && NAD_PLACEHOLDER_TEXT.test(value.trim())) {
|
|
167
|
+
normalized[column] = null
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return { ...(normalized as NADRecord), UUID: normalizeNADUUID(record.UUID) }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Streams the NAD records of one release Parquet file in file order,
|
|
176
|
+
* each passed through {@linkcode normalizeNADRecord}.
|
|
147
177
|
*
|
|
148
178
|
* @param where A DuckDB condition rows must satisfy, built with `escapeSQLString` for every literal.
|
|
149
179
|
* @throws When the file lacks a column of {@link NAD_RECORD_COLUMNS}.
|
|
@@ -158,7 +188,7 @@ export async function* readNADRecords(
|
|
|
158
188
|
})
|
|
159
189
|
|
|
160
190
|
for await (const row of rows) {
|
|
161
|
-
yield
|
|
191
|
+
yield normalizeNADRecord(row)
|
|
162
192
|
}
|
|
163
193
|
}
|
|
164
194
|
|
|
@@ -178,14 +208,28 @@ const US_STATES_SET: ReadonlySet<string> = new Set(US_STATE_ABBREVIATIONS)
|
|
|
178
208
|
*
|
|
179
209
|
* A publisher may write one designator into several columns, as New York writes `Apartment 2`
|
|
180
210
|
* into both `Building` and `Unit`, so a part that repeats an earlier one is kept once.
|
|
211
|
+
*
|
|
212
|
+
* A publisher may also copy the landmark or the street into a unit column, as Oklahoma writes
|
|
213
|
+
* `RM ENERGY` as both `LandmkName` and `Unit`, and `DAUBE RANCH` as both `St_Name` and `Unit`.
|
|
214
|
+
* Such a part isn't a unit designator, so it's left out.
|
|
215
|
+
*
|
|
216
|
+
* A part holding a digit or a single character is kept even when it equals the street's name,
|
|
217
|
+
* because `A` on `Avenue A` and `17` on `Highway 17` read as unit designators too.
|
|
181
218
|
*/
|
|
182
219
|
export function nadUnitText(record: NADRecord): string | null {
|
|
220
|
+
const street = decomposeNADStreet(record)
|
|
221
|
+
|
|
222
|
+
const owned = new Set(
|
|
223
|
+
[record.LandmkName?.trim(), street?.street, street?.full].filter(isPresent).map((v) => v.toLowerCase())
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
const repeatsOwner = (part: string) => part.length > 1 && !/\d/u.test(part) && owned.has(part.toLowerCase())
|
|
183
227
|
const parts = new Set<string>()
|
|
184
228
|
|
|
185
229
|
for (const part of [record.Building, record.Floor, record.Unit, record.Room]) {
|
|
186
230
|
const trimmed = part?.trim()
|
|
187
231
|
|
|
188
|
-
if (trimmed) {
|
|
232
|
+
if (trimmed && !repeatsOwner(trimmed)) {
|
|
189
233
|
parts.add(trimmed)
|
|
190
234
|
}
|
|
191
235
|
}
|
|
@@ -308,6 +352,66 @@ function composePostcode(r: NADRecord): string | null {
|
|
|
308
352
|
return plus4 ? `${zip}-${plus4}` : zip
|
|
309
353
|
}
|
|
310
354
|
|
|
355
|
+
/**
|
|
356
|
+
* The address components the adapter renders for one NAD record, or `null`
|
|
357
|
+
* when the record lacks a US state code, a locality or a ZIP Code.
|
|
358
|
+
*/
|
|
359
|
+
export function nadAddressComponents(record: NADRecord): CanonicalRow["components"] | null {
|
|
360
|
+
const state = (record.State ?? "").trim().toUpperCase()
|
|
361
|
+
|
|
362
|
+
if (!US_STATES_SET.has(state)) return null
|
|
363
|
+
|
|
364
|
+
const locality = composeNADLocality(record)
|
|
365
|
+
|
|
366
|
+
if (!locality) return null
|
|
367
|
+
|
|
368
|
+
const postcode = composePostcode(record)
|
|
369
|
+
|
|
370
|
+
if (!postcode) return null
|
|
371
|
+
|
|
372
|
+
const decomposed = decomposeNADStreet(record)
|
|
373
|
+
const houseNumber = nadHouseNumber(record)
|
|
374
|
+
const venue = nonEmpty(record.LandmkName)
|
|
375
|
+
const unit = nadUnitText(record)
|
|
376
|
+
|
|
377
|
+
return {
|
|
378
|
+
...(venue ? { venue } : {}),
|
|
379
|
+
...(houseNumber ? { house_number: houseNumber } : {}),
|
|
380
|
+
...(decomposed?.prefix ? { street_prefix: decomposed.prefix } : {}),
|
|
381
|
+
...(decomposed?.street ? { street: decomposed.street } : {}),
|
|
382
|
+
...(decomposed?.suffix ? { street_suffix: decomposed.suffix } : {}),
|
|
383
|
+
...(unit ? { unit } : {}),
|
|
384
|
+
locality,
|
|
385
|
+
region: state,
|
|
386
|
+
postcode,
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The rendered components with a locality that writes the record's own county moved to `subregion`.
|
|
392
|
+
*
|
|
393
|
+
* NAD contributors fill a place column with the county for an address outside any
|
|
394
|
+
* municipality: Oregon's `Inc_Muni` reads `Polk County` where `County` reads `Polk`,
|
|
395
|
+
* and Texas's `Post_City` reads `DENTON COUNTY`.
|
|
396
|
+
* The row's text keeps the county where the locality would be, as
|
|
397
|
+
* `1 1st Street, Polk County, OR 97347`, and the span is labeled the county it is.
|
|
398
|
+
*
|
|
399
|
+
* A place that shares its county's name without a designator (`Denton` in Denton County) stays a locality.
|
|
400
|
+
*/
|
|
401
|
+
export function nadCountyAsSubregion(
|
|
402
|
+
components: CanonicalRow["components"],
|
|
403
|
+
record: Pick<NADRecord, "County">
|
|
404
|
+
): CanonicalRow["components"] {
|
|
405
|
+
const locality = components["locality"]
|
|
406
|
+
const county = record.County?.trim()
|
|
407
|
+
|
|
408
|
+
if (!locality || !county || !namesUSCounty(locality, county)) return components
|
|
409
|
+
|
|
410
|
+
return Object.fromEntries(
|
|
411
|
+
Object.entries(components).map(([tag, value]) => [tag === "locality" ? "subregion" : tag, value])
|
|
412
|
+
) as CanonicalRow["components"]
|
|
413
|
+
}
|
|
414
|
+
|
|
311
415
|
/**
|
|
312
416
|
* Creates the NAD adapter.
|
|
313
417
|
*
|
|
@@ -337,40 +441,16 @@ export function createUsgovNADAdapter(): CorpusAdapter {
|
|
|
337
441
|
|
|
338
442
|
if (typeof opts.limit === "number" && emitted >= opts.limit) break
|
|
339
443
|
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
if (!US_STATES_SET.has(state)) continue
|
|
343
|
-
|
|
344
|
-
const locality = composeNADLocality(record)
|
|
444
|
+
const components = nadAddressComponents(record)
|
|
345
445
|
|
|
346
|
-
if (!
|
|
347
|
-
|
|
348
|
-
const postcode = composePostcode(record)
|
|
349
|
-
|
|
350
|
-
if (!postcode) continue
|
|
351
|
-
|
|
352
|
-
const decomposed = decomposeNADStreet(record)
|
|
353
|
-
const houseNumber = nadHouseNumber(record)
|
|
354
|
-
const venue = nonEmpty(record.LandmkName)
|
|
355
|
-
const unit = nadUnitText(record)
|
|
356
|
-
|
|
357
|
-
const components: CanonicalRow["components"] = {
|
|
358
|
-
...(venue ? { venue } : {}),
|
|
359
|
-
...(houseNumber ? { house_number: houseNumber } : {}),
|
|
360
|
-
...(decomposed?.prefix ? { street_prefix: decomposed.prefix } : {}),
|
|
361
|
-
...(decomposed?.street ? { street: decomposed.street } : {}),
|
|
362
|
-
...(decomposed?.suffix ? { street_suffix: decomposed.suffix } : {}),
|
|
363
|
-
...(unit ? { unit } : {}),
|
|
364
|
-
locality,
|
|
365
|
-
region: state,
|
|
366
|
-
postcode,
|
|
367
|
-
}
|
|
446
|
+
if (!components) continue
|
|
368
447
|
|
|
369
448
|
const rendered = formatAddressRow(components, "US", { singleLine: true })
|
|
370
449
|
|
|
371
450
|
if (!rendered) continue
|
|
372
451
|
|
|
373
|
-
const { raw
|
|
452
|
+
const { raw } = rendered
|
|
453
|
+
const aligned = nadCountyAsSubregion(rendered.components, record)
|
|
374
454
|
|
|
375
455
|
if (Object.keys(aligned).length <= 2) continue
|
|
376
456
|
|
|
@@ -13,13 +13,12 @@ import type { PathBuilderLike } from "path-ts"
|
|
|
13
13
|
import { CSVSpliterator } from "spliterator"
|
|
14
14
|
|
|
15
15
|
import { stableSourceID } from "#adapters/source-id"
|
|
16
|
-
import { splitStreetLine } from "#adapters/street/line"
|
|
17
16
|
import { createUnitSplitter } from "#adapters/street/unit"
|
|
18
17
|
import { SourceRegister } from "#registers"
|
|
19
18
|
import { streetIndexOpener } from "#street-index/reader"
|
|
20
19
|
import { AddressRole, type AdapterOptions, type CanonicalRow, type CorpusAdapter, SurfaceOrigin } from "#types"
|
|
21
20
|
import { lookupStateAbbreviation } from "#us/fips-state"
|
|
22
|
-
import { unitLine } from "#us/street-unit"
|
|
21
|
+
import { splitUSStreetLine, unitLine } from "#us/street-unit"
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* The adapter stamps this id on every emitted row.
|
|
@@ -138,23 +137,21 @@ export function createUsgovNPPESAdapter(): CorpusAdapter {
|
|
|
138
137
|
|
|
139
138
|
if (!state) continue
|
|
140
139
|
|
|
141
|
-
|
|
140
|
+
// A whole-line PO box (`PO BOX 1191`, `POB 1191`) is `po_box`.
|
|
141
|
+
// A unit written on the first line (`2560 HUNTINGTON AVE STE 302`) is split off the street,
|
|
142
|
+
// and one on the second line follows it, so the rendered row keeps the publisher's order.
|
|
143
|
+
const split = splitUSStreetLine(address1, units, { locality: city, postcode })
|
|
142
144
|
|
|
143
145
|
if (!split) continue
|
|
144
146
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const trailing = units.split(split.street, { country: "US", locality: city, postcode })
|
|
148
|
-
const street = trailing?.street ?? split.street
|
|
149
|
-
const unit = [trailing?.unit, unitLine(address2)].filter(isPresent).join(" ")
|
|
147
|
+
const unit = "po_box" in split ? "" : [split.unit, unitLine(address2)].filter(isPresent).join(" ")
|
|
148
|
+
const line = unit ? { ...split, unit } : split
|
|
150
149
|
|
|
151
150
|
const venue = orgName || formatPersonName({ given: firstName, family: lastName }, "short") || undefined
|
|
152
151
|
|
|
153
152
|
const components: CanonicalRow["components"] = {
|
|
154
153
|
...(venue ? { venue } : {}),
|
|
155
|
-
...
|
|
156
|
-
street,
|
|
157
|
-
...(unit ? { unit } : {}),
|
|
154
|
+
...line,
|
|
158
155
|
locality: city,
|
|
159
156
|
region: state.abbreviation,
|
|
160
157
|
postcode,
|