@mailwoman/corpus 11.1.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -14
- package/data/address-source-register.json +618 -13
- package/data/builds/v0.8.19-overlay/OVERLAY_PLAN.json +4778 -0
- package/data/builds/v0.8.19-rebuild/inputs.json +128 -0
- package/data/builds/v0.8.20-overlay/OVERLAY_PLAN.json +3595 -0
- package/data/builds/v0.8.20-rebuild/inputs.json +131 -0
- package/data/builds/v0.8.21-overlay/OVERLAY_PLAN.json +72 -0
- package/data/corpus-source-inputs.json +104 -2
- package/data/holdout/evaluation-groups.v0.8.18.json +90511 -0
- package/data/holdout/evaluation-groups.v0.8.19.json +100537 -0
- package/data/holdout/evaluation-groups.v0.8.20.json +129215 -0
- package/data/holdout/evaluation-groups.v0.8.21.json +173286 -0
- package/data/holdout/probe-text-collisions.v0.8.20.json +1478 -0
- package/data/license-decisions.json +393 -3
- package/data/licenses/PROVENANCE.md +15 -9
- package/data/licenses/au-acnc-cc-by-3.0-au.md +37 -0
- package/data/licenses/es-sanidad-aviso-legal.md +26 -0
- package/data/licenses/it-miur-iodl-2.0.md +41 -0
- package/data/licenses/nz-charities-cc-by-3.0-nz.md +36 -0
- package/data/region-slot-second-level.json +966 -0
- package/data/source-additions.json +126 -6
- package/data/source-resolutions.json +97 -0
- package/data/training-configs/v8.7.0-base-c6-90k-usgs-structures-s42.yaml +801 -0
- package/data/training-configs/v8.7.0-base-c6-90k-usgs-structures-s43.yaml +726 -0
- package/data/training-configs/v8.8.0-base-c6-90k-v0820-county-s42.yaml +944 -0
- package/data/training-configs/v8.9.0-base-c6-90k-v0821-s42.yaml +848 -0
- package/data/training-manifests/v0.8.19-retention-overlay.json +4553 -0
- package/data/training-manifests/v0.8.20-retention-overlay.json +4579 -0
- package/data/training-manifests/v0.8.21-retention-overlay.effective.json +2521 -0
- package/data/training-manifests/v0.8.21-retention-overlay.json +4579 -0
- package/lib/adapters/cordis/adapter.ts +10 -2
- package/lib/adapters/gleif/adapter.ts +23 -5
- package/lib/adapters/osm/adapter.ts +2 -2
- package/lib/adapters/street/repetition.ts +87 -0
- package/lib/adapters/street/unit.ts +14 -0
- package/lib/adapters/wof/admin/json/adapter.ts +34 -21
- package/lib/adapters/wof/admin/json/dual-role.ts +274 -0
- package/lib/adapters/wof/admin/json/explore.ts +4 -4
- package/lib/adapters/wof/admin/json/region-codes.ts +74 -3
- package/lib/adapters/wof/json-rows.ts +36 -21
- package/lib/adapters/wof/postalcode-json/adapter.ts +10 -28
- package/lib/adapters/wof/sample.ts +15 -3
- package/lib/adapters/wof/stored-records.ts +162 -0
- package/lib/adapters.ts +18 -6
- package/lib/au/adapters/acnc-register/adapter.ts +40 -0
- package/lib/au/evaluation/acnc-register.ts +144 -0
- package/lib/build/align/range.ts +9 -0
- package/lib/build/align/totals.ts +23 -0
- package/lib/build/align.ts +74 -4
- package/lib/build/budget.ts +11 -45
- package/lib/build/checkpoint.ts +11 -0
- package/lib/build/component-check.ts +99 -3
- package/lib/build/manifest.ts +4 -0
- package/lib/build/parallel.ts +8 -34
- package/lib/build/region-names.ts +609 -0
- package/lib/build/source-record.ts +7 -0
- package/lib/build/types.ts +20 -0
- package/lib/build/worker.ts +3 -1
- package/lib/build.ts +3 -6
- package/lib/de/recipes/locale.ts +3 -2
- package/lib/env.ts +0 -6
- package/lib/es/adapters/sanidad-centros-ap/adapter.ts +40 -0
- package/lib/es/evaluation/sanidad-centros-ap.ts +164 -0
- package/lib/evaluation/corpus-adapter.ts +153 -0
- package/lib/evaluation/source.ts +209 -0
- package/lib/evaluation/sources.ts +25 -0
- package/lib/fr/adapters/laposte-poincont/adapter.ts +381 -0
- package/lib/fr/recipes/unit-line-guideline.ts +9 -4
- package/lib/fr/structures/laposte.ts +139 -0
- package/lib/fr/tools/fetch/laposte-poincont.ts +234 -0
- package/lib/it/adapters/miur-scuole/adapter.ts +39 -0
- package/lib/it/evaluation/miur-scuole.ts +125 -0
- package/lib/jp/adapters/wof-admin/adapter.ts +4 -4
- package/lib/nc/adapters/opt-nc/adapter.ts +237 -0
- package/lib/nc/structures/opt-nc.ts +101 -0
- package/lib/nc/tools/fetch/opt-nc.ts +249 -0
- package/lib/nz/adapters/charities-register/adapter.ts +40 -0
- package/lib/nz/evaluation/charities-register.ts +149 -0
- package/lib/recipes/bare/postcode.ts +14 -11
- package/lib/recipes/deepseek/batches.ts +8 -8
- package/lib/recipes/po/box/cedex/recipe.ts +12 -1
- package/lib/recipes/po/box/cedex/us.ts +43 -2
- package/lib/recipes/scaffold.ts +1 -1
- package/lib/recipes/sources.ts +16 -0
- package/lib/recipes.ts +2 -0
- package/lib/registers.ts +28 -2
- package/lib/{post-offices → structures}/source.ts +49 -16
- package/lib/structures/sources.ts +26 -0
- package/lib/synthesizers/house-venue.ts +11 -6
- package/lib/synthesizers/tail.ts +27 -3
- package/lib/tools/audit.ts +1 -1
- package/lib/tools/fetch/storage.ts +18 -4
- package/lib/tools/fetch.ts +10 -2
- package/lib/tools/overlay/kryptonite.ts +6 -2
- package/lib/tools/overlay/split/attribute.ts +14 -2
- package/lib/tools/overlay/split/overlay.ts +36 -7
- package/lib/tools/postcode/triples.ts +3 -3
- package/lib/tools/region-slot-census.run.ts +184 -0
- package/lib/training/config/load.ts +19 -0
- package/lib/training/config/schema.ts +6 -0
- package/lib/tw/registers.ts +15 -4
- package/lib/tw/structures/chunghwa-post.ts +191 -0
- package/lib/tw/tools/fetch/chunghwa-post.ts +174 -0
- package/lib/us/adapters/state/ny-notaries/adapter.ts +7 -2
- package/lib/us/adapters/state/tx-notaries/adapter.ts +126 -21
- package/lib/us/adapters/usgov/nad/adapter.ts +111 -31
- package/lib/us/adapters/usgov/nppes/adapter.ts +8 -11
- package/lib/us/adapters/usgov/{usgs-post-offices → usgs-structures}/adapter.ts +65 -35
- package/lib/us/recipes/county.ts +474 -0
- package/lib/us/street-unit.ts +15 -5
- package/lib/us/structures/usgs/layers.ts +171 -0
- package/lib/us/structures/usgs/national-map.ts +95 -0
- package/lib/us/tools/fetch/usgs/gnis.ts +288 -0
- package/lib/us/tools/fetch/usgs/structures.ts +362 -0
- package/lib/utils/align.ts +2 -2
- package/lib/utils/evaluation-groups.ts +172 -0
- package/lib/utils/split.ts +40 -4
- package/lib/utils/tokenize.ts +7 -7
- package/lib/utils/validation-groups.ts +292 -0
- package/lib/utils/wof-json.ts +96 -134
- package/out/adapters/cordis/adapter.d.ts +3 -1
- package/out/adapters/cordis/adapter.d.ts.map +1 -1
- package/out/adapters/cordis/adapter.js +8 -2
- package/out/adapters/cordis/adapter.js.map +1 -1
- package/out/adapters/gleif/adapter.d.ts.map +1 -1
- package/out/adapters/gleif/adapter.js +19 -5
- package/out/adapters/gleif/adapter.js.map +1 -1
- package/out/adapters/osm/adapter.js +2 -2
- package/out/adapters/osm/adapter.js.map +1 -1
- package/out/adapters/street/repetition.d.ts +19 -0
- package/out/adapters/street/repetition.d.ts.map +1 -0
- package/out/adapters/street/repetition.js +71 -0
- package/out/adapters/street/repetition.js.map +1 -0
- package/out/adapters/street/unit.d.ts +10 -0
- package/out/adapters/street/unit.d.ts.map +1 -1
- package/out/adapters/street/unit.js +6 -0
- package/out/adapters/street/unit.js.map +1 -1
- package/out/adapters/wof/admin/json/adapter.d.ts +8 -0
- package/out/adapters/wof/admin/json/adapter.d.ts.map +1 -1
- package/out/adapters/wof/admin/json/adapter.js +26 -22
- package/out/adapters/wof/admin/json/adapter.js.map +1 -1
- package/out/adapters/wof/admin/json/dual-role.d.ts +83 -0
- package/out/adapters/wof/admin/json/dual-role.d.ts.map +1 -0
- package/out/adapters/wof/admin/json/dual-role.js +183 -0
- package/out/adapters/wof/admin/json/dual-role.js.map +1 -0
- package/out/adapters/wof/admin/json/explore.d.ts.map +1 -1
- package/out/adapters/wof/admin/json/explore.js +4 -4
- package/out/adapters/wof/admin/json/explore.js.map +1 -1
- package/out/adapters/wof/admin/json/region-codes.d.ts +16 -0
- package/out/adapters/wof/admin/json/region-codes.d.ts.map +1 -1
- package/out/adapters/wof/admin/json/region-codes.js +62 -3
- package/out/adapters/wof/admin/json/region-codes.js.map +1 -1
- package/out/adapters/wof/json-rows.d.ts +28 -6
- package/out/adapters/wof/json-rows.d.ts.map +1 -1
- package/out/adapters/wof/json-rows.js +9 -15
- package/out/adapters/wof/json-rows.js.map +1 -1
- package/out/adapters/wof/postalcode-json/adapter.d.ts +1 -1
- package/out/adapters/wof/postalcode-json/adapter.d.ts.map +1 -1
- package/out/adapters/wof/postalcode-json/adapter.js +9 -26
- package/out/adapters/wof/postalcode-json/adapter.js.map +1 -1
- package/out/adapters/wof/sample.d.ts +8 -1
- package/out/adapters/wof/sample.d.ts.map +1 -1
- package/out/adapters/wof/sample.js +12 -4
- package/out/adapters/wof/sample.js.map +1 -1
- package/out/adapters/wof/stored-records.d.ts +62 -0
- package/out/adapters/wof/stored-records.d.ts.map +1 -0
- package/out/adapters/wof/stored-records.js +91 -0
- package/out/adapters/wof/stored-records.js.map +1 -0
- package/out/adapters.d.ts +1 -1
- package/out/adapters.d.ts.map +1 -1
- package/out/adapters.js +15 -3
- package/out/adapters.js.map +1 -1
- package/out/au/adapters/acnc-register/adapter.d.ts +9 -0
- package/out/au/adapters/acnc-register/adapter.d.ts.map +1 -0
- package/out/au/adapters/acnc-register/adapter.js +37 -0
- package/out/au/adapters/acnc-register/adapter.js.map +1 -0
- package/out/au/evaluation/acnc-register.d.ts +56 -0
- package/out/au/evaluation/acnc-register.d.ts.map +1 -0
- package/out/au/evaluation/acnc-register.js +84 -0
- package/out/au/evaluation/acnc-register.js.map +1 -0
- package/out/build/align/range.d.ts.map +1 -1
- package/out/build/align/range.js +9 -0
- package/out/build/align/range.js.map +1 -1
- package/out/build/align/totals.d.ts +5 -0
- package/out/build/align/totals.d.ts.map +1 -1
- package/out/build/align/totals.js +15 -0
- package/out/build/align/totals.js.map +1 -1
- package/out/build/align.d.ts +26 -0
- package/out/build/align.d.ts.map +1 -1
- package/out/build/align.js +35 -2
- package/out/build/align.js.map +1 -1
- package/out/build/budget.d.ts +9 -26
- package/out/build/budget.d.ts.map +1 -1
- package/out/build/budget.js +10 -31
- package/out/build/budget.js.map +1 -1
- package/out/build/checkpoint.d.ts +11 -0
- package/out/build/checkpoint.d.ts.map +1 -1
- package/out/build/checkpoint.js.map +1 -1
- package/out/build/component-check.d.ts +55 -1
- package/out/build/component-check.d.ts.map +1 -1
- package/out/build/component-check.js +65 -3
- package/out/build/component-check.js.map +1 -1
- package/out/build/manifest.d.ts.map +1 -1
- package/out/build/manifest.js +4 -0
- package/out/build/manifest.js.map +1 -1
- package/out/build/parallel.d.ts.map +1 -1
- package/out/build/parallel.js +8 -24
- package/out/build/parallel.js.map +1 -1
- package/out/build/region-names.d.ts +120 -0
- package/out/build/region-names.d.ts.map +1 -0
- package/out/build/region-names.js +430 -0
- package/out/build/region-names.js.map +1 -0
- package/out/build/source-record.d.ts.map +1 -1
- package/out/build/source-record.js +4 -0
- package/out/build/source-record.js.map +1 -1
- package/out/build/types.d.ts +20 -0
- package/out/build/types.d.ts.map +1 -1
- package/out/build/worker.js +3 -1
- package/out/build/worker.js.map +1 -1
- package/out/build.d.ts +0 -1
- package/out/build.d.ts.map +1 -1
- package/out/build.js +3 -5
- package/out/build.js.map +1 -1
- package/out/de/recipes/locale.d.ts.map +1 -1
- package/out/de/recipes/locale.js +3 -2
- package/out/de/recipes/locale.js.map +1 -1
- package/out/env.d.ts +0 -2
- package/out/env.d.ts.map +1 -1
- package/out/env.js +0 -5
- package/out/env.js.map +1 -1
- package/out/es/adapters/sanidad-centros-ap/adapter.d.ts +9 -0
- package/out/es/adapters/sanidad-centros-ap/adapter.d.ts.map +1 -0
- package/out/es/adapters/sanidad-centros-ap/adapter.js +36 -0
- package/out/es/adapters/sanidad-centros-ap/adapter.js.map +1 -0
- package/out/es/evaluation/sanidad-centros-ap.d.ts +34 -0
- package/out/es/evaluation/sanidad-centros-ap.d.ts.map +1 -0
- package/out/es/evaluation/sanidad-centros-ap.js +128 -0
- package/out/es/evaluation/sanidad-centros-ap.js.map +1 -0
- package/out/evaluation/corpus-adapter.d.ts +60 -0
- package/out/evaluation/corpus-adapter.d.ts.map +1 -0
- package/out/evaluation/corpus-adapter.js +100 -0
- package/out/evaluation/corpus-adapter.js.map +1 -0
- package/out/evaluation/source.d.ts +134 -0
- package/out/evaluation/source.d.ts.map +1 -0
- package/out/evaluation/source.js +80 -0
- package/out/evaluation/source.js.map +1 -0
- package/out/evaluation/sources.d.ts +6 -0
- package/out/evaluation/sources.d.ts.map +1 -0
- package/out/evaluation/sources.js +22 -0
- package/out/evaluation/sources.js.map +1 -0
- package/out/fr/adapters/laposte-poincont/adapter.d.ts +110 -0
- package/out/fr/adapters/laposte-poincont/adapter.d.ts.map +1 -0
- package/out/fr/adapters/laposte-poincont/adapter.js +315 -0
- package/out/fr/adapters/laposte-poincont/adapter.js.map +1 -0
- package/out/fr/recipes/unit-line-guideline.d.ts.map +1 -1
- package/out/fr/recipes/unit-line-guideline.js +8 -4
- package/out/fr/recipes/unit-line-guideline.js.map +1 -1
- package/out/fr/structures/laposte.d.ts +27 -0
- package/out/fr/structures/laposte.d.ts.map +1 -0
- package/out/fr/structures/laposte.js +96 -0
- package/out/fr/structures/laposte.js.map +1 -0
- package/out/fr/tools/fetch/laposte-poincont.d.ts +95 -0
- package/out/fr/tools/fetch/laposte-poincont.d.ts.map +1 -0
- package/out/fr/tools/fetch/laposte-poincont.js +135 -0
- package/out/fr/tools/fetch/laposte-poincont.js.map +1 -0
- package/out/it/adapters/miur-scuole/adapter.d.ts +9 -0
- package/out/it/adapters/miur-scuole/adapter.d.ts.map +1 -0
- package/out/it/adapters/miur-scuole/adapter.js +35 -0
- package/out/it/adapters/miur-scuole/adapter.js.map +1 -0
- package/out/it/evaluation/miur-scuole.d.ts +53 -0
- package/out/it/evaluation/miur-scuole.d.ts.map +1 -0
- package/out/it/evaluation/miur-scuole.js +68 -0
- package/out/it/evaluation/miur-scuole.js.map +1 -0
- package/out/jp/adapters/wof-admin/adapter.js +4 -4
- package/out/nc/adapters/opt-nc/adapter.d.ts +84 -0
- package/out/nc/adapters/opt-nc/adapter.d.ts.map +1 -0
- package/out/nc/adapters/opt-nc/adapter.js +173 -0
- package/out/nc/adapters/opt-nc/adapter.js.map +1 -0
- package/out/nc/structures/opt-nc.d.ts +12 -0
- package/out/nc/structures/opt-nc.d.ts.map +1 -0
- package/out/nc/structures/opt-nc.js +64 -0
- package/out/nc/structures/opt-nc.js.map +1 -0
- package/out/nc/tools/fetch/opt-nc.d.ts +81 -0
- package/out/nc/tools/fetch/opt-nc.d.ts.map +1 -0
- package/out/nc/tools/fetch/opt-nc.js +162 -0
- package/out/nc/tools/fetch/opt-nc.js.map +1 -0
- package/out/nz/adapters/charities-register/adapter.d.ts +9 -0
- package/out/nz/adapters/charities-register/adapter.d.ts.map +1 -0
- package/out/nz/adapters/charities-register/adapter.js +36 -0
- package/out/nz/adapters/charities-register/adapter.js.map +1 -0
- package/out/nz/evaluation/charities-register.d.ts +60 -0
- package/out/nz/evaluation/charities-register.d.ts.map +1 -0
- package/out/nz/evaluation/charities-register.js +84 -0
- package/out/nz/evaluation/charities-register.js.map +1 -0
- package/out/recipes/bare/postcode.d.ts +2 -1
- package/out/recipes/bare/postcode.d.ts.map +1 -1
- package/out/recipes/bare/postcode.js +14 -11
- package/out/recipes/bare/postcode.js.map +1 -1
- package/out/recipes/deepseek/batches.d.ts +11 -1
- package/out/recipes/deepseek/batches.d.ts.map +1 -1
- package/out/recipes/deepseek/batches.js +8 -7
- package/out/recipes/deepseek/batches.js.map +1 -1
- package/out/recipes/po/box/cedex/recipe.d.ts.map +1 -1
- package/out/recipes/po/box/cedex/recipe.js +12 -1
- package/out/recipes/po/box/cedex/recipe.js.map +1 -1
- package/out/recipes/po/box/cedex/us.d.ts +12 -0
- package/out/recipes/po/box/cedex/us.d.ts.map +1 -1
- package/out/recipes/po/box/cedex/us.js +36 -2
- package/out/recipes/po/box/cedex/us.js.map +1 -1
- package/out/recipes/scaffold.d.ts +1 -1
- package/out/recipes/sources.d.ts.map +1 -1
- package/out/recipes/sources.js +16 -0
- package/out/recipes/sources.js.map +1 -1
- package/out/recipes.d.ts.map +1 -1
- package/out/recipes.js +2 -0
- package/out/recipes.js.map +1 -1
- package/out/registers.d.ts +28 -2
- package/out/registers.d.ts.map +1 -1
- package/out/registers.js +28 -2
- package/out/registers.js.map +1 -1
- package/out/{post-offices → structures}/source.d.ts +34 -16
- package/out/structures/source.d.ts.map +1 -0
- package/out/structures/source.js +39 -0
- package/out/structures/source.js.map +1 -0
- package/out/structures/sources.d.ts +6 -0
- package/out/structures/sources.d.ts.map +1 -0
- package/out/structures/sources.js +23 -0
- package/out/structures/sources.js.map +1 -0
- package/out/synthesizers/house-venue.d.ts.map +1 -1
- package/out/synthesizers/house-venue.js +2 -1
- package/out/synthesizers/house-venue.js.map +1 -1
- package/out/synthesizers/tail.d.ts +15 -1
- package/out/synthesizers/tail.d.ts.map +1 -1
- package/out/synthesizers/tail.js +8 -3
- package/out/synthesizers/tail.js.map +1 -1
- package/out/tools/audit.js +1 -1
- package/out/tools/audit.js.map +1 -1
- package/out/tools/fetch/storage.d.ts +10 -2
- package/out/tools/fetch/storage.d.ts.map +1 -1
- package/out/tools/fetch/storage.js +18 -4
- package/out/tools/fetch/storage.js.map +1 -1
- package/out/tools/fetch.d.ts +10 -2
- package/out/tools/fetch.d.ts.map +1 -1
- package/out/tools/fetch.js +10 -2
- package/out/tools/fetch.js.map +1 -1
- package/out/tools/overlay/kryptonite.d.ts.map +1 -1
- package/out/tools/overlay/kryptonite.js +5 -2
- package/out/tools/overlay/kryptonite.js.map +1 -1
- package/out/tools/overlay/split/attribute.d.ts +7 -1
- package/out/tools/overlay/split/attribute.d.ts.map +1 -1
- package/out/tools/overlay/split/attribute.js +4 -1
- package/out/tools/overlay/split/attribute.js.map +1 -1
- package/out/tools/overlay/split/overlay.d.ts +10 -0
- package/out/tools/overlay/split/overlay.d.ts.map +1 -1
- package/out/tools/overlay/split/overlay.js +17 -4
- package/out/tools/overlay/split/overlay.js.map +1 -1
- package/out/tools/postcode/triples.js +3 -3
- package/out/tools/postcode/triples.js.map +1 -1
- package/out/tools/region-slot-census.run.d.ts +2 -0
- package/out/tools/region-slot-census.run.d.ts.map +1 -0
- package/out/tools/region-slot-census.run.js +134 -0
- package/out/tools/region-slot-census.run.js.map +1 -0
- package/out/training/config/load.d.ts.map +1 -1
- package/out/training/config/load.js +10 -0
- package/out/training/config/load.js.map +1 -1
- package/out/training/config/schema.d.ts +13 -0
- package/out/training/config/schema.d.ts.map +1 -1
- package/out/training/config/schema.js +6 -0
- package/out/training/config/schema.js.map +1 -1
- package/out/tw/registers.d.ts +9 -0
- package/out/tw/registers.d.ts.map +1 -1
- package/out/tw/registers.js +11 -4
- package/out/tw/registers.js.map +1 -1
- package/out/tw/structures/chunghwa-post.d.ts +39 -0
- package/out/tw/structures/chunghwa-post.d.ts.map +1 -0
- package/out/tw/structures/chunghwa-post.js +150 -0
- package/out/tw/structures/chunghwa-post.js.map +1 -0
- package/out/tw/tools/fetch/chunghwa-post.d.ts +55 -0
- package/out/tw/tools/fetch/chunghwa-post.d.ts.map +1 -0
- package/out/tw/tools/fetch/chunghwa-post.js +110 -0
- package/out/tw/tools/fetch/chunghwa-post.js.map +1 -0
- package/out/us/adapters/state/ny-notaries/adapter.d.ts.map +1 -1
- package/out/us/adapters/state/ny-notaries/adapter.js +7 -2
- package/out/us/adapters/state/ny-notaries/adapter.js.map +1 -1
- package/out/us/adapters/state/tx-notaries/adapter.d.ts +42 -0
- package/out/us/adapters/state/tx-notaries/adapter.d.ts.map +1 -1
- package/out/us/adapters/state/tx-notaries/adapter.js +92 -19
- package/out/us/adapters/state/tx-notaries/adapter.js.map +1 -1
- package/out/us/adapters/usgov/nad/adapter.d.ts +35 -2
- package/out/us/adapters/usgov/nad/adapter.d.ts.map +1 -1
- package/out/us/adapters/usgov/nad/adapter.js +90 -27
- package/out/us/adapters/usgov/nad/adapter.js.map +1 -1
- package/out/us/adapters/usgov/nppes/adapter.d.ts.map +1 -1
- package/out/us/adapters/usgov/nppes/adapter.js +8 -11
- package/out/us/adapters/usgov/nppes/adapter.js.map +1 -1
- package/out/us/adapters/usgov/usgs-structures/adapter.d.ts +87 -0
- package/out/us/adapters/usgov/usgs-structures/adapter.d.ts.map +1 -0
- package/out/us/adapters/usgov/{usgs-post-offices → usgs-structures}/adapter.js +36 -27
- package/out/us/adapters/usgov/usgs-structures/adapter.js.map +1 -0
- package/out/us/recipes/county.d.ts +124 -0
- package/out/us/recipes/county.d.ts.map +1 -0
- package/out/us/recipes/county.js +295 -0
- package/out/us/recipes/county.js.map +1 -0
- package/out/us/street-unit.d.ts +10 -3
- package/out/us/street-unit.d.ts.map +1 -1
- package/out/us/street-unit.js +14 -6
- package/out/us/street-unit.js.map +1 -1
- package/out/us/structures/usgs/layers.d.ts +57 -0
- package/out/us/structures/usgs/layers.d.ts.map +1 -0
- package/out/us/structures/usgs/layers.js +121 -0
- package/out/us/structures/usgs/layers.js.map +1 -0
- package/out/us/structures/usgs/national-map.d.ts +14 -0
- package/out/us/structures/usgs/national-map.d.ts.map +1 -0
- package/out/us/{post-offices/usgs-national-map.js → structures/usgs/national-map.js} +16 -14
- package/out/us/structures/usgs/national-map.js.map +1 -0
- package/out/us/tools/fetch/usgs/gnis.d.ts +118 -0
- package/out/us/tools/fetch/usgs/gnis.d.ts.map +1 -0
- package/out/us/tools/fetch/usgs/gnis.js +177 -0
- package/out/us/tools/fetch/usgs/gnis.js.map +1 -0
- package/out/us/tools/fetch/usgs/structures.d.ts +99 -0
- package/out/us/tools/fetch/usgs/structures.d.ts.map +1 -0
- package/out/us/tools/fetch/usgs/structures.js +233 -0
- package/out/us/tools/fetch/usgs/structures.js.map +1 -0
- package/out/utils/align.js.map +1 -1
- package/out/utils/evaluation-groups.d.ts +98 -0
- package/out/utils/evaluation-groups.d.ts.map +1 -0
- package/out/utils/evaluation-groups.js +92 -0
- package/out/utils/evaluation-groups.js.map +1 -0
- package/out/utils/split.d.ts +26 -1
- package/out/utils/split.d.ts.map +1 -1
- package/out/utils/split.js +28 -3
- package/out/utils/split.js.map +1 -1
- package/out/utils/tokenize.d.ts +3 -3
- package/out/utils/tokenize.d.ts.map +1 -1
- package/out/utils/tokenize.js.map +1 -1
- package/out/utils/validation-groups.d.ts +168 -0
- package/out/utils/validation-groups.d.ts.map +1 -0
- package/out/utils/validation-groups.js +135 -0
- package/out/utils/validation-groups.js.map +1 -0
- package/out/utils/wof-json.d.ts +31 -57
- package/out/utils/wof-json.d.ts.map +1 -1
- package/out/utils/wof-json.js +81 -98
- package/out/utils/wof-json.js.map +1 -1
- package/package.json +18 -18
- package/lib/adapters/wof/record-cache.ts +0 -118
- package/lib/build/heap.ts +0 -60
- package/lib/post-offices/sources.ts +0 -18
- package/lib/us/post-offices/usgs-national-map.ts +0 -89
- package/lib/us/tools/fetch/usgs-post-offices.ts +0 -362
- package/out/adapters/wof/record-cache.d.ts +0 -22
- package/out/adapters/wof/record-cache.d.ts.map +0 -1
- package/out/adapters/wof/record-cache.js +0 -89
- package/out/adapters/wof/record-cache.js.map +0 -1
- package/out/build/heap.d.ts +0 -26
- package/out/build/heap.d.ts.map +0 -1
- package/out/build/heap.js +0 -52
- package/out/build/heap.js.map +0 -1
- package/out/post-offices/source.d.ts.map +0 -1
- package/out/post-offices/source.js +0 -21
- package/out/post-offices/source.js.map +0 -1
- package/out/post-offices/sources.d.ts +0 -13
- package/out/post-offices/sources.d.ts.map +0 -1
- package/out/post-offices/sources.js +0 -8
- package/out/post-offices/sources.js.map +0 -1
- package/out/us/adapters/usgov/usgs-post-offices/adapter.d.ts +0 -66
- package/out/us/adapters/usgov/usgs-post-offices/adapter.d.ts.map +0 -1
- package/out/us/adapters/usgov/usgs-post-offices/adapter.js.map +0 -1
- package/out/us/post-offices/usgs-national-map.d.ts +0 -14
- package/out/us/post-offices/usgs-national-map.d.ts.map +0 -1
- package/out/us/post-offices/usgs-national-map.js.map +0 -1
- package/out/us/tools/fetch/usgs-post-offices.d.ts +0 -99
- package/out/us/tools/fetch/usgs-post-offices.d.ts.map +0 -1
- package/out/us/tools/fetch/usgs-post-offices.js +0 -246
- package/out/us/tools/fetch/usgs-post-offices.js.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* New Caledonia's entry in the structures layer: OPT-NC's agencies,
|
|
6
|
+
* as `mailwoman corpus fetch nc-opt-agences` writes them.
|
|
7
|
+
*
|
|
8
|
+
* An `Agence` or an `Annexe` serves the public and is filed under the post-office category.
|
|
9
|
+
* The mail-processing center (type `Ctc`) is closed to the public and yields no record.
|
|
10
|
+
*
|
|
11
|
+
* The list is OPT-NC's own record of its counters, so its provenance is the postal operator's.
|
|
12
|
+
* Licence Ouverte 2.0.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { PathBuilder } from "path-ts"
|
|
16
|
+
import { JSONSpliterator } from "spliterator"
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
NC_OPT_AGENCES_ADAPTER_ID,
|
|
20
|
+
NC_OPT_AGENCES_FILENAME,
|
|
21
|
+
type OPTNCAgencyFeature,
|
|
22
|
+
readOPTNCAddress,
|
|
23
|
+
} from "#nc/adapters/opt-nc/adapter"
|
|
24
|
+
import type { OPTNCAgencesManifest } from "#nc/tools/fetch/opt-nc"
|
|
25
|
+
import {
|
|
26
|
+
postOfficeCategoryID,
|
|
27
|
+
StructureProvenance,
|
|
28
|
+
type StructureRecord,
|
|
29
|
+
type StructureSource,
|
|
30
|
+
type StructureSourceRead,
|
|
31
|
+
} from "#structures/source"
|
|
32
|
+
import { readManifest } from "#tools/fetch/download"
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The agency types that serve the public.
|
|
36
|
+
*/
|
|
37
|
+
const COUNTER_TYPES: ReadonlySet<string> = new Set(["agence", "annexe"])
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* One fetched feature as a structure record, or `null` when it has no identifier
|
|
41
|
+
* or doesn't serve the public.
|
|
42
|
+
*/
|
|
43
|
+
export function optNCStructureRecord(feature: OPTNCAgencyFeature, category: string): StructureRecord | null {
|
|
44
|
+
const { properties } = feature
|
|
45
|
+
const id = properties.globalid
|
|
46
|
+
|
|
47
|
+
if (!id || !COUNTER_TYPES.has(properties.type?.toLowerCase() ?? "")) return null
|
|
48
|
+
|
|
49
|
+
const [longitude, latitude] = feature.geometry?.coordinates ?? []
|
|
50
|
+
const address = readOPTNCAddress(properties)
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
id,
|
|
54
|
+
name: properties.texte ?? properties.nom,
|
|
55
|
+
category,
|
|
56
|
+
point: typeof latitude === "number" && typeof longitude === "number" ? { latitude, longitude } : null,
|
|
57
|
+
address: "components" in address ? address.components : null,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function* records(path: PathBuilder): AsyncIterable<StructureRecord> {
|
|
62
|
+
const category = postOfficeCategoryID()
|
|
63
|
+
|
|
64
|
+
for await (const feature of JSONSpliterator.fromAsync<OPTNCAgencyFeature>(path.toString())) {
|
|
65
|
+
const record = optNCStructureRecord(feature, category)
|
|
66
|
+
|
|
67
|
+
if (record) {
|
|
68
|
+
yield record
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const FETCH_COMMAND = "mailwoman corpus fetch nc-opt-agences"
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* OPT-NC's agencies.
|
|
77
|
+
*/
|
|
78
|
+
export const optNCAgencesStructures: StructureSource = {
|
|
79
|
+
id: "opt-nc-agences",
|
|
80
|
+
country: "NC",
|
|
81
|
+
publisher: "Office des postes et télécommunications de Nouvelle-Calédonie",
|
|
82
|
+
attribution: "OPT-NC, Localisation des agences OPT-NC, via data.gouv.nc",
|
|
83
|
+
license: "etalab-2.0",
|
|
84
|
+
registerSource: "nc-postal-1",
|
|
85
|
+
provenance: StructureProvenance.PostalOperator,
|
|
86
|
+
fetchCommand: FETCH_COMMAND,
|
|
87
|
+
|
|
88
|
+
async read(sourcesRoot): Promise<StructureSourceRead> {
|
|
89
|
+
const directory = sourcesRoot(NC_OPT_AGENCES_ADAPTER_ID)
|
|
90
|
+
const manifest = await readManifest<OPTNCAgencesManifest>(directory("MANIFEST.json"))
|
|
91
|
+
|
|
92
|
+
if (!manifest?.downloaded_at) {
|
|
93
|
+
throw new Error(`${directory} holds no MANIFEST.json with a fetch date. Run \`${FETCH_COMMAND}\` first.`)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
vintage: (manifest.publisher_version ?? manifest.downloaded_at).slice(0, 10),
|
|
98
|
+
records: records(directory(NC_OPT_AGENCES_FILENAME)),
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Fetches OPT-NC's agencies, the source of the `nc-opt-agences` adapter
|
|
6
|
+
* and New Caledonia's post offices in the structures layer.
|
|
7
|
+
*
|
|
8
|
+
* The dataset record `localisation-des-agences-opt-nc` on `data.gouv.nc` states the publisher
|
|
9
|
+
* and the license, and its `references` point at OPT-NC's open-data GIS.
|
|
10
|
+
* That GIS serves the features from FeatureServer `Agences_opendata` layer 0.
|
|
11
|
+
*
|
|
12
|
+
* The service itself states no license (`copyrightText` and the hub item's `licenseInfo` are empty),
|
|
13
|
+
* so the record is saved beside the features as `dataset.json`.
|
|
14
|
+
*
|
|
15
|
+
* The layer is paged by `OBJECTID` with `pageArcGISLayer`, and a pull whose size
|
|
16
|
+
* differs from the count the service stated is refused.
|
|
17
|
+
*
|
|
18
|
+
* Invoke via `mailwoman corpus fetch nc-opt-agences`.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { APIClient } from "@mailwoman/core/api"
|
|
22
|
+
import { arcGISFields, arcGISInteger, arcGISText, pageArcGISLayer } from "@mailwoman/core/api/arcgis"
|
|
23
|
+
import { ByteFormatter } from "@mailwoman/core/fs/formatters"
|
|
24
|
+
import { statPath } from "@mailwoman/core/fs/readers/stat"
|
|
25
|
+
import {
|
|
26
|
+
appendLocalTextFile,
|
|
27
|
+
makeDirectories,
|
|
28
|
+
movePath,
|
|
29
|
+
removePathIfPresent,
|
|
30
|
+
stagingSiblingPath,
|
|
31
|
+
writeLocalJSONFile,
|
|
32
|
+
} from "@mailwoman/core/fs/writers"
|
|
33
|
+
import { sha256File } from "@mailwoman/core/hash"
|
|
34
|
+
import { stringifyJSON } from "@mailwoman/core/json"
|
|
35
|
+
import { readPointCoordinates } from "@mailwoman/spatial/geometries/point/coordinates"
|
|
36
|
+
import { PathBuilder, type PathBuilderLike } from "path-ts"
|
|
37
|
+
|
|
38
|
+
import {
|
|
39
|
+
NC_OPT_AGENCES_ADAPTER_ID,
|
|
40
|
+
NC_OPT_AGENCES_FILENAME,
|
|
41
|
+
type OPTNCAgencyFeature,
|
|
42
|
+
} from "#nc/adapters/opt-nc/adapter"
|
|
43
|
+
import type { BaseFetchOptions, FetchSummary, SourceManifest } from "#tools/fetch/download"
|
|
44
|
+
import { writeManifest } from "#tools/fetch/download"
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The FeatureServer that serves the agencies.
|
|
48
|
+
*/
|
|
49
|
+
export const OPT_NC_SERVICE_URL =
|
|
50
|
+
"https://services6.arcgis.com/k3ZIRnRpeM4Ht4fG/arcgis/rest/services/Agences_opendata/FeatureServer"
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The dataset record on `data.gouv.nc`, which states the publisher and the license.
|
|
54
|
+
*/
|
|
55
|
+
export const OPT_NC_DATASET_URL =
|
|
56
|
+
"https://data.gouv.nc/api/explore/v2.1/catalog/datasets/localisation-des-agences-opt-nc"
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The service's `maxRecordCount`.
|
|
60
|
+
*/
|
|
61
|
+
export const OPT_NC_PAGE_SIZE = 1000
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The service fields the fetcher asks for, in the service's spelling.
|
|
65
|
+
*/
|
|
66
|
+
export const OPT_NC_FIELDS = [
|
|
67
|
+
"OBJECTID",
|
|
68
|
+
"ID",
|
|
69
|
+
"TEXTE",
|
|
70
|
+
"TYPE",
|
|
71
|
+
"NOM",
|
|
72
|
+
"ADRESSE",
|
|
73
|
+
"CODE_POSTAL",
|
|
74
|
+
"VILLE",
|
|
75
|
+
"GLOBALID",
|
|
76
|
+
] as const
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The file the dataset record is saved to, beside the features.
|
|
80
|
+
*/
|
|
81
|
+
export const OPT_NC_DATASET_FILENAME = "dataset.json"
|
|
82
|
+
|
|
83
|
+
const SLUG = NC_OPT_AGENCES_ADAPTER_ID
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The parts of the `data.gouv.nc` dataset record a fetch reads.
|
|
87
|
+
*/
|
|
88
|
+
interface OPTNCDatasetRecord {
|
|
89
|
+
metas?: { default?: { modified?: string; license?: string; license_url?: string; publisher?: string } }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* What one run recorded.
|
|
94
|
+
* `publisher_version` is the dataset record's `modified`.
|
|
95
|
+
*/
|
|
96
|
+
export interface OPTNCAgencesManifest extends SourceManifest {
|
|
97
|
+
service_url: string
|
|
98
|
+
dataset_url: string
|
|
99
|
+
feature_count: number
|
|
100
|
+
license: string | null
|
|
101
|
+
license_url: string | null
|
|
102
|
+
publisher: string | null
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* One service feature in the shape the adapter reads.
|
|
107
|
+
*
|
|
108
|
+
* @throws When the value isn't a GeoJSON feature, or has no `OBJECTID`.
|
|
109
|
+
*/
|
|
110
|
+
export function normalizeOPTNCFeature(value: unknown): OPTNCAgencyFeature {
|
|
111
|
+
if (value == null || typeof value !== "object" || (value as { type?: unknown }).type !== "Feature") {
|
|
112
|
+
throw new Error(`${SLUG}: expected a GeoJSON Feature, got ${String(stringifyJSON(value)).slice(0, 200)}`)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const feature = value as { geometry?: unknown; properties?: unknown }
|
|
116
|
+
const properties = arcGISFields(feature.properties)
|
|
117
|
+
const objectid = arcGISInteger(properties["objectid"])
|
|
118
|
+
|
|
119
|
+
if (objectid === null) throw new Error(`${SLUG}: the layer answered a feature with no OBJECTID`)
|
|
120
|
+
|
|
121
|
+
const point = readPointCoordinates(feature.geometry)
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
type: "Feature",
|
|
125
|
+
geometry: point ? { type: "Point", coordinates: [point[0], point[1]] } : null,
|
|
126
|
+
properties: {
|
|
127
|
+
objectid,
|
|
128
|
+
id: arcGISInteger(properties["id"]),
|
|
129
|
+
texte: arcGISText(properties["texte"]),
|
|
130
|
+
type: arcGISText(properties["type"]),
|
|
131
|
+
nom: arcGISText(properties["nom"]),
|
|
132
|
+
adresse: arcGISText(properties["adresse"]),
|
|
133
|
+
code_postal: arcGISText(properties["code_postal"]),
|
|
134
|
+
ville: arcGISText(properties["ville"]),
|
|
135
|
+
globalid: arcGISText(properties["globalid"]),
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface DownloadOPTNCAgencesOptions {
|
|
141
|
+
outputDir: PathBuilderLike
|
|
142
|
+
signal?: AbortSignal
|
|
143
|
+
report?: (line: string) => void
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Pages the layer into `<outputDir>/agences.geojsonl` and writes the dataset record and the manifest.
|
|
148
|
+
*
|
|
149
|
+
* @throws When the service answers an error, or a pull whose size differs from its count.
|
|
150
|
+
*/
|
|
151
|
+
export async function downloadOPTNCAgences(
|
|
152
|
+
client: Pick<APIClient, "fetch">,
|
|
153
|
+
options: DownloadOPTNCAgencesOptions
|
|
154
|
+
): Promise<FetchSummary> {
|
|
155
|
+
const { report, signal } = options
|
|
156
|
+
const destDir = PathBuilder.from(options.outputDir)
|
|
157
|
+
const featuresPath = destDir(NC_OPT_AGENCES_FILENAME)
|
|
158
|
+
|
|
159
|
+
report?.(`=== ${SLUG} / ${NC_OPT_AGENCES_FILENAME}`)
|
|
160
|
+
|
|
161
|
+
const { data: dataset } = await client.fetch<OPTNCDatasetRecord>({ url: OPT_NC_DATASET_URL, signal })
|
|
162
|
+
const metas = dataset?.metas?.default ?? {}
|
|
163
|
+
|
|
164
|
+
report?.(
|
|
165
|
+
` ${metas.publisher ?? "no publisher"}; license ${metas.license ?? "absent"}; modified ${metas.modified ?? "unstated"}`
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
await makeDirectories(destDir)
|
|
169
|
+
|
|
170
|
+
const staging = stagingSiblingPath(featuresPath)
|
|
171
|
+
let written = 0
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
await appendLocalTextFile("", staging)
|
|
175
|
+
|
|
176
|
+
const pages = pageArcGISLayer(
|
|
177
|
+
client,
|
|
178
|
+
{ serviceURL: OPT_NC_SERVICE_URL, layerID: 0 },
|
|
179
|
+
{
|
|
180
|
+
outFields: OPT_NC_FIELDS,
|
|
181
|
+
pageSize: OPT_NC_PAGE_SIZE,
|
|
182
|
+
context: SLUG,
|
|
183
|
+
signal,
|
|
184
|
+
onCount: (count) => report?.(` ${count.toLocaleString()} features`),
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
for await (const page of pages) {
|
|
189
|
+
const features = page.map(normalizeOPTNCFeature)
|
|
190
|
+
|
|
191
|
+
await appendLocalTextFile(`${features.map((feature) => stringifyJSON(feature)).join("\n")}\n`, staging)
|
|
192
|
+
written += features.length
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
await movePath(staging, featuresPath)
|
|
196
|
+
} finally {
|
|
197
|
+
await removePathIfPresent(staging)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
await writeLocalJSONFile((dataset ?? {}) as Record<string, unknown>, destDir(OPT_NC_DATASET_FILENAME))
|
|
201
|
+
|
|
202
|
+
const sha256 = await sha256File(featuresPath)
|
|
203
|
+
const { size: bytes } = await statPath(featuresPath)
|
|
204
|
+
|
|
205
|
+
const manifest: OPTNCAgencesManifest = {
|
|
206
|
+
source_url: OPT_NC_SERVICE_URL,
|
|
207
|
+
service_url: OPT_NC_SERVICE_URL,
|
|
208
|
+
dataset_url: OPT_NC_DATASET_URL,
|
|
209
|
+
filename: NC_OPT_AGENCES_FILENAME,
|
|
210
|
+
feature_count: written,
|
|
211
|
+
license: metas.license ?? null,
|
|
212
|
+
license_url: metas.license_url ?? null,
|
|
213
|
+
publisher: metas.publisher ?? null,
|
|
214
|
+
bytes,
|
|
215
|
+
sha256,
|
|
216
|
+
...(metas.modified ? { publisher_version: metas.modified } : {}),
|
|
217
|
+
downloaded_at: new Date().toISOString(),
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
await writeManifest(destDir("MANIFEST.json"), manifest)
|
|
221
|
+
|
|
222
|
+
report?.(` ✓ ${written.toLocaleString()} features, ${ByteFormatter.formatIEC(bytes)} sha256=${sha256}`)
|
|
223
|
+
|
|
224
|
+
return { fetched: 1, skipped: 0, failed: 0, failedCodes: [] }
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The path `#nc/adapters/opt-nc/adapter` reads, given the root a fetch wrote under.
|
|
229
|
+
*/
|
|
230
|
+
export function optNCAgencesInputPath(outRoot: BaseFetchOptions["outRoot"]): PathBuilderLike {
|
|
231
|
+
return outRoot(SLUG, NC_OPT_AGENCES_FILENAME)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface FetchOPTNCAgencesOptions extends BaseFetchOptions {
|
|
235
|
+
signal?: AbortSignal
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* The registry entry.
|
|
240
|
+
*/
|
|
241
|
+
export async function fetchOPTNCAgences(
|
|
242
|
+
options: FetchOPTNCAgencesOptions,
|
|
243
|
+
report?: (line: string) => void
|
|
244
|
+
): Promise<FetchSummary> {
|
|
245
|
+
await using client = new APIClient({ displayName: SLUG, retry: true, minRequestIntervalMs: 500 })
|
|
246
|
+
|
|
247
|
+
// Awaited rather than returned: `await using` disposes the client when this scope exits.
|
|
248
|
+
return await downloadOPTNCAgences(client, { outputDir: options.outRoot(SLUG), signal: options.signal, report })
|
|
249
|
+
}
|
|
@@ -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
|
+
* `nz-charities-register`: New Zealand's Charities Register as a corpus source.
|
|
6
|
+
*
|
|
7
|
+
* The adapter reads the OData answer `organisations.csv` through {@linkcode readNZCharities},
|
|
8
|
+
* the reader the evaluation source of the same id calls, and renders each charity's
|
|
9
|
+
* street line, suburb, city and postcode.
|
|
10
|
+
* The fetch selects no name, officer or email column, so no row can join an address to
|
|
11
|
+
* a person, though a small charity's street address can be an officer's home.
|
|
12
|
+
*
|
|
13
|
+
* A post-office box and a second line that isn't the city yield no row.
|
|
14
|
+
*
|
|
15
|
+
* CC BY 3.0 NZ grants the right to `create one or more Adaptations` (`data/licenses/nz-charities-cc-by-3.0-nz.md`).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { createEvaluationCorpusAdapter } from "#evaluation/corpus-adapter"
|
|
19
|
+
import { nzCharitiesRegisterSource, readNZCharities } from "#nz/evaluation/charities-register"
|
|
20
|
+
import { SourceRegister } from "#registers"
|
|
21
|
+
import { AddressRole } from "#types"
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Registry id for this adapter, stamped into every row it emits, and the evaluation source's id.
|
|
25
|
+
*/
|
|
26
|
+
export const NZ_CHARITIES_REGISTER_ADAPTER_ID = "nz-charities-register"
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The registered `nz-charities-register` adapter.
|
|
30
|
+
*/
|
|
31
|
+
export const nzCharitiesRegisterAdapter = createEvaluationCorpusAdapter({
|
|
32
|
+
id: NZ_CHARITIES_REGISTER_ADAPTER_ID,
|
|
33
|
+
source: nzCharitiesRegisterSource,
|
|
34
|
+
register: SourceRegister.NZCharitiesRegister,
|
|
35
|
+
locale: "en-NZ",
|
|
36
|
+
addressRole: AddressRole.RegisteredOffice,
|
|
37
|
+
description:
|
|
38
|
+
"Charities Services' Charities Register (CC BY 3.0 NZ): each registered charity's street address, without its name.",
|
|
39
|
+
read: readNZCharities,
|
|
40
|
+
})
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `nz-charities-register`: the Charities Register that Charities Services
|
|
6
|
+
* (Te Tari Taiwhenua, the Department of Internal Affairs) publishes through its
|
|
7
|
+
* OData service, read by the evaluation source and by the `nz-charities-register`
|
|
8
|
+
* corpus adapter through {@linkcode readNZCharities}.
|
|
9
|
+
*
|
|
10
|
+
* The fetch asks `vOrganisations` for every registered charity's street address:
|
|
11
|
+
* two lines, a suburb, a city and a postcode.
|
|
12
|
+
* The second line can repeat the city or the city and postcode, and otherwise
|
|
13
|
+
* holds a rural delivery code (`RD 3`) or a second address.
|
|
14
|
+
*
|
|
15
|
+
* A record is kept only where the second line is empty or repeats the city,
|
|
16
|
+
* and the first line is a street with a house number.
|
|
17
|
+
*
|
|
18
|
+
* The rows read only the address, never the charity's name, because a small
|
|
19
|
+
* charity's name can be a person's.
|
|
20
|
+
*
|
|
21
|
+
* The register states no region.
|
|
22
|
+
* NZ Post's postcodes run north to south by their first digit, so the record is stratified by that digit.
|
|
23
|
+
*
|
|
24
|
+
* ## License
|
|
25
|
+
*
|
|
26
|
+
* The open-data page (`https://www.charities.govt.nz/charities-in-new-zealand/the-charities-register/open-data`)
|
|
27
|
+
* states « Use of this data is licensed under a Creative Commons Attribution 3.0 New Zealand
|
|
28
|
+
* License. » CC BY 3.0 NZ grants the right to « create one or more Adaptations », provided
|
|
29
|
+
* each identifies that changes were made (`data/licenses/nz-charities-cc-by-3.0-nz.md`).
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import type { PathBuilder, PathBuilderLike } from "path-ts"
|
|
33
|
+
import { CSVSpliterator } from "spliterator"
|
|
34
|
+
|
|
35
|
+
import {
|
|
36
|
+
type EvaluationRecordReading,
|
|
37
|
+
type EvaluationSource,
|
|
38
|
+
evaluationSourceRead,
|
|
39
|
+
evaluationStreetLine,
|
|
40
|
+
fetchEvaluationFile,
|
|
41
|
+
readEvaluationFetch,
|
|
42
|
+
} from "#evaluation/source"
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The OData query: every registered charity's street address columns, as CSV, unpaged.
|
|
46
|
+
*/
|
|
47
|
+
export const NZ_CHARITIES_REGISTER_URL =
|
|
48
|
+
"http://www.odata.charities.govt.nz/vOrganisations?$filter=RegistrationStatus%20eq%20%27Registered%27&$returnall=true" +
|
|
49
|
+
"&$select=OrganisationId,CharityRegistrationNumber,StreetAddressLine1,StreetAddressLine2,StreetAddressSuburb," +
|
|
50
|
+
"StreetAddressCity,StreetAddressPostcode,StreetAddressCountry&$format=csv"
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The file the fetch writes the query's CSV answer to and the reader reads.
|
|
54
|
+
*/
|
|
55
|
+
export const NZ_CHARITIES_REGISTER_FILENAME = "organisations.csv"
|
|
56
|
+
|
|
57
|
+
interface CharityRow {
|
|
58
|
+
charity_registration_number?: string
|
|
59
|
+
street_address_line1?: string
|
|
60
|
+
street_address_line2?: string
|
|
61
|
+
street_address_suburb?: string
|
|
62
|
+
street_address_city?: string
|
|
63
|
+
street_address_postcode?: string
|
|
64
|
+
street_address_country?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function value(text: string | undefined): string {
|
|
68
|
+
return (text ?? "").replaceAll(/\s+/gu, " ").trim()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const sameText = (a: string, b: string) => a.localeCompare(b, "en", { sensitivity: "base" }) === 0
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* One register row as an address record, or the reason it yields none.
|
|
75
|
+
*/
|
|
76
|
+
export function readNZCharity(row: CharityRow): EvaluationRecordReading {
|
|
77
|
+
const id = value(row.charity_registration_number)
|
|
78
|
+
const city = value(row.street_address_city)
|
|
79
|
+
const suburb = value(row.street_address_suburb)
|
|
80
|
+
const postcode = value(row.street_address_postcode)
|
|
81
|
+
const line = value(row.street_address_line1)
|
|
82
|
+
const second = value(row.street_address_line2)
|
|
83
|
+
const country = value(row.street_address_country)
|
|
84
|
+
|
|
85
|
+
if (!id) return { refused: "row:identifier-absent" }
|
|
86
|
+
|
|
87
|
+
if (!line) return { refused: "row:address-absent" }
|
|
88
|
+
|
|
89
|
+
if (country && !sameText(country, "New Zealand")) return { refused: "row:overseas" }
|
|
90
|
+
|
|
91
|
+
if (!/^\d{4}$/u.test(postcode)) return { refused: "row:postcode-absent" }
|
|
92
|
+
|
|
93
|
+
if (!city) return { refused: "row:locality-absent" }
|
|
94
|
+
|
|
95
|
+
if (second && !sameText(second, city) && !sameText(second, `${city} ${postcode}`) && !sameText(second, suburb)) {
|
|
96
|
+
return { refused: "row:several-lines" }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (/\b(?:p\.?\s?o\.?\s*box|private bag)\b/iu.test(line)) return { refused: "row:post-box" }
|
|
100
|
+
|
|
101
|
+
const street = evaluationStreetLine(line, "NZ")
|
|
102
|
+
|
|
103
|
+
if ("refused" in street) return street
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
id,
|
|
107
|
+
stratum: `postcode ${postcode[0]}`,
|
|
108
|
+
components: {
|
|
109
|
+
house_number: street.house_number,
|
|
110
|
+
street: street.street,
|
|
111
|
+
...(suburb && !sameText(suburb, city) ? { dependent_locality: suburb } : {}),
|
|
112
|
+
locality: city,
|
|
113
|
+
postcode,
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* New Zealand's evaluation source, the Charities Register.
|
|
120
|
+
*/
|
|
121
|
+
export const nzCharitiesRegisterSource: EvaluationSource = {
|
|
122
|
+
id: "nz-charities-register",
|
|
123
|
+
country: "NZ",
|
|
124
|
+
publisher: "Charities Services, Department of Internal Affairs",
|
|
125
|
+
attribution: "Charities Services (Department of Internal Affairs), Charities Register open data, CC BY 3.0 NZ",
|
|
126
|
+
license: "Creative Commons Attribution 3.0 New Zealand",
|
|
127
|
+
registerSource: "nz-charity-nonprofit-1",
|
|
128
|
+
|
|
129
|
+
fetch: (directory, report) =>
|
|
130
|
+
fetchEvaluationFile(directory, NZ_CHARITIES_REGISTER_URL, NZ_CHARITIES_REGISTER_FILENAME, report),
|
|
131
|
+
|
|
132
|
+
async read(directory: PathBuilder) {
|
|
133
|
+
const fetched = await readEvaluationFetch(directory)
|
|
134
|
+
|
|
135
|
+
return evaluationSourceRead(
|
|
136
|
+
`fetched ${fetched.downloaded_at.slice(0, 10)}`,
|
|
137
|
+
readNZCharities(directory(NZ_CHARITIES_REGISTER_FILENAME))
|
|
138
|
+
)
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Every row of the OData CSV answer at `path`, read by {@linkcode readNZCharity}.
|
|
144
|
+
*/
|
|
145
|
+
export async function* readNZCharities(path: PathBuilderLike): AsyncGenerator<EvaluationRecordReading> {
|
|
146
|
+
for await (const row of CSVSpliterator.fromAsync<CharityRow>(path, { normalizeKeys: true })) {
|
|
147
|
+
yield readNZCharity(row)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -4,17 +4,19 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* `bare-postcode` — a postcode without another address component, in the country's format.
|
|
6
6
|
*
|
|
7
|
-
* Every surface the recipe renders is run through `
|
|
8
|
-
* detector calls it a postcode, so the rendering table
|
|
7
|
+
* Every surface the recipe renders is run through `computeQueryShape`
|
|
8
|
+
* and refused unless the detector calls it a postcode, so the rendering table
|
|
9
|
+
* and the legacy-formats table of `@mailwoman/postcode` must agree.
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
import { isNLPostcodeKey } from "@mailwoman/codex/nl"
|
|
12
13
|
import { currentSourcePath } from "@mailwoman/core/data-root"
|
|
13
14
|
import { pathExists } from "@mailwoman/core/fs/readers/stat"
|
|
15
|
+
import { isPostcodeFormat } from "@mailwoman/core/pipeline/types"
|
|
14
16
|
import { SeededRandom } from "@mailwoman/core/utils"
|
|
15
17
|
import { compactPostcode } from "@mailwoman/postcode/display-form"
|
|
16
|
-
import { computeQueryShape } from "@mailwoman/query-shape"
|
|
17
|
-
import {
|
|
18
|
+
import { computeQueryShape } from "@mailwoman/postcode/recognizer/query-shape"
|
|
19
|
+
import { QueryShapeGeneration } from "@mailwoman/postcode/recognizer/rule-generation"
|
|
18
20
|
import type { PathBuilderLike } from "path-ts"
|
|
19
21
|
|
|
20
22
|
import { normalizeGauntletSurface, readGauntletInputs } from "#gauntlet-inputs"
|
|
@@ -78,7 +80,7 @@ const SOURCES: PostcodeSource[] = [
|
|
|
78
80
|
*/
|
|
79
81
|
const WRITTEN_FORMS: ReadonlyMap<string, { locale: string; render: (compact: string) => string[] }> = new Map([
|
|
80
82
|
// `NNN NN`, written with the space.
|
|
81
|
-
// The four countries share the shape, so
|
|
83
|
+
// The four countries share the shape, so the postal family reports all four on one hit.
|
|
82
84
|
["CZ", { locale: "cs-CZ", render: spacedThree }],
|
|
83
85
|
["SK", { locale: "sk-SK", render: spacedThree }],
|
|
84
86
|
["SE", { locale: "sv-SE", render: spacedThree }],
|
|
@@ -147,13 +149,14 @@ export function renderBarePostcode(country: string, postcode: string): string[]
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
/**
|
|
150
|
-
* Whether `
|
|
152
|
+
* Whether the `postal` family reads this surface as a postcode across its whole span.
|
|
151
153
|
*
|
|
152
154
|
* A surface the detector doesn't recognize would train the model on a string
|
|
153
155
|
* the query-shape prior cannot then support.
|
|
156
|
+
* The recipe holds no model card, so it reads the `postal` generation.
|
|
154
157
|
*/
|
|
155
158
|
export function detectedAsPostcode(surface: string): boolean {
|
|
156
|
-
return computeQueryShape(surface).knownFormats.some(
|
|
159
|
+
return computeQueryShape(surface, QueryShapeGeneration.Postal).knownFormats.some(
|
|
157
160
|
(hit) => isPostcodeFormat(hit.format) && hit.span.start === 0 && hit.span.end === surface.length
|
|
158
161
|
)
|
|
159
162
|
}
|
|
@@ -258,7 +261,7 @@ export const barePostcodeRecipe: CorpusRecipe = {
|
|
|
258
261
|
if (perCountry.get(country)! >= budget) break
|
|
259
262
|
|
|
260
263
|
// A surface the detector doesn't read as a postcode is a disagreement
|
|
261
|
-
// between this table and
|
|
264
|
+
// between this table and the legacy-formats table.
|
|
262
265
|
if (!detectedAsPostcode(surface)) {
|
|
263
266
|
unrecognized++
|
|
264
267
|
|
|
@@ -292,11 +295,11 @@ export const barePostcodeRecipe: CorpusRecipe = {
|
|
|
292
295
|
}
|
|
293
296
|
|
|
294
297
|
// A rendered surface the detector refuses is an interface failure: every form here is
|
|
295
|
-
// one
|
|
298
|
+
// one the postal family declares a syntax for, so the count is expected to be zero.
|
|
296
299
|
if (unrecognized > 0) {
|
|
297
300
|
throw new Error(
|
|
298
|
-
`${unrecognized} rendered surfaces were not read as a postcode by
|
|
299
|
-
"WRITTEN_FORMS table and
|
|
301
|
+
`${unrecognized} rendered surfaces were not read as a postcode by computeQueryShape — the ` +
|
|
302
|
+
"WRITTEN_FORMS table and the postal family of @mailwoman/postcode disagree. Reconcile them before building."
|
|
300
303
|
)
|
|
301
304
|
}
|
|
302
305
|
|
|
@@ -198,10 +198,12 @@ export function planKryptoniteBatches(targetCount: number, batchSize: number): K
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
|
-
* The
|
|
202
|
-
*
|
|
201
|
+
* The country and locale of every kryptonite row.
|
|
202
|
+
*
|
|
203
|
+
* `KRYPTONITE_USER_TEMPLATE` asks for US addresses in every category, `french-saint` included,
|
|
204
|
+
* so each row is a US address: `1 Rue Saint-Denis, New York, NY 10001`.
|
|
203
205
|
*/
|
|
204
|
-
const
|
|
206
|
+
export const KRYPTONITE_COUNTRY = { country: "US", locale: "en-US" } as const
|
|
205
207
|
|
|
206
208
|
/**
|
|
207
209
|
* One generated canonical row, in the key order the Python generator wrote.
|
|
@@ -254,7 +256,7 @@ export function canonicalTranslitRow(
|
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
/**
|
|
257
|
-
* One adversarial row
|
|
259
|
+
* One adversarial row, a US address in every category ({@linkcode KRYPTONITE_COUNTRY}).
|
|
258
260
|
*/
|
|
259
261
|
export function canonicalKryptoniteRow(
|
|
260
262
|
category: KryptoniteCategory,
|
|
@@ -263,13 +265,11 @@ export function canonicalKryptoniteRow(
|
|
|
263
265
|
components: Readonly<Record<string, string>>,
|
|
264
266
|
kind: string
|
|
265
267
|
): DeepSeekRow {
|
|
266
|
-
const [country, locale] = FRENCH_CATEGORIES.has(category.category) ? ["FR", "fr-FR"] : ["US", "en-US"]
|
|
267
|
-
|
|
268
268
|
return {
|
|
269
269
|
raw,
|
|
270
270
|
components,
|
|
271
|
-
country,
|
|
272
|
-
locale,
|
|
271
|
+
country: KRYPTONITE_COUNTRY.country,
|
|
272
|
+
locale: KRYPTONITE_COUNTRY.locale,
|
|
273
273
|
source: "deepseek-kryptonite",
|
|
274
274
|
source_id: deterministicID("deepseek-kryptonite", `${category.category}|${index}|${raw}`),
|
|
275
275
|
license: DEEPSEEK_LICENSE_LABEL,
|
|
@@ -34,7 +34,18 @@ import {
|
|
|
34
34
|
} from "#us/recipes/skeleton-sources"
|
|
35
35
|
import { alignRow } from "#utils"
|
|
36
36
|
|
|
37
|
-
const COMPONENT_ORDER = [
|
|
37
|
+
const COMPONENT_ORDER = [
|
|
38
|
+
"house_number",
|
|
39
|
+
"street_prefix",
|
|
40
|
+
"street",
|
|
41
|
+
"street_suffix",
|
|
42
|
+
"po_box",
|
|
43
|
+
"venue",
|
|
44
|
+
"locality",
|
|
45
|
+
"postcode",
|
|
46
|
+
"region",
|
|
47
|
+
"cedex",
|
|
48
|
+
]
|
|
38
49
|
|
|
39
50
|
const orderComponents = (components: Record<string, string>): Record<string, string> =>
|
|
40
51
|
Object.fromEntries(COMPONENT_ORDER.filter((key) => components[key]).map((key) => [key, components[key]!]))
|