@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,234 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Fetches La Poste's list of its points of contact, the dataset `laposte-poincont2`
|
|
6
|
+
* (« Liste des bureaux de poste, agences postales et relais poste ») on `data.laposte.fr`,
|
|
7
|
+
* the source of the `fr-laposte-poincont` adapter and the French post offices of the structures layer.
|
|
8
|
+
*
|
|
9
|
+
* The portal is a data-fair instance.
|
|
10
|
+
* The dataset record at `/data-fair/api/v1/datasets/laposte-poincont2` states the
|
|
11
|
+
* license (`Licence Ouverte / Open Licence`), the record count and `dataUpdatedAt`.
|
|
12
|
+
*
|
|
13
|
+
* The rows are paged from `/lines` at 10,000 per request, following each answer's `next` link.
|
|
14
|
+
*
|
|
15
|
+
* The record is saved beside the rows as `dataset.json`, because it holds the publisher's
|
|
16
|
+
* license statement and the update date Licence Ouverte asks a reuser to cite.
|
|
17
|
+
* A pull whose row count differs from the record's `count` is refused, and the previous file stays.
|
|
18
|
+
*
|
|
19
|
+
* Invoke via `mailwoman corpus fetch fr-laposte-poincont`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { APIClient } from "@mailwoman/core/api"
|
|
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 { PathBuilder, type PathBuilderLike } from "path-ts"
|
|
36
|
+
|
|
37
|
+
import {
|
|
38
|
+
FR_LAPOSTE_POINCONT_ADAPTER_ID,
|
|
39
|
+
LAPOSTE_POINCONT_FIELDS,
|
|
40
|
+
LAPOSTE_POINCONT_FILENAME,
|
|
41
|
+
} from "#fr/adapters/laposte-poincont/adapter"
|
|
42
|
+
import type { BaseFetchOptions, FetchSummary, SourceManifest } from "#tools/fetch/download"
|
|
43
|
+
import { writeManifest } from "#tools/fetch/download"
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The dataset's data-fair API root.
|
|
47
|
+
*/
|
|
48
|
+
export const LAPOSTE_POINCONT_API_URL = "https://data.laposte.fr/data-fair/api/v1/datasets/laposte-poincont2"
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The dataset's page.
|
|
52
|
+
* It states the license.
|
|
53
|
+
*/
|
|
54
|
+
export const LAPOSTE_POINCONT_PAGE_URL = "https://data.laposte.fr/datasets/laposte-poincont2"
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The most rows one `/lines` request answers.
|
|
58
|
+
*/
|
|
59
|
+
export const LAPOSTE_POINCONT_PAGE_SIZE = 10_000
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The file the dataset record is saved to, beside the rows.
|
|
63
|
+
*/
|
|
64
|
+
export const LAPOSTE_POINCONT_DATASET_FILENAME = "dataset.json"
|
|
65
|
+
|
|
66
|
+
const SLUG = FR_LAPOSTE_POINCONT_ADAPTER_ID
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The parts of the data-fair dataset record a fetch reads.
|
|
70
|
+
*/
|
|
71
|
+
export interface DataFairDatasetRecord {
|
|
72
|
+
title?: string
|
|
73
|
+
count?: number
|
|
74
|
+
dataUpdatedAt?: string
|
|
75
|
+
updatedAt?: string
|
|
76
|
+
origin?: string
|
|
77
|
+
license?: { title?: string; href?: string }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* One `/lines` answer.
|
|
82
|
+
*/
|
|
83
|
+
interface DataFairLines {
|
|
84
|
+
total?: number
|
|
85
|
+
next?: string
|
|
86
|
+
results?: Array<Record<string, unknown>>
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* What one run recorded.
|
|
91
|
+
*
|
|
92
|
+
* `publisher_version` is the record's `dataUpdatedAt`, the date Licence Ouverte asks a reuser to cite.
|
|
93
|
+
*/
|
|
94
|
+
export interface LaPostePoincontManifest extends SourceManifest {
|
|
95
|
+
dataset_url: string
|
|
96
|
+
records: number
|
|
97
|
+
license_title: string | null
|
|
98
|
+
license_url: string | null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The first `/lines` URL, selecting the fields the adapter reads.
|
|
103
|
+
*/
|
|
104
|
+
export function laPostePoincontLinesURL(): string {
|
|
105
|
+
const select = encodeURIComponent(LAPOSTE_POINCONT_FIELDS.join(","))
|
|
106
|
+
|
|
107
|
+
return `${LAPOSTE_POINCONT_API_URL}/lines?size=${LAPOSTE_POINCONT_PAGE_SIZE}&select=${select}`
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* One `/lines` row with only the fields the adapter reads, in their declared order,
|
|
112
|
+
* a field the row lacks written as `null`.
|
|
113
|
+
*/
|
|
114
|
+
export function selectLaPosteFields(row: Readonly<Record<string, unknown>>): Record<string, unknown> {
|
|
115
|
+
return Object.fromEntries(LAPOSTE_POINCONT_FIELDS.map((field) => [field, row[field] ?? null]))
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface DownloadLaPostePoincontOptions {
|
|
119
|
+
outputDir: PathBuilderLike
|
|
120
|
+
signal?: AbortSignal
|
|
121
|
+
report?: (line: string) => void
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Pages every row into `<outputDir>/laposte-poincont2.jsonl` and writes the manifest.
|
|
126
|
+
*
|
|
127
|
+
* @throws When the record states no count, a page answers no `results`,
|
|
128
|
+
* or the rows written differ from the record's count.
|
|
129
|
+
*/
|
|
130
|
+
export async function downloadLaPostePoincont(
|
|
131
|
+
client: Pick<APIClient, "fetch">,
|
|
132
|
+
options: DownloadLaPostePoincontOptions
|
|
133
|
+
): Promise<FetchSummary> {
|
|
134
|
+
const { report, signal } = options
|
|
135
|
+
const destDir = PathBuilder.from(options.outputDir)
|
|
136
|
+
const rowsPath = destDir(LAPOSTE_POINCONT_FILENAME)
|
|
137
|
+
|
|
138
|
+
report?.(`=== ${SLUG} / ${LAPOSTE_POINCONT_FILENAME}`)
|
|
139
|
+
|
|
140
|
+
const { data: dataset } = await client.fetch<DataFairDatasetRecord>({ url: LAPOSTE_POINCONT_API_URL, signal })
|
|
141
|
+
|
|
142
|
+
if (typeof dataset?.count !== "number") {
|
|
143
|
+
throw new TypeError(`${SLUG}: ${LAPOSTE_POINCONT_API_URL} states no count`)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
report?.(
|
|
147
|
+
` ${dataset.count.toLocaleString()} rows, license ${dataset.license?.title ?? "absent"}, data updated ${dataset.dataUpdatedAt ?? "unstated"}`
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
await makeDirectories(destDir)
|
|
151
|
+
|
|
152
|
+
const staging = stagingSiblingPath(rowsPath)
|
|
153
|
+
let written = 0
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
await appendLocalTextFile("", staging)
|
|
157
|
+
|
|
158
|
+
let url: string | undefined = laPostePoincontLinesURL()
|
|
159
|
+
|
|
160
|
+
while (url) {
|
|
161
|
+
const { data: page }: { data: DataFairLines | null } = await client.fetch<DataFairLines>({ url, signal })
|
|
162
|
+
|
|
163
|
+
if (!Array.isArray(page?.results)) throw new TypeError(`${SLUG}: ${url} answered no results`)
|
|
164
|
+
|
|
165
|
+
if (!page.results.length) break
|
|
166
|
+
|
|
167
|
+
await appendLocalTextFile(
|
|
168
|
+
`${page.results.map((row) => stringifyJSON(selectLaPosteFields(row))).join("\n")}\n`,
|
|
169
|
+
staging
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
written += page.results.length
|
|
173
|
+
report?.(` ${written.toLocaleString()} / ${dataset.count.toLocaleString()}`)
|
|
174
|
+
|
|
175
|
+
url = page.next
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (written !== dataset.count) {
|
|
179
|
+
throw new Error(`${SLUG}: the record states ${dataset.count} rows and the pull wrote ${written}`)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
await movePath(staging, rowsPath)
|
|
183
|
+
} finally {
|
|
184
|
+
await removePathIfPresent(staging)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
await writeLocalJSONFile(dataset as Record<string, unknown>, destDir(LAPOSTE_POINCONT_DATASET_FILENAME))
|
|
188
|
+
|
|
189
|
+
const sha256 = await sha256File(rowsPath)
|
|
190
|
+
const { size: bytes } = await statPath(rowsPath)
|
|
191
|
+
|
|
192
|
+
const manifest: LaPostePoincontManifest = {
|
|
193
|
+
source_url: laPostePoincontLinesURL(),
|
|
194
|
+
dataset_url: LAPOSTE_POINCONT_API_URL,
|
|
195
|
+
filename: LAPOSTE_POINCONT_FILENAME,
|
|
196
|
+
records: written,
|
|
197
|
+
license_title: dataset.license?.title ?? null,
|
|
198
|
+
license_url: dataset.license?.href ?? null,
|
|
199
|
+
bytes,
|
|
200
|
+
sha256,
|
|
201
|
+
...(dataset.dataUpdatedAt ? { publisher_version: dataset.dataUpdatedAt } : {}),
|
|
202
|
+
downloaded_at: new Date().toISOString(),
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
await writeManifest(destDir("MANIFEST.json"), manifest)
|
|
206
|
+
|
|
207
|
+
report?.(` ✓ ${written.toLocaleString()} rows, ${ByteFormatter.formatIEC(bytes)} sha256=${sha256}`)
|
|
208
|
+
|
|
209
|
+
return { fetched: 1, skipped: 0, failed: 0, failedCodes: [] }
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The path `#fr/adapters/laposte-poincont/adapter` reads, given the root a fetch wrote under.
|
|
214
|
+
*/
|
|
215
|
+
export function laPostePoincontInputPath(outRoot: BaseFetchOptions["outRoot"]): PathBuilderLike {
|
|
216
|
+
return outRoot(SLUG, LAPOSTE_POINCONT_FILENAME)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface FetchLaPostePoincontOptions extends BaseFetchOptions {
|
|
220
|
+
signal?: AbortSignal
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The registry entry.
|
|
225
|
+
*/
|
|
226
|
+
export async function fetchLaPostePoincont(
|
|
227
|
+
options: FetchLaPostePoincontOptions,
|
|
228
|
+
report?: (line: string) => void
|
|
229
|
+
): Promise<FetchSummary> {
|
|
230
|
+
await using client = new APIClient({ displayName: SLUG, retry: true, minRequestIntervalMs: 500 })
|
|
231
|
+
|
|
232
|
+
// Awaited rather than returned: `await using` disposes the client when this scope exits.
|
|
233
|
+
return await downloadLaPostePoincont(client, { outputDir: options.outRoot(SLUG), signal: options.signal, report })
|
|
234
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `it-miur-scuole`: the education ministry's register of state schools as a corpus source.
|
|
6
|
+
*
|
|
7
|
+
* The adapter reads the register CSV through {@linkcode readMIURSchools}, the reader
|
|
8
|
+
* the evaluation source of the same id calls, and renders each school site's street,
|
|
9
|
+
* house number, postcode and comune in the ministry's capitals.
|
|
10
|
+
* The school's name is never read into a row.
|
|
11
|
+
* A street line without a house number yields no row.
|
|
12
|
+
*
|
|
13
|
+
* IODL 2.0 grants `estrarre e reimpiegare le Informazioni` and `creare un Lavoro derivato`,
|
|
14
|
+
* on condition of naming the source and the provider (`data/licenses/it-miur-iodl-2.0.md`).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createEvaluationCorpusAdapter } from "#evaluation/corpus-adapter"
|
|
18
|
+
import { itMIURScuoleSource, readMIURSchools } from "#it/evaluation/miur-scuole"
|
|
19
|
+
import { SourceRegister } from "#registers"
|
|
20
|
+
import { AddressRole } from "#types"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Registry id for this adapter, stamped into every row it emits, and the evaluation source's id.
|
|
24
|
+
*/
|
|
25
|
+
export const IT_MIUR_SCUOLE_ADAPTER_ID = "it-miur-scuole"
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The registered `it-miur-scuole` adapter.
|
|
29
|
+
*/
|
|
30
|
+
export const itMIURScuoleAdapter = createEvaluationCorpusAdapter({
|
|
31
|
+
id: IT_MIUR_SCUOLE_ADAPTER_ID,
|
|
32
|
+
source: itMIURScuoleSource,
|
|
33
|
+
register: SourceRegister.MIURScuole,
|
|
34
|
+
locale: "it-IT",
|
|
35
|
+
addressRole: AddressRole.Facility,
|
|
36
|
+
description:
|
|
37
|
+
"Ministero dell'Istruzione e del Merito's state-school register (IODL 2.0): each school site's street address, without its name.",
|
|
38
|
+
read: readMIURSchools,
|
|
39
|
+
})
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `it-miur-scuole`: the Ministero dell'Istruzione e del Merito's register of state schools
|
|
6
|
+
* (`Anagrafe scuole statali`, dataset `DS0400SCUANAGRAFESTAT` on dati.istruzione.it), read by the
|
|
7
|
+
* evaluation source and by the `it-miur-scuole` corpus adapter through {@linkcode readMIURSchools}.
|
|
8
|
+
*
|
|
9
|
+
* Each row is one school site with its region, province, street line (`INDIRIZZOSCUOLA`,
|
|
10
|
+
* `VIA COLLE DEI FRATI 5/5A`), postcode (`CAPSCUOLA`) and comune (`DESCRIZIONECOMUNE`).
|
|
11
|
+
* The ministry writes every value in capitals, and the rows keep them.
|
|
12
|
+
*
|
|
13
|
+
* The schools' addresses are the ministry's record of its own sites.
|
|
14
|
+
* A record holds the address and never the school's name.
|
|
15
|
+
*
|
|
16
|
+
* ## License
|
|
17
|
+
*
|
|
18
|
+
* The catalogue page states `License: IODL 2.0` for the dataset,
|
|
19
|
+
* linking `http://www.dati.gov.it/iodl/2.0/`.
|
|
20
|
+
* The license text (`https://www.dati.gov.it/content/italian-open-data-license-v20`) grants the
|
|
21
|
+
* right to « estrarre e reimpiegare le Informazioni » and to « creare un Lavoro derivato »,
|
|
22
|
+
* which it defines as « ogni traduzione, adattamento, trasformazione, diversa disposizione
|
|
23
|
+
* ed ogni altra modifica delle Informazioni » (`data/licenses/it-miur-iodl-2.0.md`).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { PathBuilder, PathBuilderLike } from "path-ts"
|
|
27
|
+
import { CSVSpliterator } from "spliterator"
|
|
28
|
+
|
|
29
|
+
import {
|
|
30
|
+
type EvaluationRecordReading,
|
|
31
|
+
type EvaluationSource,
|
|
32
|
+
evaluationSourceRead,
|
|
33
|
+
evaluationStreetLine,
|
|
34
|
+
fetchEvaluationFile,
|
|
35
|
+
readEvaluationFetch,
|
|
36
|
+
} from "#evaluation/source"
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The register's file for school year 2026/27, as of 2026-09-01.
|
|
40
|
+
*/
|
|
41
|
+
export const IT_MIUR_SCUOLE_URL =
|
|
42
|
+
"https://dati.istruzione.it/opendata/opendata/catalogo/elements1/SCUANAGRAFESTAT20262720260901.csv"
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The file the fetch writes and the reader reads, under the publisher's own name.
|
|
46
|
+
*/
|
|
47
|
+
export const IT_MIUR_SCUOLE_FILENAME = "SCUANAGRAFESTAT20262720260901.csv"
|
|
48
|
+
|
|
49
|
+
interface MIURSchoolRow {
|
|
50
|
+
annoscolastico?: string
|
|
51
|
+
regione?: string
|
|
52
|
+
codicescuola?: string
|
|
53
|
+
indirizzoscuola?: string
|
|
54
|
+
capscuola?: string
|
|
55
|
+
descrizionecomune?: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The register's placeholder for an absent value.
|
|
60
|
+
*/
|
|
61
|
+
const NOT_AVAILABLE = /^non disponibile$/iu
|
|
62
|
+
|
|
63
|
+
function value(text: string | undefined): string {
|
|
64
|
+
const trimmed = (text ?? "").replaceAll(/\s+/gu, " ").trim()
|
|
65
|
+
|
|
66
|
+
return NOT_AVAILABLE.test(trimmed) ? "" : trimmed
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* One register row as an address record, or the reason it yields none.
|
|
71
|
+
*/
|
|
72
|
+
export function readMIURSchool(row: MIURSchoolRow): EvaluationRecordReading {
|
|
73
|
+
const id = value(row.codicescuola)
|
|
74
|
+
const postcode = value(row.capscuola)
|
|
75
|
+
const locality = value(row.descrizionecomune)
|
|
76
|
+
const region = value(row.regione)
|
|
77
|
+
|
|
78
|
+
if (!id) return { refused: "row:identifier-absent" }
|
|
79
|
+
|
|
80
|
+
if (!/^\d{5}$/u.test(postcode)) return { refused: "row:postcode-absent" }
|
|
81
|
+
|
|
82
|
+
if (!locality) return { refused: "row:locality-absent" }
|
|
83
|
+
|
|
84
|
+
const street = evaluationStreetLine(value(row.indirizzoscuola), "IT")
|
|
85
|
+
|
|
86
|
+
if ("refused" in street) return street
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
id,
|
|
90
|
+
stratum: region || "unstated",
|
|
91
|
+
components: { street: street.street, house_number: street.house_number, postcode, locality },
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Italy's evaluation source, the state-school register.
|
|
97
|
+
*/
|
|
98
|
+
export const itMIURScuoleSource: EvaluationSource = {
|
|
99
|
+
id: "it-miur-scuole",
|
|
100
|
+
country: "IT",
|
|
101
|
+
publisher: "Ministero dell'Istruzione e del Merito",
|
|
102
|
+
attribution: "Ministero dell'Istruzione e del Merito, Anagrafe scuole statali, dati.istruzione.it, IODL 2.0",
|
|
103
|
+
license: "Italian Open Data License 2.0",
|
|
104
|
+
registerSource: "it-education-1",
|
|
105
|
+
|
|
106
|
+
fetch: (directory, report) => fetchEvaluationFile(directory, IT_MIUR_SCUOLE_URL, IT_MIUR_SCUOLE_FILENAME, report),
|
|
107
|
+
|
|
108
|
+
async read(directory: PathBuilder) {
|
|
109
|
+
const fetched = await readEvaluationFetch(directory)
|
|
110
|
+
|
|
111
|
+
return evaluationSourceRead(
|
|
112
|
+
`2026/27 (fetched ${fetched.downloaded_at.slice(0, 10)})`,
|
|
113
|
+
readMIURSchools(directory(IT_MIUR_SCUOLE_FILENAME))
|
|
114
|
+
)
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Every row of the register CSV at `path`, read by {@linkcode readMIURSchool}.
|
|
120
|
+
*/
|
|
121
|
+
export async function* readMIURSchools(path: PathBuilderLike): AsyncGenerator<EvaluationRecordReading> {
|
|
122
|
+
for await (const row of CSVSpliterator.fromAsync<MIURSchoolRow>(path, { normalizeKeys: true })) {
|
|
123
|
+
yield readMIURSchool(row)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -61,11 +61,11 @@ interface PlaceRow {
|
|
|
61
61
|
*
|
|
62
62
|
* `resolve` is the override for a parent outside the preloaded set (a chain that leaves the country);
|
|
63
63
|
* it is a point query, so keeping the common case out of it is the whole point.
|
|
64
|
-
* The GeoJSON adapters'
|
|
65
|
-
*
|
|
64
|
+
* The GeoJSON adapters' analogue is `ancestorRecordsOf` (`#utils/wof-json`),
|
|
65
|
+
* which keeps the nearest ancestor per tag.
|
|
66
66
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
67
|
+
* This function receives one `PlaceRow` per level and reads the chain directly,
|
|
68
|
+
* because its rows come from SQLite and a chain can leave the preloaded country set.
|
|
69
69
|
*/
|
|
70
70
|
function chainOf(byID: Map<number, PlaceRow>, resolve: (id: number) => PlaceRow | null, startID: number): PlaceRow[] {
|
|
71
71
|
const out: PlaceRow[] = []
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `nc-opt-agences`: the agencies of the Office des postes et télécommunications de
|
|
6
|
+
* Nouvelle-Calédonie (OPT-NC), New Caledonia's postal operator.
|
|
7
|
+
*
|
|
8
|
+
* OPT-NC publishes the list as the dataset `localisation-des-agences-opt-nc`
|
|
9
|
+
* on `data.gouv.nc`, whose records are served by its open-data GIS, the ArcGIS
|
|
10
|
+
* FeatureServer `Agences_opendata` layer 0 (`Agences_et_Centres`).
|
|
11
|
+
* `mailwoman corpus fetch nc-opt-agences` writes one GeoJSON feature per line,
|
|
12
|
+
* with the service's field names in lower case.
|
|
13
|
+
*
|
|
14
|
+
* Each feature holds a type (`Agence`, `Annexe`, …), the agency's name (`KONE`), the label
|
|
15
|
+
* the service shows for it (`Agence de KONE`), a street line, a postcode, a town and a point.
|
|
16
|
+
*
|
|
17
|
+
* ## The row
|
|
18
|
+
*
|
|
19
|
+
* The venue is the service's label (`TEXTE`), the form OPT-NC shows the public (`Agence de KONE`).
|
|
20
|
+
* The address is the street line, postcode and town.
|
|
21
|
+
*
|
|
22
|
+
* A street line is read by `readAnnuaireLine`, the French line reader the Annuaire de
|
|
23
|
+
* l'éducation adapter uses on New Caledonia's schools: `23 AVENUE DE KONIAMBO` is a number,
|
|
24
|
+
* a street-type word and a name, and `QANONO - VILLAGE DE WE` holds no number
|
|
25
|
+
* and no street-type word, so it is a place and becomes `dependent_locality`.
|
|
26
|
+
*
|
|
27
|
+
* ## License
|
|
28
|
+
*
|
|
29
|
+
* The dataset's record on `data.gouv.nc` names OPT-NC as publisher and states
|
|
30
|
+
* `Licence Ouverte v2.0` (`https://www.etalab.gouv.fr/wp-content/uploads/2017/04/ETALAB-Licence-Ouverte-v2.0.pdf`).
|
|
31
|
+
* Licence Ouverte 2.0 lets the reuser « l'adapter, la modifier, l'extraire et la transformer »,
|
|
32
|
+
* subject to naming the source and the date of its last update.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import { formatAddressRow } from "@mailwoman/codex/address/format"
|
|
36
|
+
import { JSONSpliterator } from "spliterator"
|
|
37
|
+
|
|
38
|
+
import { UnsupportedCountryError } from "#adapters/errors"
|
|
39
|
+
import { readAnnuaireLine } from "#fr/adapters/annuaire-education/adapter"
|
|
40
|
+
import { isSamePlace } from "#fr/adapters/finess/postal-lines"
|
|
41
|
+
import { SourceRegister } from "#registers"
|
|
42
|
+
import {
|
|
43
|
+
AddressRole,
|
|
44
|
+
type AdapterOptions,
|
|
45
|
+
type CanonicalRow,
|
|
46
|
+
countDropped,
|
|
47
|
+
type CorpusAdapter,
|
|
48
|
+
SurfaceOrigin,
|
|
49
|
+
} from "#types"
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Registry id for this adapter, and the source directory its fetcher writes.
|
|
53
|
+
*/
|
|
54
|
+
export const NC_OPT_AGENCES_ADAPTER_ID = "nc-opt-agences"
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The license the publisher's dataset record states.
|
|
58
|
+
*/
|
|
59
|
+
export const NC_OPT_AGENCES_LICENSE = "Licence Ouverte 2.0"
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The credit Licence Ouverte 2.0 requires: the licensor's name, beside the date of the data's last update.
|
|
63
|
+
*/
|
|
64
|
+
export const NC_OPT_AGENCES_ATTRIBUTION =
|
|
65
|
+
"Office des postes et télécommunications de Nouvelle-Calédonie (OPT-NC), Localisation des agences OPT-NC, via data.gouv.nc"
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The file the fetcher writes and the adapter reads, one GeoJSON feature per line.
|
|
69
|
+
*/
|
|
70
|
+
export const NC_OPT_AGENCES_FILENAME = "agences.geojsonl"
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The properties of one agency as the fetcher writes them: the service's fields in
|
|
74
|
+
* lower case, a field the service left empty written as `null`.
|
|
75
|
+
*/
|
|
76
|
+
export interface OPTNCAgencyProperties {
|
|
77
|
+
objectid: number
|
|
78
|
+
id: number | null
|
|
79
|
+
texte: string | null
|
|
80
|
+
type: string | null
|
|
81
|
+
nom: string | null
|
|
82
|
+
adresse: string | null
|
|
83
|
+
code_postal: string | null
|
|
84
|
+
ville: string | null
|
|
85
|
+
globalid: string | null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* One agency as the fetcher writes it.
|
|
90
|
+
*/
|
|
91
|
+
export interface OPTNCAgencyFeature {
|
|
92
|
+
type: "Feature"
|
|
93
|
+
geometry: { type: "Point"; coordinates: [longitude: number, latitude: number] } | null
|
|
94
|
+
properties: OPTNCAgencyProperties
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Why a feature yielded no row.
|
|
99
|
+
*/
|
|
100
|
+
export const OPTNCRefusal = {
|
|
101
|
+
IdentifierAbsent: "row:identifier-absent",
|
|
102
|
+
NameAbsent: "row:name-absent",
|
|
103
|
+
/**
|
|
104
|
+
* `code_postal` isn't New Caledonia's five digits beginning `988`.
|
|
105
|
+
*/
|
|
106
|
+
PostcodeAbsent: "row:postcode-absent",
|
|
107
|
+
LocalityAbsent: "row:locality-absent",
|
|
108
|
+
StreetLineAbsent: "row:street-line-absent",
|
|
109
|
+
/**
|
|
110
|
+
* The street line holds a digit the line reader cannot place, or a street-type word with no name.
|
|
111
|
+
*/
|
|
112
|
+
StreetLineUnread: "row:street-line-unread",
|
|
113
|
+
Unrenderable: "row:unrenderable",
|
|
114
|
+
} as const
|
|
115
|
+
|
|
116
|
+
export type OPTNCRefusal = (typeof OPTNCRefusal)[keyof typeof OPTNCRefusal]
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* An agency's address as labeled components, or the reason it has none.
|
|
120
|
+
*/
|
|
121
|
+
export function readOPTNCAddress(
|
|
122
|
+
properties: Pick<OPTNCAgencyProperties, "adresse" | "code_postal" | "ville">
|
|
123
|
+
): { readonly components: CanonicalRow["components"] } | { readonly refused: OPTNCRefusal } {
|
|
124
|
+
const postcode = properties.code_postal?.trim() ?? ""
|
|
125
|
+
const locality = properties.ville?.trim() ?? ""
|
|
126
|
+
const line = properties.adresse?.replaceAll(/\s+/gu, " ").trim() ?? ""
|
|
127
|
+
|
|
128
|
+
if (!/^988\d{2}$/u.test(postcode)) return { refused: OPTNCRefusal.PostcodeAbsent }
|
|
129
|
+
|
|
130
|
+
if (!locality) return { refused: OPTNCRefusal.LocalityAbsent }
|
|
131
|
+
|
|
132
|
+
if (!line) return { refused: OPTNCRefusal.StreetLineAbsent }
|
|
133
|
+
|
|
134
|
+
const reading = readAnnuaireLine(line)
|
|
135
|
+
const components: CanonicalRow["components"] = {}
|
|
136
|
+
|
|
137
|
+
switch (reading.kind) {
|
|
138
|
+
case "street":
|
|
139
|
+
if (reading.house_number) {
|
|
140
|
+
components.house_number = reading.house_number
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (reading.street_prefix) {
|
|
144
|
+
components.street_prefix = reading.street_prefix
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
components.street = reading.street
|
|
148
|
+
break
|
|
149
|
+
case "place":
|
|
150
|
+
// A place line that only repeats the town would label the same words twice.
|
|
151
|
+
if (isSamePlace(reading.place, locality)) return { refused: OPTNCRefusal.StreetLineAbsent }
|
|
152
|
+
|
|
153
|
+
components.dependent_locality = reading.place
|
|
154
|
+
break
|
|
155
|
+
default:
|
|
156
|
+
return { refused: OPTNCRefusal.StreetLineUnread }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return { components: { ...components, postcode, locality } }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Read one feature into a corpus row, or report why it yielded none.
|
|
164
|
+
*/
|
|
165
|
+
export function readOPTNCAgency(feature: OPTNCAgencyFeature): { admitted: CanonicalRow } | { refused: OPTNCRefusal } {
|
|
166
|
+
const { properties } = feature
|
|
167
|
+
const id = properties.globalid ?? (properties.id == null ? null : String(properties.id))
|
|
168
|
+
|
|
169
|
+
if (!id) return { refused: OPTNCRefusal.IdentifierAbsent }
|
|
170
|
+
|
|
171
|
+
const name = properties.texte?.trim() || properties.nom?.trim()
|
|
172
|
+
|
|
173
|
+
if (!name) return { refused: OPTNCRefusal.NameAbsent }
|
|
174
|
+
|
|
175
|
+
const address = readOPTNCAddress(properties)
|
|
176
|
+
|
|
177
|
+
if ("refused" in address) return address
|
|
178
|
+
|
|
179
|
+
// `venue` first, so alignment claims its span before `locality` searches for its own.
|
|
180
|
+
const rendered = formatAddressRow({ venue: name, ...address.components }, "NC", { singleLine: true })
|
|
181
|
+
|
|
182
|
+
if (!rendered || rendered.unplaced.length) return { refused: OPTNCRefusal.Unrenderable }
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
admitted: {
|
|
186
|
+
raw: rendered.raw,
|
|
187
|
+
components: rendered.components,
|
|
188
|
+
country: "NC",
|
|
189
|
+
locale: "fr-NC",
|
|
190
|
+
source: NC_OPT_AGENCES_ADAPTER_ID,
|
|
191
|
+
source_id: `${NC_OPT_AGENCES_ADAPTER_ID}-${id}`,
|
|
192
|
+
license: NC_OPT_AGENCES_LICENSE,
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function createOPTNCAgencesAdapter(): CorpusAdapter {
|
|
198
|
+
return {
|
|
199
|
+
id: NC_OPT_AGENCES_ADAPTER_ID,
|
|
200
|
+
defaultLicense: NC_OPT_AGENCES_LICENSE,
|
|
201
|
+
addressRole: AddressRole.Facility,
|
|
202
|
+
register: SourceRegister.OPTNCAgences,
|
|
203
|
+
surface: SurfaceOrigin.Rendered,
|
|
204
|
+
description: "OPT-NC's agencies (Licence Ouverte 2.0): New Caledonia's post offices beside their addresses.",
|
|
205
|
+
|
|
206
|
+
async *rows(opts: AdapterOptions): AsyncIterable<CanonicalRow> {
|
|
207
|
+
if (opts.country && opts.country !== "NC") {
|
|
208
|
+
throw new UnsupportedCountryError(NC_OPT_AGENCES_ADAPTER_ID, ["NC"], opts.country)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let emitted = 0
|
|
212
|
+
|
|
213
|
+
for await (const feature of JSONSpliterator.fromAsync<OPTNCAgencyFeature>(opts.inputPath)) {
|
|
214
|
+
if (opts.signal?.aborted) break
|
|
215
|
+
|
|
216
|
+
if (typeof opts.limit === "number" && emitted >= opts.limit) break
|
|
217
|
+
|
|
218
|
+
const reading = readOPTNCAgency(feature)
|
|
219
|
+
|
|
220
|
+
if ("refused" in reading) {
|
|
221
|
+
countDropped(opts, reading.refused)
|
|
222
|
+
|
|
223
|
+
continue
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
yield reading.admitted
|
|
227
|
+
|
|
228
|
+
emitted++
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The configured adapter instance registered with the corpus builder.
|
|
236
|
+
*/
|
|
237
|
+
export const optNCAgencesAdapter = createOPTNCAgencesAdapter()
|