@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
|
@@ -135,6 +135,7 @@ import { Globerator } from "spliterator/node/fs"
|
|
|
135
135
|
import { loadLibpostalDictionary } from "#adapters/libpostal-dictionary"
|
|
136
136
|
import { stableSourceID } from "#adapters/source-id"
|
|
137
137
|
import { splitStreetLine, splitTrailingStreetLine, type SplitStreetLine } from "#adapters/street/line"
|
|
138
|
+
import { joinRepetitionIndex } from "#adapters/street/repetition"
|
|
138
139
|
import { createUnitSplitter, type UnitSplitter } from "#adapters/street/unit"
|
|
139
140
|
import { SourceRegister } from "#registers"
|
|
140
141
|
import { streetIndexOpener } from "#street-index/reader"
|
|
@@ -482,10 +483,13 @@ const LEADING_NUMBER_COMMA = /^(\d+[\p{L}]?),\s*/u
|
|
|
482
483
|
*
|
|
483
484
|
* `order` is `null` for a country with no unambiguous side, and such a line
|
|
484
485
|
* is kept only where it holds no digit.
|
|
486
|
+
* In a `country` that writes a repetition index, `20 BIS RUE LOUIS PHILIPPE` yields the house number
|
|
487
|
+
* `20 BIS` and the street `RUE LOUIS PHILIPPE`, as {@linkcode joinRepetitionIndex} reads it.
|
|
485
488
|
*/
|
|
486
489
|
export function splitCORDISStreetLine(
|
|
487
490
|
line: string,
|
|
488
|
-
order: StreetOrder | null
|
|
491
|
+
order: StreetOrder | null,
|
|
492
|
+
country?: string
|
|
489
493
|
): SplitStreetLine | { refused: CORDISRefusal } | null {
|
|
490
494
|
const trimmed = line
|
|
491
495
|
.replaceAll(/\s+/gu, " ")
|
|
@@ -501,6 +505,10 @@ export function splitCORDISStreetLine(
|
|
|
501
505
|
|
|
502
506
|
if (order === StreetOrder.NumberFirst) {
|
|
503
507
|
split = splitStreetLine(trimmed.replace(LEADING_NUMBER_COMMA, "$1 "))
|
|
508
|
+
|
|
509
|
+
if (split && country) {
|
|
510
|
+
split = joinRepetitionIndex(split, country)
|
|
511
|
+
}
|
|
504
512
|
} else if (order === StreetOrder.NumberLast) {
|
|
505
513
|
split = splitTrailingStreetLine(trimmed)
|
|
506
514
|
}
|
|
@@ -566,7 +574,7 @@ export function readCORDISRecord(
|
|
|
566
574
|
// A unit at the end of the line (`BD SAINT-JACQUES BATIMENT B`) comes off first,
|
|
567
575
|
// so its identifier is never read as the house number.
|
|
568
576
|
const lineUnit = units.split(streetLine, { country, locality, postcode: fieldValue(record.postCode) })
|
|
569
|
-
const split = splitCORDISStreetLine(lineUnit?.street ?? streetLine, streetOrderForCountry(country))
|
|
577
|
+
const split = splitCORDISStreetLine(lineUnit?.street ?? streetLine, streetOrderForCountry(country), country)
|
|
570
578
|
|
|
571
579
|
if (split && "refused" in split) return { refused: split.refused, country }
|
|
572
580
|
|
|
@@ -124,6 +124,7 @@ import { Globerator } from "spliterator/node/fs"
|
|
|
124
124
|
import { UnsupportedCountryError } from "#adapters/errors"
|
|
125
125
|
import { stableSourceID } from "#adapters/source-id"
|
|
126
126
|
import { splitStreetLine, splitTrailingStreetLine } from "#adapters/street/line"
|
|
127
|
+
import { joinRepetitionIndex, withoutRepetitionIndex } from "#adapters/street/repetition"
|
|
127
128
|
import { createUnitSplitter, type UnitSplitter } from "#adapters/street/unit"
|
|
128
129
|
import { FingerprintSet } from "#fingerprints"
|
|
129
130
|
import { isPlaceholderValue } from "#it/adapters/anac/adapter"
|
|
@@ -682,7 +683,9 @@ function placeStreetNumber(
|
|
|
682
683
|
// `49, AVENUE JOHN F. KENNEDY` does.
|
|
683
684
|
// The layout renders its own separator.
|
|
684
685
|
// The comma stays out of the component.
|
|
685
|
-
|
|
686
|
+
// A repetition index after a leading number belongs to the number: `20 BIS RUE LOUIS PHILIPPE`.
|
|
687
|
+
const leading = leads ? splitStreetLine(line.replace(LEADING_NUMBER_COMMA, "$1 ")) : null
|
|
688
|
+
const split = leads ? leading && joinRepetitionIndex(leading, country) : splitTrailingStreetLine(line)
|
|
686
689
|
|
|
687
690
|
if (!split?.house_number || ZERO_NUMBER.test(split.house_number) || unplacedDigit(split.street)) {
|
|
688
691
|
return { refused: GLEIFRefusal.StreetNumberUnplaced }
|
|
@@ -692,7 +695,7 @@ function placeStreetNumber(
|
|
|
692
695
|
|
|
693
696
|
if (refusal) return { refused: refusal }
|
|
694
697
|
|
|
695
|
-
if (addressNumber && !numberAgrees(split.house_number, addressNumber)) {
|
|
698
|
+
if (addressNumber && !numberAgrees(split.house_number, addressNumber, country)) {
|
|
696
699
|
return { refused: GLEIFRefusal.StreetNumberDisagrees }
|
|
697
700
|
}
|
|
698
701
|
|
|
@@ -715,12 +718,27 @@ function streetRefusal(street: string): GLEIFRefusal | null {
|
|
|
715
718
|
/**
|
|
716
719
|
* Whether a split's house number is the publisher's `AddressNumber`, or that number
|
|
717
720
|
* with a subdivision joined to it, as `1A/3` is to `1A`.
|
|
721
|
+
*
|
|
722
|
+
* In a country that writes a repetition index, `20 BIS` also agrees with a published `20` or `20BIS`.
|
|
718
723
|
*/
|
|
719
|
-
function numberAgrees(split: string, published: string): boolean {
|
|
720
|
-
const a = split.toUpperCase()
|
|
724
|
+
function numberAgrees(split: string, published: string, country: string): boolean {
|
|
721
725
|
const b = published.replaceAll(/\s+/gu, "").toUpperCase()
|
|
722
726
|
|
|
723
|
-
|
|
727
|
+
const agrees = (candidate: string): boolean => {
|
|
728
|
+
const a = candidate.toUpperCase()
|
|
729
|
+
|
|
730
|
+
return a === b || a.startsWith(`${b}/`) || a.startsWith(`${b}-`)
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (agrees(split)) return true
|
|
734
|
+
|
|
735
|
+
const number = withoutRepetitionIndex(split, country)
|
|
736
|
+
|
|
737
|
+
if (number == null) return false
|
|
738
|
+
|
|
739
|
+
const index = split.slice(number.length).trim()
|
|
740
|
+
|
|
741
|
+
return agrees(number) || agrees(`${number}${index}`)
|
|
724
742
|
}
|
|
725
743
|
|
|
726
744
|
/**
|
|
@@ -18,7 +18,7 @@ import { sha256Hex } from "@mailwoman/core/hash"
|
|
|
18
18
|
import { tryParsingJSON } from "@mailwoman/core/json"
|
|
19
19
|
import { extractDelimited } from "@mailwoman/core/scripting/arguments"
|
|
20
20
|
import { stripCombiningMarks } from "@mailwoman/normalize/fold"
|
|
21
|
-
import {
|
|
21
|
+
import { acceptPostcode, statesPostcodeSyntax } from "@mailwoman/postcode/country-formats"
|
|
22
22
|
import { TextSpliterator } from "spliterator"
|
|
23
23
|
|
|
24
24
|
import { OSM_LICENSE } from "#adapters/osm/license"
|
|
@@ -238,7 +238,7 @@ export function componentsForOSMRow(
|
|
|
238
238
|
} else {
|
|
239
239
|
countDropped(
|
|
240
240
|
tally,
|
|
241
|
-
|
|
241
|
+
statesPostcodeSyntax(country) ? "component:postcode:not-country-format" : "component:postcode:country-has-none"
|
|
242
242
|
)
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Moves a repetition index (`bis`, `ter`, `quater`) from the start of a split street
|
|
6
|
+
* onto the house number it follows, in a country that writes one.
|
|
7
|
+
*
|
|
8
|
+
* {@linkcode splitStreetLine} splits `20 BIS RUE LOUIS PHILIPPE` into `20` and `BIS RUE LOUIS PHILIPPE`.
|
|
9
|
+
* The BAN adapter, reading the same address from BAN's own columns,
|
|
10
|
+
* labels `20 bis` as the house number and `RUE LOUIS PHILIPPE` as the street,
|
|
11
|
+
* and this module gives a one-line source that labeling.
|
|
12
|
+
*
|
|
13
|
+
* The words and the countries come from `@mailwoman/codex/house-number-repetition`.
|
|
14
|
+
*
|
|
15
|
+
* It runs after the shared split rather than inside it.
|
|
16
|
+
* The split's other callers read no country, and they keep their output.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { houseNumberRepetitionIndexes } from "@mailwoman/codex/house-number-repetition"
|
|
20
|
+
|
|
21
|
+
import type { SplitStreetLine } from "#adapters/street/line"
|
|
22
|
+
|
|
23
|
+
const patternMemo = new Map<string, { spaced: RegExp; joined: RegExp; trailing: RegExp } | null>()
|
|
24
|
+
|
|
25
|
+
function patternsFor(country: string): { spaced: RegExp; joined: RegExp; trailing: RegExp } | null {
|
|
26
|
+
const key = country.toUpperCase()
|
|
27
|
+
|
|
28
|
+
if (patternMemo.has(key)) return patternMemo.get(key)!
|
|
29
|
+
|
|
30
|
+
const words = houseNumberRepetitionIndexes(key)
|
|
31
|
+
const alternation = words.join("|")
|
|
32
|
+
|
|
33
|
+
const patterns = words.length
|
|
34
|
+
? {
|
|
35
|
+
// The index opening the street, then the street name: `BIS RUE LOUIS PHILIPPE`.
|
|
36
|
+
spaced: new RegExp(`^(${alternation})(?![\\p{L}])[\\s,]+(\\S.*)$`, "iu"),
|
|
37
|
+
// A number with the index written against it, then the street: `20BIS RUE LOUIS PHILIPPE`.
|
|
38
|
+
joined: new RegExp(`^(\\d+(?: ?- ?\\d+)?(?:${alternation}))\\s+(\\S.*)$`, "iu"),
|
|
39
|
+
// A house number that ends in the index: `20 BIS`, `20BIS`.
|
|
40
|
+
trailing: new RegExp(`^(\\d.*?)\\s*(?:${alternation})$`, "iu"),
|
|
41
|
+
}
|
|
42
|
+
: null
|
|
43
|
+
|
|
44
|
+
patternMemo.set(key, patterns)
|
|
45
|
+
|
|
46
|
+
return patterns
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The split with a leading repetition index moved onto the house number,
|
|
51
|
+
* in a country that writes one, or the split unchanged.
|
|
52
|
+
*
|
|
53
|
+
* The index keeps the publisher's spelling, so `26 Bis Boulevard Princesse Charlotte`
|
|
54
|
+
* yields `26 Bis`, and is joined with a space as BAN joins `numero` and `rep`.
|
|
55
|
+
* A number written against its index, `20BIS RUE X`, which the shared split
|
|
56
|
+
* leaves whole, yields `20BIS` and `RUE X`.
|
|
57
|
+
*/
|
|
58
|
+
export function joinRepetitionIndex(split: SplitStreetLine, country: string): SplitStreetLine {
|
|
59
|
+
const patterns = patternsFor(country)
|
|
60
|
+
|
|
61
|
+
if (!patterns) return split
|
|
62
|
+
|
|
63
|
+
if (split.house_number) {
|
|
64
|
+
// Only a bare number or range takes an index, so `20A` keeps the street it was split from.
|
|
65
|
+
if (!/^\d+(?: ?- ?\d+)?$/u.test(split.house_number)) return split
|
|
66
|
+
|
|
67
|
+
const match = patterns.spaced.exec(split.street)
|
|
68
|
+
|
|
69
|
+
return match ? { house_number: `${split.house_number} ${match[1]}`, street: match[2]!.trim() } : split
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const match = patterns.joined.exec(split.street)
|
|
73
|
+
|
|
74
|
+
return match ? { house_number: match[1]!, street: match[2]!.trim() } : split
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The house number without a trailing repetition index, or `null` when it ends in none.
|
|
79
|
+
*
|
|
80
|
+
* A publisher's separate number column may state `20` where the street line writes `20 BIS`,
|
|
81
|
+
* and a caller checking the two against each other compares the number this returns.
|
|
82
|
+
*/
|
|
83
|
+
export function withoutRepetitionIndex(houseNumber: string, country: string): string | null {
|
|
84
|
+
const match = patternsFor(country)?.trailing.exec(houseNumber.trim())
|
|
85
|
+
|
|
86
|
+
return match ? match[1]! : null
|
|
87
|
+
}
|
|
@@ -457,6 +457,13 @@ export interface StreetPlace {
|
|
|
457
457
|
*/
|
|
458
458
|
export interface UnitSplitter {
|
|
459
459
|
split(street: string, place: StreetPlace): TrailingUnitSplit | null
|
|
460
|
+
/**
|
|
461
|
+
* The unit designator and identifier `street` ends in, in the words of the place's country,
|
|
462
|
+
* whether or not the remainder passes the street test {@linkcode UnitSplitter.split} applies.
|
|
463
|
+
*
|
|
464
|
+
* @returns `null` when the street ends in no unit the country's vocabulary writes.
|
|
465
|
+
*/
|
|
466
|
+
trailingUnit(street: string, place: StreetPlace): { street: string; unit: string } | null
|
|
460
467
|
}
|
|
461
468
|
|
|
462
469
|
export interface CreateUnitSplitterOptions {
|
|
@@ -503,6 +510,13 @@ export async function createUnitSplitter(options: CreateUnitSplitterOptions = {}
|
|
|
503
510
|
...(place.postcode ? { postcode: place.postcode } : {}),
|
|
504
511
|
})
|
|
505
512
|
},
|
|
513
|
+
trailingUnit(street, place) {
|
|
514
|
+
const vocabulary = vocabularies.get(place.country.toUpperCase())
|
|
515
|
+
|
|
516
|
+
if (!vocabulary || vocabulary.origin === "none") return null
|
|
517
|
+
|
|
518
|
+
return splitLastUnit(street, vocabulary, place.postcode)
|
|
519
|
+
},
|
|
506
520
|
}
|
|
507
521
|
}
|
|
508
522
|
|
|
@@ -52,6 +52,12 @@ import { hashFNV1a } from "@mailwoman/core/coarse-placer/fnv-hash"
|
|
|
52
52
|
import { isPresent } from "@mailwoman/core/objects"
|
|
53
53
|
import type { WhosOnFirstPlacetype } from "@mailwoman/gazetteer/whosonfirst"
|
|
54
54
|
|
|
55
|
+
import {
|
|
56
|
+
dualRolePlaceOf,
|
|
57
|
+
dualRoleRowRule,
|
|
58
|
+
findDualRolePairs,
|
|
59
|
+
readCapitalSeats,
|
|
60
|
+
} from "#adapters/wof/admin/json/dual-role"
|
|
55
61
|
import { regionCodeFor } from "#adapters/wof/admin/json/region-codes"
|
|
56
62
|
import {
|
|
57
63
|
COUNTRY_DISPLAY_NAME,
|
|
@@ -61,11 +67,12 @@ import {
|
|
|
61
67
|
type NameSlot,
|
|
62
68
|
type WOFVariantSpec,
|
|
63
69
|
} from "#adapters/wof/json-rows"
|
|
64
|
-
import { walkFeaturesCached } from "#adapters/wof/record-cache"
|
|
65
70
|
import { RowSampler } from "#adapters/wof/sample"
|
|
71
|
+
import { openStoredRecordEntries } from "#adapters/wof/stored-records"
|
|
66
72
|
import { SourceRegister } from "#registers"
|
|
67
73
|
import { AddressRole, type AdapterOptions, type CanonicalRow, type CorpusAdapter, SurfaceOrigin } from "#types"
|
|
68
|
-
import {
|
|
74
|
+
import { nameValues, preferredName, type AncestorRecords, type WOFRecord } from "#utils"
|
|
75
|
+
import { ancestorRecordsOf } from "#utils/wof-json"
|
|
69
76
|
|
|
70
77
|
/**
|
|
71
78
|
* Map a WOF placetype to a Mailwoman `ComponentTag`, or `undefined` to skip.
|
|
@@ -537,6 +544,15 @@ export function nameSlotsFor(rec: WOFRecord): NameSlot[] {
|
|
|
537
544
|
return slots.map((slot) => (slot.language && !kept.has(slot.language) ? { key: slot.key, value: slot.value } : slot))
|
|
538
545
|
}
|
|
539
546
|
|
|
547
|
+
/**
|
|
548
|
+
* The `wof:country` WOF writes on a record it assigns to no country,
|
|
549
|
+
* such as a disputed area or a record not yet placed.
|
|
550
|
+
*
|
|
551
|
+
* A row takes its country from the record, so such a record's rows are tagged `XX`
|
|
552
|
+
* and write another country's region: `Pecinan, England, United Kingdom`.
|
|
553
|
+
*/
|
|
554
|
+
export const WOF_NO_COUNTRY = "XX"
|
|
555
|
+
|
|
540
556
|
/**
|
|
541
557
|
* Registry id for this adapter.
|
|
542
558
|
*
|
|
@@ -562,36 +578,33 @@ export function createWOFAdminAdapter(): CorpusAdapter {
|
|
|
562
578
|
"Who's On First admin GeoJSON bundles (countries, regions, counties, localities) — multi-name variants per record.",
|
|
563
579
|
|
|
564
580
|
async *rows(opts: AdapterOptions): AsyncIterable<CanonicalRow> {
|
|
565
|
-
//
|
|
566
|
-
//
|
|
567
|
-
//
|
|
568
|
-
//
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
581
|
+
// A record whose placetype maps to no ComponentTag (campus, county-region hybrids on
|
|
582
|
+
// which Mailwoman has no opinion) is neither rendered nor an ancestor.
|
|
583
|
+
// A record WOF assigns to no country names none for its rows, so it is skipped too.
|
|
584
|
+
// A country-filtered run keeps only that country's records, ancestors included.
|
|
585
|
+
using stored = await openStoredRecordEntries(opts, {
|
|
586
|
+
keep: (record) => Boolean(placetypeToTag(record.placetype)) && record.country !== WOF_NO_COUNTRY,
|
|
587
|
+
resolve: (record, lookup) => ancestorRecordsOf(record, lookup, placetypeToTag),
|
|
588
|
+
})
|
|
572
589
|
|
|
573
|
-
|
|
574
|
-
if (opts.signal?.aborted) return
|
|
590
|
+
const sampler = opts.sample ? new RowSampler<CanonicalRow>(opts.sample) : undefined
|
|
575
591
|
|
|
576
|
-
|
|
592
|
+
// A region sharing its city's name yields `<name>, <country>` to the city (#2909).
|
|
593
|
+
// The regions are held and the localities streamed past them.
|
|
594
|
+
const places = (placetype: string) =>
|
|
595
|
+
Iterator.from(stored.scan([placetype])).map(({ record, properties }) => dualRolePlaceOf(record, properties))
|
|
577
596
|
|
|
578
|
-
|
|
579
|
-
byID.set(rec.id, rec)
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
const ancestry = buildAncestorRecordIndex(byID, placetypeToTag)
|
|
583
|
-
const sampler = opts.sample ? new RowSampler<CanonicalRow>(opts.sample) : undefined
|
|
597
|
+
const pairs = findDualRolePairs(places("region"), places("locality"), await readCapitalSeats())
|
|
584
598
|
|
|
585
|
-
// Pass 2: emit rows in sorted-id order for deterministic jsonl.
|
|
586
599
|
yield* emitWOFJSONRows({
|
|
587
|
-
records:
|
|
588
|
-
ancestry,
|
|
600
|
+
records: stored.entries,
|
|
589
601
|
adapterOptions: opts,
|
|
590
602
|
adapterID: WOF_ADMIN_ADAPTER_ID,
|
|
591
603
|
localeByCountry: LOCALE_BY_COUNTRY,
|
|
592
604
|
nameSlotsFor,
|
|
593
605
|
variantsFor,
|
|
594
606
|
sampler,
|
|
607
|
+
rowRule: dualRoleRowRule(WOF_ADMIN_ADAPTER_ID, pairs),
|
|
595
608
|
})
|
|
596
609
|
|
|
597
610
|
await sampler?.writeOutputs()
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file The `wof-admin` rule for a region that shares its name with the city inside it (Berlin, Zürich, Madrid).
|
|
6
|
+
*
|
|
7
|
+
* In the two-part form `<name>, <country>`, the shared name reads as the city: `Berlin, Germany` is the city. The
|
|
8
|
+
* adapter therefore leaves out the region's `<region>, <country>` rows and keeps the city's `<locality>, <country>`
|
|
9
|
+
* row whatever the sample would keep (#2909).
|
|
10
|
+
*
|
|
11
|
+
* A region qualifies when it holds a same-name locality near its centroid, and that locality is a seat in the
|
|
12
|
+
* capitals reference for the country or the most populous locality inside the region. The pair test is the one the
|
|
13
|
+
* gazetteer's coincident-roles relation used, with the names compared without case or diacritics: the canton
|
|
14
|
+
* `Zurich` holds the city `Zürich`. The locality descends from the region, and the centroids lie within 15% of the
|
|
15
|
+
* region's bounding-box diagonal, or within 12 km.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { foldToken } from "@mailwoman/codex/normalize"
|
|
19
|
+
import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
|
|
20
|
+
import { repoRootPath } from "@mailwoman/core/paths"
|
|
21
|
+
import { haversine } from "@mailwoman/spatial/geometries/point/distance"
|
|
22
|
+
import type { PathBuilderLike } from "path-ts"
|
|
23
|
+
|
|
24
|
+
import type { WOFRowRule } from "#adapters/wof/json-rows"
|
|
25
|
+
import type { CanonicalRow } from "#types"
|
|
26
|
+
import type { WOFRecord } from "#utils"
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The share of a region's bounding-box diagonal its same-name locality's centroid may lie from the region's.
|
|
30
|
+
*/
|
|
31
|
+
const TOLERANCE_FRACTION = 0.15
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The distance a pair is always admitted within, so a small city-state (Bremen, 9.3 km apart) still pairs.
|
|
35
|
+
*/
|
|
36
|
+
const MIN_TOLERANCE_KM = 12
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The number of values in a 2D bounding box: `[west, south, east, north]`.
|
|
40
|
+
*/
|
|
41
|
+
const BBOX_2D_LENGTH = 4
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The key two spellings of one place name share: diacritics and case removed, ends trimmed.
|
|
45
|
+
*/
|
|
46
|
+
function dualRoleKey(name: string): string {
|
|
47
|
+
return foldToken(name).trim()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* One region or locality as the rule reads it.
|
|
52
|
+
*/
|
|
53
|
+
export interface DualRolePlace {
|
|
54
|
+
id: number
|
|
55
|
+
name: string
|
|
56
|
+
placetype: string
|
|
57
|
+
country: string
|
|
58
|
+
/**
|
|
59
|
+
* Ancestor ids, nearest first.
|
|
60
|
+
*/
|
|
61
|
+
ancestors: readonly number[]
|
|
62
|
+
latitude: number
|
|
63
|
+
longitude: number
|
|
64
|
+
/**
|
|
65
|
+
* `[west, south, east, north]`, or `null` when the record states none.
|
|
66
|
+
*/
|
|
67
|
+
bbox: readonly [number, number, number, number] | null
|
|
68
|
+
population: number
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The rule's view of a stored record: its label point, else its geometry point, else `0, 0`;
|
|
73
|
+
* its `geom:bbox`; and `wof:population`, else `gn:population`, else 0.
|
|
74
|
+
*
|
|
75
|
+
* The gazetteer's admin build reads a record's point and population the same way.
|
|
76
|
+
*/
|
|
77
|
+
export function dualRolePlaceOf(record: WOFRecord, properties: Record<string, unknown>): DualRolePlace {
|
|
78
|
+
const number = (key: string): number | null => {
|
|
79
|
+
const value = properties[key]
|
|
80
|
+
|
|
81
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const lbl = [number("lbl:latitude"), number("lbl:longitude")] as const
|
|
85
|
+
const geom = [number("geom:latitude"), number("geom:longitude")] as const
|
|
86
|
+
const point = lbl.every((n) => n != null) ? lbl : geom.every((n) => n != null) ? geom : [0, 0]
|
|
87
|
+
const bboxText = properties["geom:bbox"]
|
|
88
|
+
const bboxParts = typeof bboxText === "string" ? bboxText.split(",").map(Number) : []
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
id: record.id,
|
|
92
|
+
name: record.name,
|
|
93
|
+
placetype: record.placetype,
|
|
94
|
+
country: record.country,
|
|
95
|
+
ancestors: record.parent_id != null ? [...record.ancestors, record.parent_id] : record.ancestors,
|
|
96
|
+
latitude: point[0]!,
|
|
97
|
+
longitude: point[1]!,
|
|
98
|
+
bbox:
|
|
99
|
+
bboxParts.length === BBOX_2D_LENGTH && bboxParts.every((n) => Number.isFinite(n))
|
|
100
|
+
? (bboxParts as [number, number, number, number])
|
|
101
|
+
: null,
|
|
102
|
+
population: number("wof:population") ?? number("gn:population") ?? 0,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Why a region's locality qualifies.
|
|
108
|
+
*/
|
|
109
|
+
export const DualRoleBasis = { seat: "seat", largest: "largest" } as const
|
|
110
|
+
|
|
111
|
+
export type DualRoleBasis = (typeof DualRoleBasis)[keyof typeof DualRoleBasis]
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A region and the same-name locality whose name it yields.
|
|
115
|
+
*/
|
|
116
|
+
export interface DualRolePair {
|
|
117
|
+
regionID: number
|
|
118
|
+
localityID: number
|
|
119
|
+
country: string
|
|
120
|
+
name: string
|
|
121
|
+
basis: DualRoleBasis
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The seats of the capitals reference, as `<country>|<folded name>` for each
|
|
126
|
+
* entry's name and each of its keys.
|
|
127
|
+
*/
|
|
128
|
+
export type CapitalSeats = ReadonlySet<string>
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The capitals reference `mailwoman gazetteer capitals` writes, from GeoNames'
|
|
132
|
+
* national capitals and admin-1 seats.
|
|
133
|
+
*/
|
|
134
|
+
export function capitalsReferencePath(): string {
|
|
135
|
+
return repoRootPath("data", "gazetteer", "capitals-v1.json")
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The seats {@linkcode capitalsReferencePath} lists.
|
|
140
|
+
*
|
|
141
|
+
* @throws When the file isn't a version 1 reference with entries, because an empty seat
|
|
142
|
+
* set would qualify only the largest localities and look like a valid result.
|
|
143
|
+
*/
|
|
144
|
+
export async function readCapitalSeats(path: PathBuilderLike = capitalsReferencePath()): Promise<CapitalSeats> {
|
|
145
|
+
const parsed = await readLocalJSONFile<{
|
|
146
|
+
version?: number
|
|
147
|
+
entries?: Array<{ name?: string; country?: string; k?: string[] }>
|
|
148
|
+
}>(path)
|
|
149
|
+
|
|
150
|
+
if (parsed.version !== 1 || !Array.isArray(parsed.entries) || !parsed.entries.length) {
|
|
151
|
+
throw new Error(`${path.toString()} is not a version 1 capitals reference with entries.`)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const seats = new Set<string>()
|
|
155
|
+
|
|
156
|
+
for (const entry of parsed.entries) {
|
|
157
|
+
if (!entry.country) continue
|
|
158
|
+
|
|
159
|
+
for (const name of [entry.name, ...(entry.k ?? [])]) {
|
|
160
|
+
if (name) {
|
|
161
|
+
seats.add(`${entry.country.toUpperCase()}|${dualRoleKey(name)}`)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return seats
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The qualifying pairs of `regions` and `localities`, which must hold every region
|
|
171
|
+
* and locality the rule may pair.
|
|
172
|
+
*
|
|
173
|
+
* The regions are held, and the localities are read once, as they stream past.
|
|
174
|
+
*
|
|
175
|
+
* A region's largest locality is the one with the highest population that descends
|
|
176
|
+
* from it, the lower id first on a tie.
|
|
177
|
+
* A region whose localities state no population has no largest locality, so only a seat qualifies it.
|
|
178
|
+
*/
|
|
179
|
+
export function findDualRolePairs(
|
|
180
|
+
regionPlaces: Iterable<DualRolePlace>,
|
|
181
|
+
localities: Iterable<DualRolePlace>,
|
|
182
|
+
seats: CapitalSeats
|
|
183
|
+
): DualRolePair[] {
|
|
184
|
+
const regions = new Map<number, DualRolePlace>()
|
|
185
|
+
|
|
186
|
+
for (const region of regionPlaces) {
|
|
187
|
+
regions.set(region.id, region)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const largest = new Map<number, DualRolePlace>()
|
|
191
|
+
const candidates: Array<{ region: DualRolePlace; locality: DualRolePlace }> = []
|
|
192
|
+
|
|
193
|
+
for (const locality of localities) {
|
|
194
|
+
for (const regionID of new Set(locality.ancestors)) {
|
|
195
|
+
const region = regions.get(regionID)
|
|
196
|
+
|
|
197
|
+
if (!region) continue
|
|
198
|
+
|
|
199
|
+
const held = largest.get(regionID)
|
|
200
|
+
|
|
201
|
+
if (
|
|
202
|
+
locality.population > 0 &&
|
|
203
|
+
(!held ||
|
|
204
|
+
locality.population > held.population ||
|
|
205
|
+
(locality.population === held.population && locality.id < held.id))
|
|
206
|
+
) {
|
|
207
|
+
largest.set(regionID, locality)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (dualRoleKey(locality.name) === dualRoleKey(region.name) && isCoincident(region, locality)) {
|
|
211
|
+
candidates.push({ region, locality })
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const pairs: DualRolePair[] = []
|
|
217
|
+
|
|
218
|
+
for (const { region, locality } of candidates) {
|
|
219
|
+
const basis = seats.has(`${locality.country}|${dualRoleKey(locality.name)}`)
|
|
220
|
+
? DualRoleBasis.seat
|
|
221
|
+
: largest.get(region.id)?.id === locality.id
|
|
222
|
+
? DualRoleBasis.largest
|
|
223
|
+
: null
|
|
224
|
+
|
|
225
|
+
if (basis) {
|
|
226
|
+
pairs.push({ regionID: region.id, localityID: locality.id, country: region.country, name: region.name, basis })
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return pairs.toSorted((a, b) => a.regionID - b.regionID || a.localityID - b.localityID)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Whether a locality's centroid lies within the region's tolerance of the region's centroid.
|
|
235
|
+
*/
|
|
236
|
+
function isCoincident(region: DualRolePlace, locality: DualRolePlace): boolean {
|
|
237
|
+
const distance = haversine(region.latitude, region.longitude, locality.latitude, locality.longitude)
|
|
238
|
+
|
|
239
|
+
const [west, south, east, north] = region.bbox ?? [
|
|
240
|
+
region.longitude,
|
|
241
|
+
region.latitude,
|
|
242
|
+
region.longitude,
|
|
243
|
+
region.latitude,
|
|
244
|
+
]
|
|
245
|
+
|
|
246
|
+
const diagonal = haversine(south, west, north, east)
|
|
247
|
+
|
|
248
|
+
return distance <= Math.max(TOLERANCE_FRACTION * diagonal, MIN_TOLERANCE_KM)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The row rule for `pairs`: a `<region>, <country>` row whose region folds to a paired
|
|
253
|
+
* region's name in the row's country is left out, whichever record or name slot wrote it,
|
|
254
|
+
* and each paired locality's canonical `<locality>, <country>` row is required.
|
|
255
|
+
*/
|
|
256
|
+
export function dualRoleRowRule(adapterID: string, pairs: readonly DualRolePair[]): WOFRowRule {
|
|
257
|
+
const regionNames = new Set(pairs.map((pair) => `${pair.country}|${dualRoleKey(pair.name)}`))
|
|
258
|
+
const required = new Set(pairs.map((pair) => `${adapterID}-${pair.localityID}-default-with-country`))
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
drops: (row: CanonicalRow) => {
|
|
262
|
+
const tags = Object.keys(row.components)
|
|
263
|
+
const region = row.components.region
|
|
264
|
+
|
|
265
|
+
return (
|
|
266
|
+
tags.length === 2 &&
|
|
267
|
+
typeof region === "string" &&
|
|
268
|
+
typeof row.components.country === "string" &&
|
|
269
|
+
regionNames.has(`${row.country}|${dualRoleKey(region)}`)
|
|
270
|
+
)
|
|
271
|
+
},
|
|
272
|
+
requires: (row: CanonicalRow) => required.has(row.source_id),
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -27,7 +27,8 @@ import {
|
|
|
27
27
|
import { emitWOFJSONRows, LOCALE_BY_COUNTRY, type NameSlot } from "#adapters/wof/json-rows"
|
|
28
28
|
import { AUGMENTATIONS } from "#synthesizers/utils"
|
|
29
29
|
import type { CanonicalRow } from "#types"
|
|
30
|
-
import {
|
|
30
|
+
import { readFeatureRecord, type WOFRecord } from "#utils"
|
|
31
|
+
import { ancestorRecordsOf } from "#utils/wof-json"
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* The deepest `wof:parent_id` chain read, a guard against a corrupt cycle.
|
|
@@ -208,7 +209,7 @@ export async function exploreWOFRecord(id: number, options: ExploreOptions = {})
|
|
|
208
209
|
parent = next ? next.parent_id : null
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
const
|
|
212
|
+
const recordAncestors = ancestorRecordsOf(record, (ancestorID) => byID.get(ancestorID), adapterTag)
|
|
212
213
|
|
|
213
214
|
const slots = new Map<string, ExploredSlot>()
|
|
214
215
|
|
|
@@ -220,8 +221,7 @@ export async function exploreWOFRecord(id: number, options: ExploreOptions = {})
|
|
|
220
221
|
const byLongestKey = [...slots.keys()].toSorted((a, b) => b.length - a.length)
|
|
221
222
|
|
|
222
223
|
for (const row of emitWOFJSONRows({
|
|
223
|
-
records:
|
|
224
|
-
ancestry,
|
|
224
|
+
records: [{ record, ancestors: recordAncestors }],
|
|
225
225
|
adapterOptions: { inputPath: path },
|
|
226
226
|
adapterID: WOF_ADMIN_ADAPTER_ID,
|
|
227
227
|
localeByCountry: LOCALE_BY_COUNTRY,
|