@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
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { readLocalTextFileSync } from "@mailwoman/core/fs/readers"
|
|
19
19
|
import { isFileSync } from "@mailwoman/core/fs/readers/stat"
|
|
20
20
|
import { tryParsingJSON } from "@mailwoman/core/json"
|
|
21
|
+
import { isPresent } from "@mailwoman/core/objects"
|
|
21
22
|
import { sslAddressSpecsPath } from "@mailwoman/dictionaries/paths"
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -27,9 +28,28 @@ interface SubdivisionSpec {
|
|
|
27
28
|
sub_keys?: string
|
|
28
29
|
sub_names?: string
|
|
29
30
|
sub_lnames?: string
|
|
31
|
+
sub_isoids?: string
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
const CODES_BY_COUNTRY = new Map<string, ReadonlyMap<string, string>>()
|
|
35
|
+
const SPECS_BY_COUNTRY = new Map<string, SubdivisionSpec | null>()
|
|
36
|
+
const WRITTEN_CODES_BY_COUNTRY = new Map<string, ReadonlyMap<string, string>>()
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Reads one country's libaddressinput spec, once per country, or `null` when none is vendored.
|
|
40
|
+
*
|
|
41
|
+
* `variantsFor` runs synchronously inside the row generator, so the spec is read synchronously.
|
|
42
|
+
*/
|
|
43
|
+
function specFor(country: string): SubdivisionSpec | null {
|
|
44
|
+
if (SPECS_BY_COUNTRY.has(country)) return SPECS_BY_COUNTRY.get(country) ?? null
|
|
45
|
+
|
|
46
|
+
const path = sslAddressSpecsPath()(`${country}.json`)
|
|
47
|
+
const spec = isFileSync(path) ? tryParsingJSON<SubdivisionSpec>(readLocalTextFileSync(path)) : null
|
|
48
|
+
|
|
49
|
+
SPECS_BY_COUNTRY.set(country, spec)
|
|
50
|
+
|
|
51
|
+
return spec
|
|
52
|
+
}
|
|
33
53
|
|
|
34
54
|
/**
|
|
35
55
|
* Reads one country's name-to-code map, or an empty map when the country writes no codes.
|
|
@@ -40,9 +60,7 @@ function codesFor(country: string): ReadonlyMap<string, string> {
|
|
|
40
60
|
if (cached) return cached
|
|
41
61
|
|
|
42
62
|
const codes = new Map<string, string>()
|
|
43
|
-
const
|
|
44
|
-
// `variantsFor` runs synchronously inside the row generator, so the spec is read synchronously, once per country.
|
|
45
|
-
const spec = isFileSync(path) ? tryParsingJSON<SubdivisionSpec>(readLocalTextFileSync(path)) : null
|
|
63
|
+
const spec = specFor(country)
|
|
46
64
|
const keys = spec?.sub_keys?.split("~") ?? []
|
|
47
65
|
|
|
48
66
|
for (const names of [spec?.sub_names, spec?.sub_lnames]) {
|
|
@@ -71,6 +89,59 @@ export function regionCodeFor(country: string, regionName: string): string | nul
|
|
|
71
89
|
return codesFor(country.toUpperCase()).get(regionName.toLowerCase()) ?? null
|
|
72
90
|
}
|
|
73
91
|
|
|
92
|
+
/**
|
|
93
|
+
* The ISO 3166-2 code `region` stands for in `country`, when the country's
|
|
94
|
+
* addresses write that code: the subdivision's libaddressinput key is its ISO code,
|
|
95
|
+
* and the region is written as the key or as one of the subdivision's names.
|
|
96
|
+
*
|
|
97
|
+
* United States `TX` and `Texas` both return `TX`.
|
|
98
|
+
* The United Arab Emirates keys Abu Dhabi by its Arabic name, `أبو ظبي`, beside ISO code `AZ`,
|
|
99
|
+
* so its addresses write the name and the region returns `null`.
|
|
100
|
+
* The comparison ignores case.
|
|
101
|
+
*/
|
|
102
|
+
export function writtenSubdivisionCode(country: string, region: string): string | null {
|
|
103
|
+
const code = country.toUpperCase()
|
|
104
|
+
const written = WRITTEN_CODES_BY_COUNTRY.get(code) ?? writtenCodesFor(code)
|
|
105
|
+
|
|
106
|
+
return written.get(region.toLowerCase()) ?? null
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Reads one country's map from each lower-cased form of a code-keyed subdivision
|
|
111
|
+
* to its code, once per country.
|
|
112
|
+
*/
|
|
113
|
+
function writtenCodesFor(country: string): ReadonlyMap<string, string> {
|
|
114
|
+
const written = new Map<string, string>()
|
|
115
|
+
const spec = specFor(country)
|
|
116
|
+
const keys = spec?.sub_keys?.split("~") ?? []
|
|
117
|
+
const isoIDs = spec?.sub_isoids?.split("~") ?? []
|
|
118
|
+
const nameLists = [spec?.sub_names, spec?.sub_lnames].map((names) => names?.split("~") ?? [])
|
|
119
|
+
|
|
120
|
+
for (const [i, key] of keys.entries()) {
|
|
121
|
+
if (isoIDs.length !== keys.length || isoIDs[i]!.toLowerCase() !== key.toLowerCase()) continue
|
|
122
|
+
|
|
123
|
+
for (const form of [key, ...nameLists.flatMap((list) => (list.length === keys.length ? [list[i]!] : []))]) {
|
|
124
|
+
if (!written.has(form.toLowerCase())) {
|
|
125
|
+
written.set(form.toLowerCase(), key)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
WRITTEN_CODES_BY_COUNTRY.set(country, written)
|
|
131
|
+
|
|
132
|
+
return written
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Every key and name libaddressinput lists for `country`'s subdivisions
|
|
137
|
+
* (`TX`, `Texas`; `AE`, `Armed Forces (AE)`; `TO`, `Torino`), or none when it lists no subdivisions.
|
|
138
|
+
*/
|
|
139
|
+
export function subdivisionWrittenForms(country: string): string[] {
|
|
140
|
+
const spec = specFor(country.toUpperCase())
|
|
141
|
+
|
|
142
|
+
return [spec?.sub_keys, spec?.sub_names, spec?.sub_lnames].flatMap((list) => list?.split("~") ?? []).filter(isPresent)
|
|
143
|
+
}
|
|
144
|
+
|
|
74
145
|
/**
|
|
75
146
|
* The name of the region `country`'s addresses write as `regionCode`, in lower case as the
|
|
76
147
|
* spec table holds it, title-cased word by word, or `null` when they write no such code.
|
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
} from "@mailwoman/codex/address/layouts"
|
|
15
15
|
import type { ComponentTag } from "@mailwoman/codex/component"
|
|
16
16
|
import { isPresent } from "@mailwoman/core/objects"
|
|
17
|
-
import {
|
|
18
|
-
import type { ScriptCode } from "@mailwoman/query-shape/types"
|
|
17
|
+
import { textScript } from "@mailwoman/recognizer/script-run"
|
|
19
18
|
|
|
20
19
|
import type { RowSampler, SampledRow } from "#adapters/wof/sample"
|
|
21
20
|
import type { AdapterOptions, CanonicalRow } from "#types"
|
|
@@ -92,7 +91,7 @@ const ADMIN_RUN_TAGS: ReadonlySet<ComponentTag> = new Set(["dependent_locality",
|
|
|
92
91
|
/**
|
|
93
92
|
* Scripts whose addresses join their units without a separator or with a single space.
|
|
94
93
|
*/
|
|
95
|
-
const CJK_SCRIPTS: ReadonlySet<
|
|
94
|
+
const CJK_SCRIPTS: ReadonlySet<string> = new Set(["Hani", "Hira", "Kana", "Hang"])
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
97
|
* Chooses the join script for a hierarchy from the names being joined.
|
|
@@ -104,7 +103,7 @@ const CJK_SCRIPTS: ReadonlySet<ScriptCode> = new Set(["Hani", "Hira", "Kana", "H
|
|
|
104
103
|
*/
|
|
105
104
|
function hierarchyScript(parts: readonly string[]): AddressScript {
|
|
106
105
|
const allCJK = parts.every((part) => {
|
|
107
|
-
const script =
|
|
106
|
+
const script = textScript(part)
|
|
108
107
|
|
|
109
108
|
return script === "Zyyy" || CJK_SCRIPTS.has(script)
|
|
110
109
|
})
|
|
@@ -246,15 +245,19 @@ export function nameSlotsFor(rec: WOFRecord, options: NameSlotOptions = {}): Nam
|
|
|
246
245
|
return slots
|
|
247
246
|
}
|
|
248
247
|
|
|
248
|
+
/**
|
|
249
|
+
* One record and the ancestors its variants read: names for `wof-postalcode`, records for `wof-admin`.
|
|
250
|
+
*/
|
|
251
|
+
export interface WOFRecordEntry<A extends object> {
|
|
252
|
+
record: WOFRecord
|
|
253
|
+
ancestors: A
|
|
254
|
+
}
|
|
255
|
+
|
|
249
256
|
interface EmitWOFJSONRowsOptions<A extends object> {
|
|
250
|
-
records: ReadonlyMap<number, WOFRecord>
|
|
251
257
|
/**
|
|
252
|
-
* The
|
|
253
|
-
*
|
|
254
|
-
* A record absent from the map resolves to an empty object.
|
|
255
|
-
* Records with no resolvable ancestor produce the same value.
|
|
258
|
+
* The records to render, in ascending WOF-id order.
|
|
256
259
|
*/
|
|
257
|
-
|
|
260
|
+
records: Iterable<WOFRecordEntry<A>>
|
|
258
261
|
adapterOptions: AdapterOptions
|
|
259
262
|
adapterID: string
|
|
260
263
|
localeByCountry: Readonly<Record<string, string>>
|
|
@@ -268,15 +271,27 @@ interface EmitWOFJSONRowsOptions<A extends object> {
|
|
|
268
271
|
* The caller reads its cell counts afterwards.
|
|
269
272
|
*/
|
|
270
273
|
sampler?: RowSampler<CanonicalRow>
|
|
274
|
+
/**
|
|
275
|
+
* Rows the adapter refuses or requires whatever the sample keeps.
|
|
276
|
+
*/
|
|
277
|
+
rowRule?: WOFRowRule
|
|
271
278
|
}
|
|
272
279
|
|
|
273
280
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* Frozen and shared, because the emitter reaches it once per such record
|
|
277
|
-
* and constructing a fresh object per row would allocate one per name slot.
|
|
281
|
+
* An adapter's decision about single rendered rows, applied on top of the sample.
|
|
278
282
|
*/
|
|
279
|
-
|
|
283
|
+
export interface WOFRowRule {
|
|
284
|
+
/**
|
|
285
|
+
* Whether the row is left out of the output.
|
|
286
|
+
*
|
|
287
|
+
* A sampled run still observes the row, so leaving it out moves no other row's keep decision.
|
|
288
|
+
*/
|
|
289
|
+
drops: (row: CanonicalRow) => boolean
|
|
290
|
+
/**
|
|
291
|
+
* Whether a sampled run keeps the row whatever its hash.
|
|
292
|
+
*/
|
|
293
|
+
requires: (row: CanonicalRow) => boolean
|
|
294
|
+
}
|
|
280
295
|
|
|
281
296
|
/**
|
|
282
297
|
* Emit aligned rows in WOF-id order, enforcing the adapter limit across all name and hierarchy variants.
|
|
@@ -286,13 +301,13 @@ const NO_ANCESTORS = Object.freeze({})
|
|
|
286
301
|
* while the row keeps the record's own country.
|
|
287
302
|
*/
|
|
288
303
|
export function* emitWOFJSONRows<A extends object>(options: EmitWOFJSONRowsOptions<A>): Generator<CanonicalRow> {
|
|
289
|
-
const { adapterOptions, sampler } = options
|
|
304
|
+
const { adapterOptions, sampler, rowRule } = options
|
|
290
305
|
const limit = adapterOptions.limit
|
|
291
306
|
let emitted = 0
|
|
292
307
|
|
|
293
308
|
if (sampler) {
|
|
294
309
|
for (const { row, slotKey } of renderWOFRows(options)) {
|
|
295
|
-
sampler.observe(sampledRow(row, slotKey), row)
|
|
310
|
+
sampler.observe(sampledRow(row, slotKey), row, rowRule?.requires(row) ?? false)
|
|
296
311
|
}
|
|
297
312
|
}
|
|
298
313
|
|
|
@@ -307,6 +322,8 @@ export function* emitWOFJSONRows<A extends object>(options: EmitWOFJSONRowsOptio
|
|
|
307
322
|
for (const row of rows) {
|
|
308
323
|
if (typeof limit === "number" && emitted >= limit) return
|
|
309
324
|
|
|
325
|
+
if (rowRule?.drops(row)) continue
|
|
326
|
+
|
|
310
327
|
yield row
|
|
311
328
|
|
|
312
329
|
emitted++
|
|
@@ -325,7 +342,6 @@ function* renderWOFRows<A extends object>(
|
|
|
325
342
|
): Generator<{ row: CanonicalRow; slotKey: string }> {
|
|
326
343
|
const {
|
|
327
344
|
records,
|
|
328
|
-
ancestry,
|
|
329
345
|
adapterOptions,
|
|
330
346
|
adapterID,
|
|
331
347
|
localeByCountry,
|
|
@@ -334,14 +350,13 @@ function* renderWOFRows<A extends object>(
|
|
|
334
350
|
variantsFor,
|
|
335
351
|
} = options
|
|
336
352
|
|
|
337
|
-
for (const
|
|
353
|
+
for (const { record, ancestors } of records) {
|
|
338
354
|
if (adapterOptions.signal?.aborted) return
|
|
339
|
-
const record = records.get(id)!
|
|
340
355
|
|
|
341
356
|
if (!shouldEmit(record)) continue
|
|
342
357
|
|
|
343
358
|
for (const slot of slotsForRecord(record)) {
|
|
344
|
-
for (const variant of variantsFor(record,
|
|
359
|
+
for (const variant of variantsFor(record, ancestors, slot)) {
|
|
345
360
|
const rendered = variant.hierarchy
|
|
346
361
|
? renderHierarchy(variant.components, variant.layoutCountry ?? record.country)
|
|
347
362
|
: formatAddressRow(variant.components, record.country, { singleLine: true })
|
|
@@ -30,12 +30,13 @@ import {
|
|
|
30
30
|
type NameSlot,
|
|
31
31
|
type WOFVariantSpec,
|
|
32
32
|
} from "#adapters/wof/json-rows"
|
|
33
|
-
import { walkFeaturesCached } from "#adapters/wof/record-cache"
|
|
34
33
|
import { RowSampler } from "#adapters/wof/sample"
|
|
34
|
+
import { openStoredRecordEntries } from "#adapters/wof/stored-records"
|
|
35
35
|
import { SourceRegister } from "#registers"
|
|
36
36
|
import { AddressRole, type AdapterOptions, type CanonicalRow, type CorpusAdapter, SurfaceOrigin } from "#types"
|
|
37
37
|
import { US_STATE_BY_ABBREVIATION } from "#us/fips-state"
|
|
38
|
-
import {
|
|
38
|
+
import type { AncestorNames, WOFRecord } from "#utils"
|
|
39
|
+
import { ancestorNamesOf, ancestorRecordsOf } from "#utils/wof-json"
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Maps a lowercase US state name to its USPS code.
|
|
@@ -162,39 +163,20 @@ export function createWOFPostalcodeAdapter(): CorpusAdapter {
|
|
|
162
163
|
"Who's On First postalcode GeoJSON bundles (postcode → locality/region pairs). Ancestor names from sibling admin repos.",
|
|
163
164
|
|
|
164
165
|
async *rows(opts: AdapterOptions): AsyncIterable<CanonicalRow> {
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (opts.country && rec.country !== opts.country) continue
|
|
172
|
-
|
|
173
|
-
if (!postcodePlacetypeToTag(rec.placetype)) continue
|
|
174
|
-
byID.set(rec.id, rec)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const ancestry = buildAncestorNameIndex(byID, postcodePlacetypeToTag)
|
|
178
|
-
|
|
179
|
-
// The adapter read admin records so postcode ancestry resolves.
|
|
180
|
-
// The index above now holds the three ancestor names read by each postcode variant.
|
|
181
|
-
// Their removal here releases every admin record's `nameVariants` map before the emit pass.
|
|
182
|
-
// `shouldEmit` skipped those records anyway.
|
|
183
|
-
for (const [id, record] of byID) {
|
|
184
|
-
if (postcodePlacetypeToTag(record.placetype) !== "postcode") {
|
|
185
|
-
byID.delete(id)
|
|
186
|
-
}
|
|
187
|
-
}
|
|
166
|
+
// Admin records are kept so a postcode's ancestry resolves, and only postcodes are rendered.
|
|
167
|
+
using stored = await openStoredRecordEntries(opts, {
|
|
168
|
+
keep: (record) => Boolean(postcodePlacetypeToTag(record.placetype)),
|
|
169
|
+
render: (record) => postcodePlacetypeToTag(record.placetype) === "postcode",
|
|
170
|
+
resolve: (record, lookup) => ancestorNamesOf(ancestorRecordsOf(record, lookup, postcodePlacetypeToTag)),
|
|
171
|
+
})
|
|
188
172
|
|
|
189
173
|
const sampler = opts.sample ? new RowSampler<CanonicalRow>(opts.sample) : undefined
|
|
190
174
|
|
|
191
175
|
yield* emitWOFJSONRows({
|
|
192
|
-
records:
|
|
193
|
-
ancestry,
|
|
176
|
+
records: stored.entries,
|
|
194
177
|
adapterOptions: opts,
|
|
195
178
|
adapterID: WOF_POSTALCODE_ADAPTER_ID,
|
|
196
179
|
localeByCountry: LOCALE_BY_COUNTRY,
|
|
197
|
-
shouldEmit: (record) => postcodePlacetypeToTag(record.placetype) === "postcode",
|
|
198
180
|
nameSlotsFor,
|
|
199
181
|
variantsFor: postcodeVariantsFor,
|
|
200
182
|
sampler,
|
|
@@ -178,6 +178,10 @@ interface Candidate<T> {
|
|
|
178
178
|
* The `holdOutCells` or `compareCells` entry the row matched.
|
|
179
179
|
*/
|
|
180
180
|
group?: string
|
|
181
|
+
/**
|
|
182
|
+
* Whether the row is kept whatever its hash, because the adapter requires it.
|
|
183
|
+
*/
|
|
184
|
+
required?: boolean
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
/**
|
|
@@ -239,7 +243,14 @@ export class RowSampler<T = SampledRow> {
|
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
|
|
242
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Counts `row` in its cells and holds `payload` while one of its cells may keep it.
|
|
248
|
+
*
|
|
249
|
+
* A `required` row is kept whatever its hash, unless its cell is held out.
|
|
250
|
+
* It still enters its cells' heaps as any other row does, so requiring it
|
|
251
|
+
* moves no other row's keep decision.
|
|
252
|
+
*/
|
|
253
|
+
observe(row: SampledRow, payload: T, required = false): void {
|
|
243
254
|
const keys = this.#keys(row)
|
|
244
255
|
|
|
245
256
|
if (!keys) return
|
|
@@ -283,8 +294,8 @@ export class RowSampler<T = SampledRow> {
|
|
|
283
294
|
lowest(this.#country, row.country, this.#sample.rowsPerCountry),
|
|
284
295
|
].some(Boolean)
|
|
285
296
|
|
|
286
|
-
if (held) {
|
|
287
|
-
this.#candidates.set(row.sourceID, base)
|
|
297
|
+
if (held || required) {
|
|
298
|
+
this.#candidates.set(row.sourceID, required ? { ...base, required } : base)
|
|
288
299
|
}
|
|
289
300
|
|
|
290
301
|
const compareGroup = [structure, order].find((key) => this.#compare.has(key))
|
|
@@ -306,6 +317,7 @@ export class RowSampler<T = SampledRow> {
|
|
|
306
317
|
|
|
307
318
|
#isKept(candidate: Candidate<T>): boolean {
|
|
308
319
|
return (
|
|
320
|
+
candidate.required === true ||
|
|
309
321
|
candidate.hash <= (this.#structure.get(candidate.structure)?.threshold ?? -1) ||
|
|
310
322
|
candidate.hash <= (this.#language.get(candidate.language)?.threshold ?? -1) ||
|
|
311
323
|
candidate.hash <= (this.#country.get(candidate.country)?.threshold ?? -1)
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file Reads the WOF adapters' records from the WOF record store, in WOF-id order, with each record's
|
|
6
|
+
* ancestors resolved by primary-key lookup.
|
|
7
|
+
*
|
|
8
|
+
* The adapters used to hold every record of the input in one map so that any record's ancestors could
|
|
9
|
+
* be found. That map peaked at 14,883 MiB for `wof-admin` and `wof-postalcode` together. A record and its
|
|
10
|
+
* ancestors are now read from the store as they are needed. The ancestors that recur, the counties,
|
|
11
|
+
* regions and countries, stay in a bounded cache.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
refreshWOFRecordStore,
|
|
16
|
+
storedWOFRecord,
|
|
17
|
+
storedWOFRecords,
|
|
18
|
+
wofRecordStorePathFor,
|
|
19
|
+
wofRepositories,
|
|
20
|
+
type WOFRecordStoreDatabase,
|
|
21
|
+
type WOFRepoRefresh,
|
|
22
|
+
} from "@mailwoman/gazetteer/whosonfirst/record-store"
|
|
23
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
24
|
+
|
|
25
|
+
import type { WOFRecordEntry } from "#adapters/wof/json-rows"
|
|
26
|
+
import type { AdapterOptions } from "#types"
|
|
27
|
+
import { readRefutedParentIDs, recordFromFeature, type WOFFeature, type WOFRecord } from "#utils/wof-json"
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The most ancestor records the lookup cache holds before it drops the least recently used.
|
|
31
|
+
*/
|
|
32
|
+
const ANCESTOR_CACHE_LIMIT = 500_000
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Options for {@linkcode openStoredRecordEntries}.
|
|
36
|
+
*/
|
|
37
|
+
export interface StoredRecordEntriesOptions<A extends object> {
|
|
38
|
+
/**
|
|
39
|
+
* Whether a parsed record belongs to the reader's index: a record it renders,
|
|
40
|
+
* or one an ancestor walk may reach.
|
|
41
|
+
*
|
|
42
|
+
* The adapter's `--country` filter applies on top.
|
|
43
|
+
*/
|
|
44
|
+
keep: (record: WOFRecord) => boolean
|
|
45
|
+
/**
|
|
46
|
+
* Whether a kept record is rendered.
|
|
47
|
+
*
|
|
48
|
+
* A record that's only an ancestor, such as an admin record read by `wof-postalcode`,
|
|
49
|
+
* is kept and not rendered.
|
|
50
|
+
*/
|
|
51
|
+
render?: (record: WOFRecord) => boolean
|
|
52
|
+
/**
|
|
53
|
+
* The ancestors a rendered record's variants read, from a lookup that returns kept records only.
|
|
54
|
+
*/
|
|
55
|
+
resolve: (record: WOFRecord, lookup: (id: number) => WOFRecord | undefined) => A
|
|
56
|
+
onRepo?: (refresh: WOFRepoRefresh) => void
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Opened entries over the store, and the handle that closes it.
|
|
61
|
+
*/
|
|
62
|
+
export interface StoredRecordEntries<A extends object> extends Disposable {
|
|
63
|
+
entries: Iterable<WOFRecordEntry<A>>
|
|
64
|
+
/**
|
|
65
|
+
* Every kept record of the given placetypes in ascending WOF-id order, with the stored feature's
|
|
66
|
+
* properties, read in a pass of its own before or after {@linkcode StoredRecordEntries.entries}.
|
|
67
|
+
*
|
|
68
|
+
* The properties hold what a record omits, such as the point, bounding box and population.
|
|
69
|
+
*/
|
|
70
|
+
scan: (placetypes: readonly string[]) => Iterable<{ record: WOFRecord; properties: Record<string, unknown> }>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Refreshes the store for `opts.inputPath`, then returns the rendered records in ascending WOF-id order.
|
|
75
|
+
*
|
|
76
|
+
* A record is kept, rendered and resolved exactly as the in-memory index read it:
|
|
77
|
+
* parsed by {@linkcode recordFromFeature}, filtered by `keep` and the country,
|
|
78
|
+
* with ancestors found among kept records of the same repositories.
|
|
79
|
+
*/
|
|
80
|
+
export async function openStoredRecordEntries<A extends object>(
|
|
81
|
+
opts: AdapterOptions,
|
|
82
|
+
reader: StoredRecordEntriesOptions<A>
|
|
83
|
+
): Promise<StoredRecordEntries<A>> {
|
|
84
|
+
const storePath = wofRecordStorePathFor(opts.inputPath)
|
|
85
|
+
|
|
86
|
+
await refreshWOFRecordStore(storePath, opts.inputPath, { signal: opts.signal, onRepo: reader.onRepo })
|
|
87
|
+
|
|
88
|
+
const repos = (await wofRepositories(opts.inputPath)).map((repo) => repo.basename())
|
|
89
|
+
const inScope = new Set(repos)
|
|
90
|
+
const refuted = await readRefutedParentIDs()
|
|
91
|
+
const db = new DatabaseClient<WOFRecordStoreDatabase>(storePath, { readOnly: true })
|
|
92
|
+
|
|
93
|
+
const parseKept = (feature: WOFFeature): WOFRecord | null => {
|
|
94
|
+
const record = recordFromFeature(feature, refuted)
|
|
95
|
+
|
|
96
|
+
if (!record || !reader.keep(record)) return null
|
|
97
|
+
|
|
98
|
+
if (opts.country && record.country !== opts.country) return null
|
|
99
|
+
|
|
100
|
+
return record
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// A miss is cached as `null`, so an id outside the index is read from the store once.
|
|
104
|
+
const cache = new Map<number, WOFRecord | null>()
|
|
105
|
+
|
|
106
|
+
const lookup = (id: number): WOFRecord | undefined => {
|
|
107
|
+
const cached = cache.get(id)
|
|
108
|
+
|
|
109
|
+
if (cached !== undefined) {
|
|
110
|
+
cache.delete(id)
|
|
111
|
+
cache.set(id, cached)
|
|
112
|
+
|
|
113
|
+
return cached ?? undefined
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const stored = storedWOFRecord<WOFFeature>(db, id)
|
|
117
|
+
const record = stored && inScope.has(stored.repo) ? parseKept(stored.feature) : null
|
|
118
|
+
|
|
119
|
+
cache.set(id, record)
|
|
120
|
+
|
|
121
|
+
if (cache.size > ANCESTOR_CACHE_LIMIT) {
|
|
122
|
+
cache.delete(cache.keys().next().value!)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return record ?? undefined
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function* entries(): Generator<WOFRecordEntry<A>> {
|
|
129
|
+
for (const stored of storedWOFRecords<WOFFeature>(db, {
|
|
130
|
+
repos,
|
|
131
|
+
...(opts.country ? { country: opts.country } : {}),
|
|
132
|
+
})) {
|
|
133
|
+
if (opts.signal?.aborted) return
|
|
134
|
+
const record = parseKept(stored.feature)
|
|
135
|
+
|
|
136
|
+
if (!record || (reader.render && !reader.render(record))) continue
|
|
137
|
+
|
|
138
|
+
yield { record, ancestors: reader.resolve(record, lookup) }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function* scan(placetypes: readonly string[]): Generator<{ record: WOFRecord; properties: Record<string, unknown> }> {
|
|
143
|
+
for (const stored of storedWOFRecords<WOFFeature>(db, {
|
|
144
|
+
repos,
|
|
145
|
+
placetypes: new Set(placetypes),
|
|
146
|
+
...(opts.country ? { country: opts.country } : {}),
|
|
147
|
+
})) {
|
|
148
|
+
if (opts.signal?.aborted) return
|
|
149
|
+
const record = parseKept(stored.feature)
|
|
150
|
+
|
|
151
|
+
if (record) {
|
|
152
|
+
yield { record, properties: stored.feature.properties ?? {} }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
entries: entries(),
|
|
159
|
+
scan,
|
|
160
|
+
[Symbol.dispose]: () => db[Symbol.dispose](),
|
|
161
|
+
}
|
|
162
|
+
}
|
package/lib/adapters.ts
CHANGED
|
@@ -57,6 +57,7 @@ import { overtureAdapter } from "#adapters/overture/adapter"
|
|
|
57
57
|
import { defaultAdapterRegistry } from "#adapters/registry"
|
|
58
58
|
import { wofAdminAdapter } from "#adapters/wof/admin/json/adapter"
|
|
59
59
|
import { wofPostalcodeAdapter } from "#adapters/wof/postalcode-json/adapter"
|
|
60
|
+
import { auACNCRegisterAdapter } from "#au/adapters/acnc-register/adapter"
|
|
60
61
|
import { gnafAdapter } from "#au/adapters/gnaf/adapter"
|
|
61
62
|
import { azerbaijanPlacesAdapter } from "#az/adapters/opendata/adapter"
|
|
62
63
|
import { brusselsAdapter } from "#be/adapters/brussels/adapter"
|
|
@@ -70,20 +71,25 @@ import { esBizkaiaAdapter } from "#es/adapters/bizkaia/adapter"
|
|
|
70
71
|
import { esCatastroAdapter } from "#es/adapters/catastro/adapter"
|
|
71
72
|
import { esGipuzkoaAdapter } from "#es/adapters/gipuzkoa/adapter"
|
|
72
73
|
import { esNavarraAdapter } from "#es/adapters/navarra/adapter"
|
|
74
|
+
import { esSanidadCentrosAPAdapter } from "#es/adapters/sanidad-centros-ap/adapter"
|
|
73
75
|
import { ryhtiAdapter } from "#fi/adapters/ryhti/adapter"
|
|
74
76
|
import { adressurFaroeAdapter } from "#fo/adapters/adressur/adapter"
|
|
75
77
|
import { annuaireEducationAdapter } from "#fr/adapters/annuaire-education/adapter"
|
|
76
78
|
import { banAdapter } from "#fr/adapters/ban/adapter"
|
|
77
79
|
import { finessAdapter } from "#fr/adapters/finess/adapter"
|
|
80
|
+
import { laPostePoincontAdapter } from "#fr/adapters/laposte-poincont/adapter"
|
|
78
81
|
import { gbOSOpenAdapter } from "#gb/adapters/os-open/adapter"
|
|
79
82
|
import { guamAddressPointsAdapter } from "#gu/adapters/bsp/adapter"
|
|
80
83
|
import { isleOfManLandRegistryAdapter } from "#im/adapters/land-registry/adapter"
|
|
81
84
|
import { itANACAdapter } from "#it/adapters/anac/adapter"
|
|
85
|
+
import { itMIURScuoleAdapter } from "#it/adapters/miur-scuole/adapter"
|
|
82
86
|
import { llvLiechtensteinAdapter } from "#li/adapters/llv/adapter"
|
|
83
87
|
import { bdAdressesAdapter } from "#lu/adapters/bd-adresses/adapter"
|
|
84
88
|
import { varisAdapter } from "#lv/adapters/varis/adapter"
|
|
89
|
+
import { optNCAgencesAdapter } from "#nc/adapters/opt-nc/adapter"
|
|
85
90
|
import { nlKadasterAdapter } from "#nl/adapters/kadaster/adapter"
|
|
86
91
|
import { matrikkelenAdapter } from "#no/adapters/matrikkelen/adapter"
|
|
92
|
+
import { nzCharitiesRegisterAdapter } from "#nz/adapters/charities-register/adapter"
|
|
87
93
|
import { emuiaAdapter } from "#pl/adapters/emuia/adapter"
|
|
88
94
|
import { reteaScolaraAdapter } from "#ro/adapters/retea-scolara/adapter"
|
|
89
95
|
import { skInspireAdapter } from "#sk/adapters/inspire/adapter"
|
|
@@ -99,7 +105,7 @@ import { usgovImlsPlsAdapter } from "#us/adapters/usgov/imls-pls/adapter"
|
|
|
99
105
|
import { USGovIRSBMFAdapter } from "#us/adapters/usgov/irs-bmf/adapter"
|
|
100
106
|
import { usgovNADAdapter } from "#us/adapters/usgov/nad/adapter"
|
|
101
107
|
import { usgovNPPESAdapter } from "#us/adapters/usgov/nppes/adapter"
|
|
102
|
-
import {
|
|
108
|
+
import { usgovUSGSStructuresAdapter } from "#us/adapters/usgov/usgs-structures/adapter"
|
|
103
109
|
import { ideUruguayAdapter } from "#uy/adapters/ide/adapter"
|
|
104
110
|
|
|
105
111
|
/**
|
|
@@ -157,7 +163,7 @@ export const BUILTIN_ADAPTERS: readonly CorpusAdapter[] = [
|
|
|
157
163
|
usgovNADAdapter,
|
|
158
164
|
usgovImlsPlsAdapter,
|
|
159
165
|
USGovIRSBMFAdapter,
|
|
160
|
-
|
|
166
|
+
usgovUSGSStructuresAdapter,
|
|
161
167
|
stateIaContractorsAdapter,
|
|
162
168
|
stateTxNotariesAdapter,
|
|
163
169
|
stateNyNotariesAdapter,
|
|
@@ -168,6 +174,12 @@ export const BUILTIN_ADAPTERS: readonly CorpusAdapter[] = [
|
|
|
168
174
|
varisAdapter,
|
|
169
175
|
finessAdapter,
|
|
170
176
|
annuaireEducationAdapter,
|
|
177
|
+
laPostePoincontAdapter,
|
|
178
|
+
optNCAgencesAdapter,
|
|
179
|
+
esSanidadCentrosAPAdapter,
|
|
180
|
+
itMIURScuoleAdapter,
|
|
181
|
+
auACNCRegisterAdapter,
|
|
182
|
+
nzCharitiesRegisterAdapter,
|
|
171
183
|
gleifAdapter,
|
|
172
184
|
]
|
|
173
185
|
|
|
@@ -255,10 +267,10 @@ export {
|
|
|
255
267
|
} from "#us/adapters/usgov/samhsa-treatment-locator/adapter"
|
|
256
268
|
|
|
257
269
|
export {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
} from "#us/adapters/usgov/usgs-
|
|
270
|
+
USGOV_USGS_STRUCTURES_ADAPTER_ID,
|
|
271
|
+
USGOV_USGS_STRUCTURES_DEFAULT_LICENSE,
|
|
272
|
+
usgovUSGSStructuresAdapter,
|
|
273
|
+
} from "#us/adapters/usgov/usgs-structures/adapter"
|
|
262
274
|
|
|
263
275
|
export { WOF_ADMIN_ADAPTER_ID, wofAdminAdapter } from "#adapters/wof/admin/json/adapter"
|
|
264
276
|
export { WOF_POSTALCODE_ADAPTER_ID, wofPostalcodeAdapter } from "#adapters/wof/postalcode-json/adapter"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `au-acnc-register`: the ACNC charity register as a corpus source.
|
|
6
|
+
*
|
|
7
|
+
* The adapter reads `datadotgov_main.csv` through {@linkcode readACNCCharities},
|
|
8
|
+
* the reader the evaluation source of the same id calls, and renders each charity's
|
|
9
|
+
* single street line, town, state and postcode.
|
|
10
|
+
* The charity's name is never read into a row, because a small charity's name can be
|
|
11
|
+
* a person's and its address can be a responsible person's home.
|
|
12
|
+
*
|
|
13
|
+
* A withheld address, a post-office box and a multi-line address yield no row.
|
|
14
|
+
*
|
|
15
|
+
* CC BY 3.0 AU clause 3A grants the right to
|
|
16
|
+
* `create and Reproduce one or more Derivative Works` (`data/licenses/au-acnc-cc-by-3.0-au.md`).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { auACNCRegisterSource, readACNCCharities } from "#au/evaluation/acnc-register"
|
|
20
|
+
import { createEvaluationCorpusAdapter } from "#evaluation/corpus-adapter"
|
|
21
|
+
import { SourceRegister } from "#registers"
|
|
22
|
+
import { AddressRole } from "#types"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Registry id for this adapter, stamped into every row it emits, and the evaluation source's id.
|
|
26
|
+
*/
|
|
27
|
+
export const AU_ACNC_REGISTER_ADAPTER_ID = "au-acnc-register"
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The registered `au-acnc-register` adapter.
|
|
31
|
+
*/
|
|
32
|
+
export const auACNCRegisterAdapter = createEvaluationCorpusAdapter({
|
|
33
|
+
id: AU_ACNC_REGISTER_ADAPTER_ID,
|
|
34
|
+
source: auACNCRegisterSource,
|
|
35
|
+
register: SourceRegister.ACNCRegister,
|
|
36
|
+
locale: "en-AU",
|
|
37
|
+
addressRole: AddressRole.RegisteredOffice,
|
|
38
|
+
description: "ACNC Registered Charities (CC BY 3.0 AU): each charity's single-line street address, without its name.",
|
|
39
|
+
read: readACNCCharities,
|
|
40
|
+
})
|