@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,64 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
import { JSONSpliterator } from "spliterator";
|
|
4
|
+
import { NC_OPT_AGENCES_ADAPTER_ID, NC_OPT_AGENCES_FILENAME, readOPTNCAddress, } from "#nc/adapters/opt-nc/adapter";
|
|
5
|
+
import { postOfficeCategoryID, StructureProvenance, } from "#structures/source";
|
|
6
|
+
import { readManifest } from "#tools/fetch/download";
|
|
7
|
+
/**
|
|
8
|
+
* The agency types that serve the public.
|
|
9
|
+
*/
|
|
10
|
+
const COUNTER_TYPES = new Set(["agence", "annexe"]);
|
|
11
|
+
/**
|
|
12
|
+
* One fetched feature as a structure record, or `null` when it has no identifier
|
|
13
|
+
* or doesn't serve the public.
|
|
14
|
+
*/
|
|
15
|
+
export function optNCStructureRecord(feature, category) {
|
|
16
|
+
const { properties } = feature;
|
|
17
|
+
const id = properties.globalid;
|
|
18
|
+
if (!id || !COUNTER_TYPES.has(properties.type?.toLowerCase() ?? ""))
|
|
19
|
+
return null;
|
|
20
|
+
const [longitude, latitude] = feature.geometry?.coordinates ?? [];
|
|
21
|
+
const address = readOPTNCAddress(properties);
|
|
22
|
+
return {
|
|
23
|
+
id,
|
|
24
|
+
name: properties.texte ?? properties.nom,
|
|
25
|
+
category,
|
|
26
|
+
point: typeof latitude === "number" && typeof longitude === "number" ? { latitude, longitude } : null,
|
|
27
|
+
address: "components" in address ? address.components : null,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function* records(path) {
|
|
31
|
+
const category = postOfficeCategoryID();
|
|
32
|
+
for await (const feature of JSONSpliterator.fromAsync(path.toString())) {
|
|
33
|
+
const record = optNCStructureRecord(feature, category);
|
|
34
|
+
if (record) {
|
|
35
|
+
yield record;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const FETCH_COMMAND = "mailwoman corpus fetch nc-opt-agences";
|
|
40
|
+
/**
|
|
41
|
+
* OPT-NC's agencies.
|
|
42
|
+
*/
|
|
43
|
+
export const optNCAgencesStructures = {
|
|
44
|
+
id: "opt-nc-agences",
|
|
45
|
+
country: "NC",
|
|
46
|
+
publisher: "Office des postes et télécommunications de Nouvelle-Calédonie",
|
|
47
|
+
attribution: "OPT-NC, Localisation des agences OPT-NC, via data.gouv.nc",
|
|
48
|
+
license: "etalab-2.0",
|
|
49
|
+
registerSource: "nc-postal-1",
|
|
50
|
+
provenance: StructureProvenance.PostalOperator,
|
|
51
|
+
fetchCommand: FETCH_COMMAND,
|
|
52
|
+
async read(sourcesRoot) {
|
|
53
|
+
const directory = sourcesRoot(NC_OPT_AGENCES_ADAPTER_ID);
|
|
54
|
+
const manifest = await readManifest(directory("MANIFEST.json"));
|
|
55
|
+
if (!manifest?.downloaded_at) {
|
|
56
|
+
throw new Error(`${directory} holds no MANIFEST.json with a fetch date. Run \`${FETCH_COMMAND}\` first.`);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
vintage: (manifest.publisher_version ?? manifest.downloaded_at).slice(0, 10),
|
|
60
|
+
records: records(directory(NC_OPT_AGENCES_FILENAME)),
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=opt-nc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opt-nc.js","sourceRoot":"","sources":["../../../lib/nc/structures/opt-nc.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAclE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,EACN,yBAAy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
|
5
|
+
* The dataset record `localisation-des-agences-opt-nc` on `data.gouv.nc` states the publisher
|
|
6
|
+
* and the license, and its `references` point at OPT-NC's open-data GIS.
|
|
7
|
+
* That GIS serves the features from FeatureServer `Agences_opendata` layer 0.
|
|
8
|
+
*
|
|
9
|
+
* The service itself states no license (`copyrightText` and the hub item's `licenseInfo` are empty),
|
|
10
|
+
* so the record is saved beside the features as `dataset.json`.
|
|
11
|
+
*
|
|
12
|
+
* The layer is paged by `OBJECTID` with `pageArcGISLayer`, and a pull whose size
|
|
13
|
+
* differs from the count the service stated is refused.
|
|
14
|
+
*
|
|
15
|
+
* Invoke via `mailwoman corpus fetch nc-opt-agences`.
|
|
16
|
+
*/
|
|
17
|
+
import { APIClient } from "@mailwoman/core/api";
|
|
18
|
+
import { type PathBuilderLike } from "path-ts";
|
|
19
|
+
import { type OPTNCAgencyFeature } from "#nc/adapters/opt-nc/adapter";
|
|
20
|
+
import type { BaseFetchOptions, FetchSummary, SourceManifest } from "#tools/fetch/download";
|
|
21
|
+
/**
|
|
22
|
+
* The FeatureServer that serves the agencies.
|
|
23
|
+
*/
|
|
24
|
+
export declare const OPT_NC_SERVICE_URL = "https://services6.arcgis.com/k3ZIRnRpeM4Ht4fG/arcgis/rest/services/Agences_opendata/FeatureServer";
|
|
25
|
+
/**
|
|
26
|
+
* The dataset record on `data.gouv.nc`, which states the publisher and the license.
|
|
27
|
+
*/
|
|
28
|
+
export declare const OPT_NC_DATASET_URL = "https://data.gouv.nc/api/explore/v2.1/catalog/datasets/localisation-des-agences-opt-nc";
|
|
29
|
+
/**
|
|
30
|
+
* The service's `maxRecordCount`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const OPT_NC_PAGE_SIZE = 1000;
|
|
33
|
+
/**
|
|
34
|
+
* The service fields the fetcher asks for, in the service's spelling.
|
|
35
|
+
*/
|
|
36
|
+
export declare const OPT_NC_FIELDS: readonly ["OBJECTID", "ID", "TEXTE", "TYPE", "NOM", "ADRESSE", "CODE_POSTAL", "VILLE", "GLOBALID"];
|
|
37
|
+
/**
|
|
38
|
+
* The file the dataset record is saved to, beside the features.
|
|
39
|
+
*/
|
|
40
|
+
export declare const OPT_NC_DATASET_FILENAME = "dataset.json";
|
|
41
|
+
/**
|
|
42
|
+
* What one run recorded.
|
|
43
|
+
* `publisher_version` is the dataset record's `modified`.
|
|
44
|
+
*/
|
|
45
|
+
export interface OPTNCAgencesManifest extends SourceManifest {
|
|
46
|
+
service_url: string;
|
|
47
|
+
dataset_url: string;
|
|
48
|
+
feature_count: number;
|
|
49
|
+
license: string | null;
|
|
50
|
+
license_url: string | null;
|
|
51
|
+
publisher: string | null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* One service feature in the shape the adapter reads.
|
|
55
|
+
*
|
|
56
|
+
* @throws When the value isn't a GeoJSON feature, or has no `OBJECTID`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function normalizeOPTNCFeature(value: unknown): OPTNCAgencyFeature;
|
|
59
|
+
export interface DownloadOPTNCAgencesOptions {
|
|
60
|
+
outputDir: PathBuilderLike;
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
report?: (line: string) => void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Pages the layer into `<outputDir>/agences.geojsonl` and writes the dataset record and the manifest.
|
|
66
|
+
*
|
|
67
|
+
* @throws When the service answers an error, or a pull whose size differs from its count.
|
|
68
|
+
*/
|
|
69
|
+
export declare function downloadOPTNCAgences(client: Pick<APIClient, "fetch">, options: DownloadOPTNCAgencesOptions): Promise<FetchSummary>;
|
|
70
|
+
/**
|
|
71
|
+
* The path `#nc/adapters/opt-nc/adapter` reads, given the root a fetch wrote under.
|
|
72
|
+
*/
|
|
73
|
+
export declare function optNCAgencesInputPath(outRoot: BaseFetchOptions["outRoot"]): PathBuilderLike;
|
|
74
|
+
export interface FetchOPTNCAgencesOptions extends BaseFetchOptions {
|
|
75
|
+
signal?: AbortSignal;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The registry entry.
|
|
79
|
+
*/
|
|
80
|
+
export declare function fetchOPTNCAgences(options: FetchOPTNCAgencesOptions, report?: (line: string) => void): Promise<FetchSummary>;
|
|
81
|
+
//# sourceMappingURL=opt-nc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opt-nc.d.ts","sourceRoot":"","sources":["../../../../lib/nc/tools/fetch/opt-nc.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAe/C,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAG3F;;GAEG;AACH,eAAO,MAAM,kBAAkB,sGACqE,CAAA;AAEpG;;GAEG;AACH,eAAO,MAAM,kBAAkB,2FAC0D,CAAA;AAEzF;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,aAAa,YACzB,UAAU,EACV,IAAI,EACJ,OAAO,EACP,MAAM,EACN,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,UAAU,CACD,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,uBAAuB,iBAAiB,CAAA;AAWrD;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC3D,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CA4BxE;AAED,MAAM,WAAW,2BAA2B;IAC3C,SAAS,EAAE,eAAe,CAAA;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,YAAY,CAAC,CAuEvB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,GAAG,eAAe,CAE3F;AAED,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IACjE,MAAM,CAAC,EAAE,WAAW,CAAA;CACpB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,wBAAwB,EACjC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,YAAY,CAAC,CAKvB"}
|
|
@@ -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
|
+
* Fetches OPT-NC's agencies, the source of the `nc-opt-agences` adapter
|
|
5
|
+
* and New Caledonia's post offices in the structures layer.
|
|
6
|
+
*
|
|
7
|
+
* The dataset record `localisation-des-agences-opt-nc` on `data.gouv.nc` states the publisher
|
|
8
|
+
* and the license, and its `references` point at OPT-NC's open-data GIS.
|
|
9
|
+
* That GIS serves the features from FeatureServer `Agences_opendata` layer 0.
|
|
10
|
+
*
|
|
11
|
+
* The service itself states no license (`copyrightText` and the hub item's `licenseInfo` are empty),
|
|
12
|
+
* so the record is saved beside the features as `dataset.json`.
|
|
13
|
+
*
|
|
14
|
+
* The layer is paged by `OBJECTID` with `pageArcGISLayer`, and a pull whose size
|
|
15
|
+
* differs from the count the service stated is refused.
|
|
16
|
+
*
|
|
17
|
+
* Invoke via `mailwoman corpus fetch nc-opt-agences`.
|
|
18
|
+
*/
|
|
19
|
+
import { APIClient } from "@mailwoman/core/api";
|
|
20
|
+
import { arcGISFields, arcGISInteger, arcGISText, pageArcGISLayer } from "@mailwoman/core/api/arcgis";
|
|
21
|
+
import { ByteFormatter } from "@mailwoman/core/fs/formatters";
|
|
22
|
+
import { statPath } from "@mailwoman/core/fs/readers/stat";
|
|
23
|
+
import { appendLocalTextFile, makeDirectories, movePath, removePathIfPresent, stagingSiblingPath, writeLocalJSONFile, } from "@mailwoman/core/fs/writers";
|
|
24
|
+
import { sha256File } from "@mailwoman/core/hash";
|
|
25
|
+
import { stringifyJSON } from "@mailwoman/core/json";
|
|
26
|
+
import { readPointCoordinates } from "@mailwoman/spatial/geometries/point/coordinates";
|
|
27
|
+
import { PathBuilder } from "path-ts";
|
|
28
|
+
import { NC_OPT_AGENCES_ADAPTER_ID, NC_OPT_AGENCES_FILENAME, } from "#nc/adapters/opt-nc/adapter";
|
|
29
|
+
import { writeManifest } from "#tools/fetch/download";
|
|
30
|
+
/**
|
|
31
|
+
* The FeatureServer that serves the agencies.
|
|
32
|
+
*/
|
|
33
|
+
export const OPT_NC_SERVICE_URL = "https://services6.arcgis.com/k3ZIRnRpeM4Ht4fG/arcgis/rest/services/Agences_opendata/FeatureServer";
|
|
34
|
+
/**
|
|
35
|
+
* The dataset record on `data.gouv.nc`, which states the publisher and the license.
|
|
36
|
+
*/
|
|
37
|
+
export const OPT_NC_DATASET_URL = "https://data.gouv.nc/api/explore/v2.1/catalog/datasets/localisation-des-agences-opt-nc";
|
|
38
|
+
/**
|
|
39
|
+
* The service's `maxRecordCount`.
|
|
40
|
+
*/
|
|
41
|
+
export const OPT_NC_PAGE_SIZE = 1000;
|
|
42
|
+
/**
|
|
43
|
+
* The service fields the fetcher asks for, in the service's spelling.
|
|
44
|
+
*/
|
|
45
|
+
export const OPT_NC_FIELDS = [
|
|
46
|
+
"OBJECTID",
|
|
47
|
+
"ID",
|
|
48
|
+
"TEXTE",
|
|
49
|
+
"TYPE",
|
|
50
|
+
"NOM",
|
|
51
|
+
"ADRESSE",
|
|
52
|
+
"CODE_POSTAL",
|
|
53
|
+
"VILLE",
|
|
54
|
+
"GLOBALID",
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* The file the dataset record is saved to, beside the features.
|
|
58
|
+
*/
|
|
59
|
+
export const OPT_NC_DATASET_FILENAME = "dataset.json";
|
|
60
|
+
const SLUG = NC_OPT_AGENCES_ADAPTER_ID;
|
|
61
|
+
/**
|
|
62
|
+
* One service feature in the shape the adapter reads.
|
|
63
|
+
*
|
|
64
|
+
* @throws When the value isn't a GeoJSON feature, or has no `OBJECTID`.
|
|
65
|
+
*/
|
|
66
|
+
export function normalizeOPTNCFeature(value) {
|
|
67
|
+
if (value == null || typeof value !== "object" || value.type !== "Feature") {
|
|
68
|
+
throw new Error(`${SLUG}: expected a GeoJSON Feature, got ${String(stringifyJSON(value)).slice(0, 200)}`);
|
|
69
|
+
}
|
|
70
|
+
const feature = value;
|
|
71
|
+
const properties = arcGISFields(feature.properties);
|
|
72
|
+
const objectid = arcGISInteger(properties["objectid"]);
|
|
73
|
+
if (objectid === null)
|
|
74
|
+
throw new Error(`${SLUG}: the layer answered a feature with no OBJECTID`);
|
|
75
|
+
const point = readPointCoordinates(feature.geometry);
|
|
76
|
+
return {
|
|
77
|
+
type: "Feature",
|
|
78
|
+
geometry: point ? { type: "Point", coordinates: [point[0], point[1]] } : null,
|
|
79
|
+
properties: {
|
|
80
|
+
objectid,
|
|
81
|
+
id: arcGISInteger(properties["id"]),
|
|
82
|
+
texte: arcGISText(properties["texte"]),
|
|
83
|
+
type: arcGISText(properties["type"]),
|
|
84
|
+
nom: arcGISText(properties["nom"]),
|
|
85
|
+
adresse: arcGISText(properties["adresse"]),
|
|
86
|
+
code_postal: arcGISText(properties["code_postal"]),
|
|
87
|
+
ville: arcGISText(properties["ville"]),
|
|
88
|
+
globalid: arcGISText(properties["globalid"]),
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Pages the layer into `<outputDir>/agences.geojsonl` and writes the dataset record and the manifest.
|
|
94
|
+
*
|
|
95
|
+
* @throws When the service answers an error, or a pull whose size differs from its count.
|
|
96
|
+
*/
|
|
97
|
+
export async function downloadOPTNCAgences(client, options) {
|
|
98
|
+
const { report, signal } = options;
|
|
99
|
+
const destDir = PathBuilder.from(options.outputDir);
|
|
100
|
+
const featuresPath = destDir(NC_OPT_AGENCES_FILENAME);
|
|
101
|
+
report?.(`=== ${SLUG} / ${NC_OPT_AGENCES_FILENAME}`);
|
|
102
|
+
const { data: dataset } = await client.fetch({ url: OPT_NC_DATASET_URL, signal });
|
|
103
|
+
const metas = dataset?.metas?.default ?? {};
|
|
104
|
+
report?.(` ${metas.publisher ?? "no publisher"}; license ${metas.license ?? "absent"}; modified ${metas.modified ?? "unstated"}`);
|
|
105
|
+
await makeDirectories(destDir);
|
|
106
|
+
const staging = stagingSiblingPath(featuresPath);
|
|
107
|
+
let written = 0;
|
|
108
|
+
try {
|
|
109
|
+
await appendLocalTextFile("", staging);
|
|
110
|
+
const pages = pageArcGISLayer(client, { serviceURL: OPT_NC_SERVICE_URL, layerID: 0 }, {
|
|
111
|
+
outFields: OPT_NC_FIELDS,
|
|
112
|
+
pageSize: OPT_NC_PAGE_SIZE,
|
|
113
|
+
context: SLUG,
|
|
114
|
+
signal,
|
|
115
|
+
onCount: (count) => report?.(` ${count.toLocaleString()} features`),
|
|
116
|
+
});
|
|
117
|
+
for await (const page of pages) {
|
|
118
|
+
const features = page.map(normalizeOPTNCFeature);
|
|
119
|
+
await appendLocalTextFile(`${features.map((feature) => stringifyJSON(feature)).join("\n")}\n`, staging);
|
|
120
|
+
written += features.length;
|
|
121
|
+
}
|
|
122
|
+
await movePath(staging, featuresPath);
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
await removePathIfPresent(staging);
|
|
126
|
+
}
|
|
127
|
+
await writeLocalJSONFile((dataset ?? {}), destDir(OPT_NC_DATASET_FILENAME));
|
|
128
|
+
const sha256 = await sha256File(featuresPath);
|
|
129
|
+
const { size: bytes } = await statPath(featuresPath);
|
|
130
|
+
const manifest = {
|
|
131
|
+
source_url: OPT_NC_SERVICE_URL,
|
|
132
|
+
service_url: OPT_NC_SERVICE_URL,
|
|
133
|
+
dataset_url: OPT_NC_DATASET_URL,
|
|
134
|
+
filename: NC_OPT_AGENCES_FILENAME,
|
|
135
|
+
feature_count: written,
|
|
136
|
+
license: metas.license ?? null,
|
|
137
|
+
license_url: metas.license_url ?? null,
|
|
138
|
+
publisher: metas.publisher ?? null,
|
|
139
|
+
bytes,
|
|
140
|
+
sha256,
|
|
141
|
+
...(metas.modified ? { publisher_version: metas.modified } : {}),
|
|
142
|
+
downloaded_at: new Date().toISOString(),
|
|
143
|
+
};
|
|
144
|
+
await writeManifest(destDir("MANIFEST.json"), manifest);
|
|
145
|
+
report?.(` ✓ ${written.toLocaleString()} features, ${ByteFormatter.formatIEC(bytes)} sha256=${sha256}`);
|
|
146
|
+
return { fetched: 1, skipped: 0, failed: 0, failedCodes: [] };
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The path `#nc/adapters/opt-nc/adapter` reads, given the root a fetch wrote under.
|
|
150
|
+
*/
|
|
151
|
+
export function optNCAgencesInputPath(outRoot) {
|
|
152
|
+
return outRoot(SLUG, NC_OPT_AGENCES_FILENAME);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The registry entry.
|
|
156
|
+
*/
|
|
157
|
+
export async function fetchOPTNCAgences(options, report) {
|
|
158
|
+
await using client = new APIClient({ displayName: SLUG, retry: true, minRequestIntervalMs: 500 });
|
|
159
|
+
// Awaited rather than returned: `await using` disposes the client when this scope exits.
|
|
160
|
+
return await downloadOPTNCAgences(client, { outputDir: options.outRoot(SLUG), signal: options.signal, report });
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=opt-nc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opt-nc.js","sourceRoot":"","sources":["../../../../lib/nc/tools/fetch/opt-nc.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,QAAQ,EACR,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,GAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA;AACtF,OAAO,EAAE,WAAW,EAAwB,MAAM,SAAS,CAAA;AAE3D,OAAO,EACN,yBAAyB,EACzB,uBAAuB,GAEvB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAC9B,mGAAmG,CAAA;AAEpG;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAC9B,wFAAwF,CAAA;AAEzF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAEpC;;GAEG;AACH,MAAM,CA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AAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAChH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry id for this adapter, stamped into every row it emits, and the evaluation source's id.
|
|
3
|
+
*/
|
|
4
|
+
export declare const NZ_CHARITIES_REGISTER_ADAPTER_ID = "nz-charities-register";
|
|
5
|
+
/**
|
|
6
|
+
* The registered `nz-charities-register` adapter.
|
|
7
|
+
*/
|
|
8
|
+
export declare const nzCharitiesRegisterAdapter: import("#types").CorpusAdapter;
|
|
9
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../lib/nz/adapters/charities-register/adapter.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,eAAO,MAAM,gCAAgC,0BAA0B,CAAA;AAEvE;;GAEG;AACH,eAAO,MAAM,0BAA0B,gCASrC,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
/**
|
|
4
|
+
* `nz-charities-register`: New Zealand's Charities Register as a corpus source.
|
|
5
|
+
*
|
|
6
|
+
* The adapter reads the OData answer `organisations.csv` through {@linkcode readNZCharities},
|
|
7
|
+
* the reader the evaluation source of the same id calls, and renders each charity's
|
|
8
|
+
* street line, suburb, city and postcode.
|
|
9
|
+
* The fetch selects no name, officer or email column, so no row can join an address to
|
|
10
|
+
* a person, though a small charity's street address can be an officer's home.
|
|
11
|
+
*
|
|
12
|
+
* A post-office box and a second line that isn't the city yield no row.
|
|
13
|
+
*
|
|
14
|
+
* CC BY 3.0 NZ grants the right to `create one or more Adaptations` (`data/licenses/nz-charities-cc-by-3.0-nz.md`).
|
|
15
|
+
*/
|
|
16
|
+
import { createEvaluationCorpusAdapter } from "#evaluation/corpus-adapter";
|
|
17
|
+
import { nzCharitiesRegisterSource, readNZCharities } from "#nz/evaluation/charities-register";
|
|
18
|
+
import { SourceRegister } from "#registers";
|
|
19
|
+
import { AddressRole } from "#types";
|
|
20
|
+
/**
|
|
21
|
+
* Registry id for this adapter, stamped into every row it emits, and the evaluation source's id.
|
|
22
|
+
*/
|
|
23
|
+
export const NZ_CHARITIES_REGISTER_ADAPTER_ID = "nz-charities-register";
|
|
24
|
+
/**
|
|
25
|
+
* The registered `nz-charities-register` adapter.
|
|
26
|
+
*/
|
|
27
|
+
export const nzCharitiesRegisterAdapter = createEvaluationCorpusAdapter({
|
|
28
|
+
id: NZ_CHARITIES_REGISTER_ADAPTER_ID,
|
|
29
|
+
source: nzCharitiesRegisterSource,
|
|
30
|
+
register: SourceRegister.NZCharitiesRegister,
|
|
31
|
+
locale: "en-NZ",
|
|
32
|
+
addressRole: AddressRole.RegisteredOffice,
|
|
33
|
+
description: "Charities Services' Charities Register (CC BY 3.0 NZ): each registered charity's street address, without its name.",
|
|
34
|
+
read: readNZCharities,
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../lib/nz/adapters/charities-register/adapter.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,uBAAuB,CAAA;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,6BAA6B,CAAC;IACvE,EAAE,EAAE,gCAAgC;IACpC,MAAM,EAAE,yBAAyB;IACjC,QAAQ,EAAE,cAAc,CAAC,mBAAmB;IAC5C,MAAM,EAAE,OAAO;IACf,WAAW,EAAE,WAAW,CAAC,gBAAgB;IACzC,WAAW,EACV,oHAAoH;IACrH,IAAI,EAAE,eAAe;CACrB,CAAC,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nz-charities-register`: the Charities Register that Charities Services
|
|
3
|
+
* (Te Tari Taiwhenua, the Department of Internal Affairs) publishes through its
|
|
4
|
+
* OData service, read by the evaluation source and by the `nz-charities-register`
|
|
5
|
+
* corpus adapter through {@linkcode readNZCharities}.
|
|
6
|
+
*
|
|
7
|
+
* The fetch asks `vOrganisations` for every registered charity's street address:
|
|
8
|
+
* two lines, a suburb, a city and a postcode.
|
|
9
|
+
* The second line can repeat the city or the city and postcode, and otherwise
|
|
10
|
+
* holds a rural delivery code (`RD 3`) or a second address.
|
|
11
|
+
*
|
|
12
|
+
* A record is kept only where the second line is empty or repeats the city,
|
|
13
|
+
* and the first line is a street with a house number.
|
|
14
|
+
*
|
|
15
|
+
* The rows read only the address, never the charity's name, because a small
|
|
16
|
+
* charity's name can be a person's.
|
|
17
|
+
*
|
|
18
|
+
* The register states no region.
|
|
19
|
+
* NZ Post's postcodes run north to south by their first digit, so the record is stratified by that digit.
|
|
20
|
+
*
|
|
21
|
+
* ## License
|
|
22
|
+
*
|
|
23
|
+
* The open-data page (`https://www.charities.govt.nz/charities-in-new-zealand/the-charities-register/open-data`)
|
|
24
|
+
* states « Use of this data is licensed under a Creative Commons Attribution 3.0 New Zealand
|
|
25
|
+
* License. » CC BY 3.0 NZ grants the right to « create one or more Adaptations », provided
|
|
26
|
+
* each identifies that changes were made (`data/licenses/nz-charities-cc-by-3.0-nz.md`).
|
|
27
|
+
*/
|
|
28
|
+
import type { PathBuilderLike } from "path-ts";
|
|
29
|
+
import { type EvaluationRecordReading, type EvaluationSource } from "#evaluation/source";
|
|
30
|
+
/**
|
|
31
|
+
* The OData query: every registered charity's street address columns, as CSV, unpaged.
|
|
32
|
+
*/
|
|
33
|
+
export declare const NZ_CHARITIES_REGISTER_URL: string;
|
|
34
|
+
/**
|
|
35
|
+
* The file the fetch writes the query's CSV answer to and the reader reads.
|
|
36
|
+
*/
|
|
37
|
+
export declare const NZ_CHARITIES_REGISTER_FILENAME = "organisations.csv";
|
|
38
|
+
interface CharityRow {
|
|
39
|
+
charity_registration_number?: string;
|
|
40
|
+
street_address_line1?: string;
|
|
41
|
+
street_address_line2?: string;
|
|
42
|
+
street_address_suburb?: string;
|
|
43
|
+
street_address_city?: string;
|
|
44
|
+
street_address_postcode?: string;
|
|
45
|
+
street_address_country?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* One register row as an address record, or the reason it yields none.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readNZCharity(row: CharityRow): EvaluationRecordReading;
|
|
51
|
+
/**
|
|
52
|
+
* New Zealand's evaluation source, the Charities Register.
|
|
53
|
+
*/
|
|
54
|
+
export declare const nzCharitiesRegisterSource: EvaluationSource;
|
|
55
|
+
/**
|
|
56
|
+
* Every row of the OData CSV answer at `path`, read by {@linkcode readNZCharity}.
|
|
57
|
+
*/
|
|
58
|
+
export declare function readNZCharities(path: PathBuilderLike): AsyncGenerator<EvaluationRecordReading>;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=charities-register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charities-register.d.ts","sourceRoot":"","sources":["../../../lib/nz/evaluation/charities-register.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAKrB,MAAM,oBAAoB,CAAA;AAE3B;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAGqC,CAAA;AAE3E;;GAEG;AACH,eAAO,MAAM,8BAA8B,sBAAsB,CAAA;AAEjE,UAAU,UAAU;IACnB,2BAA2B,CAAC,EAAE,MAAM,CAAA;IACpC,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAQD;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,uBAAuB,CAwCtE;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,gBAmBvC,CAAA;AAED;;GAEG;AACH,wBAAuB,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAAC,uBAAuB,CAAC,CAIrG"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
import { CSVSpliterator } from "spliterator";
|
|
4
|
+
import { evaluationSourceRead, evaluationStreetLine, fetchEvaluationFile, readEvaluationFetch, } from "#evaluation/source";
|
|
5
|
+
/**
|
|
6
|
+
* The OData query: every registered charity's street address columns, as CSV, unpaged.
|
|
7
|
+
*/
|
|
8
|
+
export const NZ_CHARITIES_REGISTER_URL = "http://www.odata.charities.govt.nz/vOrganisations?$filter=RegistrationStatus%20eq%20%27Registered%27&$returnall=true" +
|
|
9
|
+
"&$select=OrganisationId,CharityRegistrationNumber,StreetAddressLine1,StreetAddressLine2,StreetAddressSuburb," +
|
|
10
|
+
"StreetAddressCity,StreetAddressPostcode,StreetAddressCountry&$format=csv";
|
|
11
|
+
/**
|
|
12
|
+
* The file the fetch writes the query's CSV answer to and the reader reads.
|
|
13
|
+
*/
|
|
14
|
+
export const NZ_CHARITIES_REGISTER_FILENAME = "organisations.csv";
|
|
15
|
+
function value(text) {
|
|
16
|
+
return (text ?? "").replaceAll(/\s+/gu, " ").trim();
|
|
17
|
+
}
|
|
18
|
+
const sameText = (a, b) => a.localeCompare(b, "en", { sensitivity: "base" }) === 0;
|
|
19
|
+
/**
|
|
20
|
+
* One register row as an address record, or the reason it yields none.
|
|
21
|
+
*/
|
|
22
|
+
export function readNZCharity(row) {
|
|
23
|
+
const id = value(row.charity_registration_number);
|
|
24
|
+
const city = value(row.street_address_city);
|
|
25
|
+
const suburb = value(row.street_address_suburb);
|
|
26
|
+
const postcode = value(row.street_address_postcode);
|
|
27
|
+
const line = value(row.street_address_line1);
|
|
28
|
+
const second = value(row.street_address_line2);
|
|
29
|
+
const country = value(row.street_address_country);
|
|
30
|
+
if (!id)
|
|
31
|
+
return { refused: "row:identifier-absent" };
|
|
32
|
+
if (!line)
|
|
33
|
+
return { refused: "row:address-absent" };
|
|
34
|
+
if (country && !sameText(country, "New Zealand"))
|
|
35
|
+
return { refused: "row:overseas" };
|
|
36
|
+
if (!/^\d{4}$/u.test(postcode))
|
|
37
|
+
return { refused: "row:postcode-absent" };
|
|
38
|
+
if (!city)
|
|
39
|
+
return { refused: "row:locality-absent" };
|
|
40
|
+
if (second && !sameText(second, city) && !sameText(second, `${city} ${postcode}`) && !sameText(second, suburb)) {
|
|
41
|
+
return { refused: "row:several-lines" };
|
|
42
|
+
}
|
|
43
|
+
if (/\b(?:p\.?\s?o\.?\s*box|private bag)\b/iu.test(line))
|
|
44
|
+
return { refused: "row:post-box" };
|
|
45
|
+
const street = evaluationStreetLine(line, "NZ");
|
|
46
|
+
if ("refused" in street)
|
|
47
|
+
return street;
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
stratum: `postcode ${postcode[0]}`,
|
|
51
|
+
components: {
|
|
52
|
+
house_number: street.house_number,
|
|
53
|
+
street: street.street,
|
|
54
|
+
...(suburb && !sameText(suburb, city) ? { dependent_locality: suburb } : {}),
|
|
55
|
+
locality: city,
|
|
56
|
+
postcode,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* New Zealand's evaluation source, the Charities Register.
|
|
62
|
+
*/
|
|
63
|
+
export const nzCharitiesRegisterSource = {
|
|
64
|
+
id: "nz-charities-register",
|
|
65
|
+
country: "NZ",
|
|
66
|
+
publisher: "Charities Services, Department of Internal Affairs",
|
|
67
|
+
attribution: "Charities Services (Department of Internal Affairs), Charities Register open data, CC BY 3.0 NZ",
|
|
68
|
+
license: "Creative Commons Attribution 3.0 New Zealand",
|
|
69
|
+
registerSource: "nz-charity-nonprofit-1",
|
|
70
|
+
fetch: (directory, report) => fetchEvaluationFile(directory, NZ_CHARITIES_REGISTER_URL, NZ_CHARITIES_REGISTER_FILENAME, report),
|
|
71
|
+
async read(directory) {
|
|
72
|
+
const fetched = await readEvaluationFetch(directory);
|
|
73
|
+
return evaluationSourceRead(`fetched ${fetched.downloaded_at.slice(0, 10)}`, readNZCharities(directory(NZ_CHARITIES_REGISTER_FILENAME)));
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Every row of the OData CSV answer at `path`, read by {@linkcode readNZCharity}.
|
|
78
|
+
*/
|
|
79
|
+
export async function* readNZCharities(path) {
|
|
80
|
+
for await (const row of CSVSpliterator.fromAsync(path, { normalizeKeys: true })) {
|
|
81
|
+
yield readNZCharity(row);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=charities-register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charities-register.js","sourceRoot":"","sources":["../../../lib/nz/evaluation/charities-register.ts"],"names":[],"mappings":"AAAA,kEAAkE;AA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AI;YACd,QAAQ;SACR;KACD,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IAC1D,EAAE,EAAE,uBAAuB;IAC3B,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,oDAAoD;IAC/D,WAAW,EAAE,iGAAiG;IAC9G,OAAO,EAAE,8CAA8C;IACvD,cAAc,EAAE,wBAAwB;IAExC,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAC5B,mBAAmB,CAAC,SAAS,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,CAAC;IAElG,KAAK,CAAC,IAAI,CAAC,SAAsB;QAChC,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAA;QAEpD,OAAO,oBAAoB,CAC1B,WAAW,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAC/C,eAAe,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC,CAC1D,CAAA;IACF,CAAC;CACD,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,eAAe,CAAC,IAAqB;IAC3D,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,cAAc,CAAC,SAAS,CAAa,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC7F,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;AACF,CAAC"}
|
|
@@ -19,10 +19,11 @@ export declare function findMissingPostcodeSources<P extends PathBuilderLike>(pa
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function renderBarePostcode(country: string, postcode: string): string[];
|
|
21
21
|
/**
|
|
22
|
-
* Whether `
|
|
22
|
+
* Whether the `postal` family reads this surface as a postcode across its whole span.
|
|
23
23
|
*
|
|
24
24
|
* A surface the detector doesn't recognize would train the model on a string
|
|
25
25
|
* the query-shape prior cannot then support.
|
|
26
|
+
* The recipe holds no model card, so it reads the `postal` generation.
|
|
26
27
|
*/
|
|
27
28
|
export declare function detectedAsPostcode(surface: string): boolean;
|
|
28
29
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcode.d.ts","sourceRoot":"","sources":["../../../lib/recipes/bare/postcode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postcode.d.ts","sourceRoot":"","sources":["../../../lib/recipes/bare/postcode.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,EAAiB,KAAK,YAAY,EAAkC,MAAM,mBAAmB,CAAA;AAuFpG;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAM9F;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAAC,CAAC,SAAS,eAAe,EACzE,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,GAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAc,GAChD,OAAO,CAAC,CAAC,EAAE,CAAC,CAId;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAM9E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI3D;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,YA8JhC,CAAA"}
|
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* `bare-postcode` — a postcode without another address component, in the country's format.
|
|
5
5
|
*
|
|
6
|
-
* Every surface the recipe renders is run through `
|
|
7
|
-
* detector calls it a postcode, so the rendering table
|
|
6
|
+
* Every surface the recipe renders is run through `computeQueryShape`
|
|
7
|
+
* and refused unless the detector calls it a postcode, so the rendering table
|
|
8
|
+
* and the legacy-formats table of `@mailwoman/postcode` must agree.
|
|
8
9
|
*/
|
|
9
10
|
import { isNLPostcodeKey } from "@mailwoman/codex/nl";
|
|
10
11
|
import { currentSourcePath } from "@mailwoman/core/data-root";
|
|
11
12
|
import { pathExists } from "@mailwoman/core/fs/readers/stat";
|
|
13
|
+
import { isPostcodeFormat } from "@mailwoman/core/pipeline/types";
|
|
12
14
|
import { SeededRandom } from "@mailwoman/core/utils";
|
|
13
15
|
import { compactPostcode } from "@mailwoman/postcode/display-form";
|
|
14
|
-
import { computeQueryShape } from "@mailwoman/query-shape";
|
|
15
|
-
import {
|
|
16
|
+
import { computeQueryShape } from "@mailwoman/postcode/recognizer/query-shape";
|
|
17
|
+
import { QueryShapeGeneration } from "@mailwoman/postcode/recognizer/rule-generation";
|
|
16
18
|
import { normalizeGauntletSurface, readGauntletInputs } from "#gauntlet-inputs";
|
|
17
19
|
import { isReservedBarePostcode } from "#recipes/bare/postcode/eval";
|
|
18
20
|
import { alignAndWrite, readCSVRecords, recipeSourceID } from "#recipes/scaffold";
|
|
@@ -61,7 +63,7 @@ const SOURCES = [
|
|
|
61
63
|
*/
|
|
62
64
|
const WRITTEN_FORMS = new Map([
|
|
63
65
|
// `NNN NN`, written with the space.
|
|
64
|
-
// The four countries share the shape, so
|
|
66
|
+
// The four countries share the shape, so the postal family reports all four on one hit.
|
|
65
67
|
["CZ", { locale: "cs-CZ", render: spacedThree }],
|
|
66
68
|
["SK", { locale: "sk-SK", render: spacedThree }],
|
|
67
69
|
["SE", { locale: "sv-SE", render: spacedThree }],
|
|
@@ -119,13 +121,14 @@ export function renderBarePostcode(country, postcode) {
|
|
|
119
121
|
return form.render(compactPostcode(postcode));
|
|
120
122
|
}
|
|
121
123
|
/**
|
|
122
|
-
* Whether `
|
|
124
|
+
* Whether the `postal` family reads this surface as a postcode across its whole span.
|
|
123
125
|
*
|
|
124
126
|
* A surface the detector doesn't recognize would train the model on a string
|
|
125
127
|
* the query-shape prior cannot then support.
|
|
128
|
+
* The recipe holds no model card, so it reads the `postal` generation.
|
|
126
129
|
*/
|
|
127
130
|
export function detectedAsPostcode(surface) {
|
|
128
|
-
return computeQueryShape(surface).knownFormats.some((hit) => isPostcodeFormat(hit.format) && hit.span.start === 0 && hit.span.end === surface.length);
|
|
131
|
+
return computeQueryShape(surface, QueryShapeGeneration.Postal).knownFormats.some((hit) => isPostcodeFormat(hit.format) && hit.span.start === 0 && hit.span.end === surface.length);
|
|
129
132
|
}
|
|
130
133
|
/**
|
|
131
134
|
* Recipe registered with the corpus builder.
|
|
@@ -206,7 +209,7 @@ export const barePostcodeRecipe = {
|
|
|
206
209
|
if (perCountry.get(country) >= budget)
|
|
207
210
|
break;
|
|
208
211
|
// A surface the detector doesn't read as a postcode is a disagreement
|
|
209
|
-
// between this table and
|
|
212
|
+
// between this table and the legacy-formats table.
|
|
210
213
|
if (!detectedAsPostcode(surface)) {
|
|
211
214
|
unrecognized++;
|
|
212
215
|
continue;
|
|
@@ -235,10 +238,10 @@ export const barePostcodeRecipe = {
|
|
|
235
238
|
}
|
|
236
239
|
}
|
|
237
240
|
// A rendered surface the detector refuses is an interface failure: every form here is
|
|
238
|
-
// one
|
|
241
|
+
// one the postal family declares a syntax for, so the count is expected to be zero.
|
|
239
242
|
if (unrecognized > 0) {
|
|
240
|
-
throw new Error(`${unrecognized} rendered surfaces were not read as a postcode by
|
|
241
|
-
"WRITTEN_FORMS table and
|
|
243
|
+
throw new Error(`${unrecognized} rendered surfaces were not read as a postcode by computeQueryShape — the ` +
|
|
244
|
+
"WRITTEN_FORMS table and the postal family of @mailwoman/postcode disagree. Reconcile them before building.");
|
|
242
245
|
}
|
|
243
246
|
// An empty build is a failure rather than an empty answer: the required
|
|
244
247
|
// files were preflighted above, so zero rows means their postcode columns
|