@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
|
@@ -15,6 +15,7 @@ import { basename, type PathBuilderLike, resolvePath } from "path-ts"
|
|
|
15
15
|
|
|
16
16
|
import { openCorpusRowStream } from "#parquet/corpus-rows"
|
|
17
17
|
import type { DuckDBLimits } from "#parquet/duckdb"
|
|
18
|
+
import { parquetColumnNames } from "#parquet/readers"
|
|
18
19
|
import type { ParquetRow } from "#parquet/schema"
|
|
19
20
|
import {
|
|
20
21
|
SPLIT_ATTRIBUTE,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
import type { CanonicalRow } from "#types"
|
|
26
27
|
import type { SplitRetention } from "#utils/retention"
|
|
27
28
|
import { type CountryHoldout, defaultHoldouts, HOLDOUT_COMPONENT_TAGS, type SplitName, splitForRow } from "#utils/split"
|
|
29
|
+
import { type EvaluationGroupPolicy, evaluationGroupPolicyIdentity } from "#utils/validation-groups"
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* The fields {@linkcode holdoutComponents} reads, with the span triple optional
|
|
@@ -91,6 +93,15 @@ export interface SplitSliceOptions {
|
|
|
91
93
|
* Covered by the policy hash.
|
|
92
94
|
*/
|
|
93
95
|
retention?: SplitRetention
|
|
96
|
+
/**
|
|
97
|
+
* The frozen and validation group lists.
|
|
98
|
+
*
|
|
99
|
+
* A caller that passes them selects the evaluation-group policy
|
|
100
|
+
* (HOLDOUT_AND_EVALUATION section 4.6): the frozen groups' rows go to test,
|
|
101
|
+
* the validation groups' rows go to val, and every other row trains.
|
|
102
|
+
* Both lists' identities and the quota join the policy hash.
|
|
103
|
+
*/
|
|
104
|
+
evaluationGroups?: EvaluationGroupPolicy
|
|
94
105
|
/**
|
|
95
106
|
* The DuckDB instance's threads and memory, for a caller that splits several files at once.
|
|
96
107
|
* @defaultValue the shares `openDuckDB` gives an instance whose caller names none.
|
|
@@ -108,9 +119,13 @@ export interface SplitSliceOptions {
|
|
|
108
119
|
const SPLIT_COLUMNS = ["raw", "source_id", "country", "span_starts", "span_ends", "span_tags"] as const
|
|
109
120
|
|
|
110
121
|
/**
|
|
111
|
-
* A corpus row read through {@linkcode SPLIT_COLUMNS}.
|
|
122
|
+
* A corpus row read through {@linkcode SPLIT_COLUMNS}, with `base_source_id` when the file has the column.
|
|
123
|
+
*
|
|
124
|
+
* The evaluation-group policy keys on it.
|
|
125
|
+
* A file without the column records no derivation, so each row is its own group,
|
|
126
|
+
* as the overlap audit reads it.
|
|
112
127
|
*/
|
|
113
|
-
type SplitColumnRow = Pick<ParquetRow, (typeof SPLIT_COLUMNS)[number]>
|
|
128
|
+
type SplitColumnRow = Pick<ParquetRow, (typeof SPLIT_COLUMNS)[number]> & { base_source_id?: string | null }
|
|
114
129
|
|
|
115
130
|
export interface SplitSliceResult {
|
|
116
131
|
input: string
|
|
@@ -183,18 +198,31 @@ export async function splitOverlaySlice(options: SplitSliceOptions): Promise<Spl
|
|
|
183
198
|
const decided = new SplitDecisions()
|
|
184
199
|
const counts: Record<SplitName, number> = { train: 0, val: 0, test: 0 }
|
|
185
200
|
let index = 0
|
|
201
|
+
const { evaluationGroups } = options
|
|
202
|
+
|
|
203
|
+
const columns =
|
|
204
|
+
evaluationGroups && (await parquetColumnNames(input)).includes("base_source_id")
|
|
205
|
+
? [...SPLIT_COLUMNS, "base_source_id"]
|
|
206
|
+
: SPLIT_COLUMNS
|
|
186
207
|
|
|
187
208
|
for await (const row of openCorpusRowStream<SplitColumnRow>(input, {
|
|
188
|
-
columns
|
|
209
|
+
columns,
|
|
189
210
|
...(options.limits ? { limits: options.limits } : {}),
|
|
190
211
|
})) {
|
|
191
212
|
const components = holdoutComponents(row, index, input)
|
|
192
213
|
|
|
193
214
|
const split = splitForRow(
|
|
194
|
-
{
|
|
215
|
+
{
|
|
216
|
+
source_id: row.source_id,
|
|
217
|
+
base_source_id: row.base_source_id ?? null,
|
|
218
|
+
country: row.country,
|
|
219
|
+
components,
|
|
220
|
+
span_tags: row.span_tags,
|
|
221
|
+
},
|
|
195
222
|
holdouts,
|
|
196
223
|
undefined,
|
|
197
|
-
options.retention
|
|
224
|
+
options.retention,
|
|
225
|
+
evaluationGroups
|
|
198
226
|
)
|
|
199
227
|
|
|
200
228
|
const earlier = decided.get(row.source_id)
|
|
@@ -214,14 +242,15 @@ export async function splitOverlaySlice(options: SplitSliceOptions): Promise<Spl
|
|
|
214
242
|
index++
|
|
215
243
|
}
|
|
216
244
|
|
|
217
|
-
const
|
|
245
|
+
const groupsIdentity = evaluationGroups ? evaluationGroupPolicyIdentity(evaluationGroups) : undefined
|
|
246
|
+
const { policyHash, codeHash } = await splitPolicyHash(holdouts, options.retention, groupsIdentity)
|
|
218
247
|
|
|
219
248
|
const name = basename(input)
|
|
220
249
|
|
|
221
250
|
const attribute: SplitAttributeFile = {
|
|
222
251
|
attribute: SPLIT_ATTRIBUTE,
|
|
223
252
|
policyHash,
|
|
224
|
-
policy: { holdouts, codeHash },
|
|
253
|
+
policy: { holdouts, codeHash, ...(groupsIdentity ? { evaluationGroups: groupsIdentity } : {}) },
|
|
225
254
|
file: { name, sha256: await sha256File(input), rows: index },
|
|
226
255
|
counts,
|
|
227
256
|
val: decided.idsIn("val"),
|
|
@@ -243,7 +243,7 @@ export async function readTriplesFromParentJoin(
|
|
|
243
243
|
options: { postcodeDB?: PathBuilderLike; adminDB?: PathBuilderLike } = {}
|
|
244
244
|
): Promise<PostcodeTriple[]> {
|
|
245
245
|
const postcodeDB = options.postcodeDB ?? wofDatabasePath("postalcode-intl.db")
|
|
246
|
-
const adminDB = options.adminDB ?? wofDatabasePath("admin-global-priority
|
|
246
|
+
const adminDB = options.adminDB ?? wofDatabasePath("admin-global-priority.db")
|
|
247
247
|
|
|
248
248
|
await assertPathExists(postcodeDB, `readTriplesFromParentJoin: no postcode database at ${postcodeDB}`)
|
|
249
249
|
await assertPathExists(adminDB, `readTriplesFromParentJoin: no admin gazetteer at ${adminDB}`)
|
|
@@ -391,7 +391,7 @@ export async function readPairsFromAdmin(
|
|
|
391
391
|
countries: readonly string[],
|
|
392
392
|
options: { adminDB?: PathBuilderLike; locale?: (cc: string) => string } = {}
|
|
393
393
|
): Promise<AdminPair[]> {
|
|
394
|
-
const adminDB = options.adminDB ?? wofDatabasePath("admin-global-priority
|
|
394
|
+
const adminDB = options.adminDB ?? wofDatabasePath("admin-global-priority.db")
|
|
395
395
|
|
|
396
396
|
await assertPathExists(adminDB, `readPairsFromAdmin: no admin gazetteer at ${adminDB}`)
|
|
397
397
|
|
|
@@ -452,7 +452,7 @@ export async function createKnownLocalityCheck(
|
|
|
452
452
|
country: string,
|
|
453
453
|
adminDB?: PathBuilderLike
|
|
454
454
|
): Promise<(name: string) => boolean> {
|
|
455
|
-
const path = adminDB ?? wofDatabasePath("admin-global-priority
|
|
455
|
+
const path = adminDB ?? wofDatabasePath("admin-global-priority.db")
|
|
456
456
|
|
|
457
457
|
await assertPathExists(path, `createKnownLocalityCheck: no admin gazetteer at ${path}`)
|
|
458
458
|
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file Counts, for every country, a corpus's base rows with a region and those that write a second-level
|
|
6
|
+
* (WOF `county`) name in the region slot, and writes the counts to the table the `region:unknown` rule reads.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* node packages/corpus/lib/tools/region-slot-census.run.ts --manifest <MANIFEST.json> \
|
|
10
|
+
* --out <census.json> [--table packages/corpus/data/region-slot-second-level.json]
|
|
11
|
+
*
|
|
12
|
+
* A row counts as `secondLevelOnly` when its region is no region name of its country and is a county
|
|
13
|
+
* name of it. `--out` also lists each country's leading sources and values.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
|
|
17
|
+
import { writeLocalJSONFile } from "@mailwoman/core/fs/writers"
|
|
18
|
+
import { parseArguments, requiredArgument } from "@mailwoman/core/scripting/arguments"
|
|
19
|
+
import { wofDatabasePath } from "@mailwoman/resolver-wof-sqlite/paths"
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
readRegionNames,
|
|
23
|
+
readSecondLevelNames,
|
|
24
|
+
secondLevelAdmitted,
|
|
25
|
+
type SecondLevelRegionTable,
|
|
26
|
+
} from "#build/region-names"
|
|
27
|
+
import { escapeSQLString, openDuckDB } from "#parquet/duckdb"
|
|
28
|
+
import { parquetColumnNames } from "#parquet/readers"
|
|
29
|
+
import { localManifestFilePath } from "#tools/overlay/manifest"
|
|
30
|
+
|
|
31
|
+
const { values } = parseArguments({
|
|
32
|
+
options: {
|
|
33
|
+
manifest: { type: "string" },
|
|
34
|
+
out: { type: "string" },
|
|
35
|
+
table: { type: "string" },
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const command = "region-slot-census"
|
|
40
|
+
const manifestPath = requiredArgument(command, "--manifest", values.manifest)
|
|
41
|
+
const outPath = requiredArgument(command, "--out", values.out)
|
|
42
|
+
|
|
43
|
+
const REQUIRED_COLUMNS = ["raw", "country", "source", "span_starts", "span_ends", "span_tags"] as const
|
|
44
|
+
const TOP_VALUES = 15
|
|
45
|
+
|
|
46
|
+
interface CountryTally {
|
|
47
|
+
withRegion: number
|
|
48
|
+
region: number
|
|
49
|
+
secondLevelOnly: number
|
|
50
|
+
neither: number
|
|
51
|
+
secondLevelOnlyBySource: Map<string, number>
|
|
52
|
+
secondLevelOnlyValues: Map<string, number>
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const database = wofDatabasePath("admin-global-priority.db")
|
|
56
|
+
const regions = await readRegionNames(database)
|
|
57
|
+
const secondLevel = await readSecondLevelNames(database)
|
|
58
|
+
const manifest = await readLocalJSONFile<{ files: { path: string }[] }>(manifestPath)
|
|
59
|
+
const tallies = new Map<string, CountryTally>()
|
|
60
|
+
const unread: string[] = []
|
|
61
|
+
const started = Date.now()
|
|
62
|
+
let baseRows = 0
|
|
63
|
+
|
|
64
|
+
const increment = (map: Map<string, number>, key: string) => map.set(key, (map.get(key) ?? 0) + 1)
|
|
65
|
+
|
|
66
|
+
using db = await openDuckDB({ memoryLimitBytes: 2 * 1024 ** 3 })
|
|
67
|
+
|
|
68
|
+
for (const [index, file] of manifest.files.entries()) {
|
|
69
|
+
const path = localManifestFilePath(file.path)
|
|
70
|
+
const columns = new Set(await parquetColumnNames(path))
|
|
71
|
+
|
|
72
|
+
if (!REQUIRED_COLUMNS.every((column) => columns.has(column))) {
|
|
73
|
+
unread.push(path)
|
|
74
|
+
|
|
75
|
+
continue
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const baseColumn = ["base_source_id", "synth_base_id"].find((column) => columns.has(column))
|
|
79
|
+
|
|
80
|
+
const stream = await db.stream(
|
|
81
|
+
`SELECT ${REQUIRED_COLUMNS.join(", ")} FROM read_parquet('${escapeSQLString(path)}')` +
|
|
82
|
+
(baseColumn ? ` WHERE coalesce(${baseColumn}, '') = ''` : "")
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
const names = stream.columnNames()
|
|
86
|
+
|
|
87
|
+
for (let chunk = await stream.fetchChunk(); chunk && chunk.rowCount > 0; chunk = await stream.fetchChunk()) {
|
|
88
|
+
for (const row of chunk.getRowObjects(names)) {
|
|
89
|
+
baseRows++
|
|
90
|
+
|
|
91
|
+
// DuckDB returns a LIST column as `{ items }`; the span offsets index `raw`'s UTF-16 code units.
|
|
92
|
+
const at = (row.span_tags as { items: readonly string[] }).items.indexOf("region")
|
|
93
|
+
|
|
94
|
+
if (at === -1) continue
|
|
95
|
+
|
|
96
|
+
const raw = String(row.raw)
|
|
97
|
+
const start = (row.span_starts as { items: readonly (number | bigint)[] }).items[at]
|
|
98
|
+
const end = (row.span_ends as { items: readonly (number | bigint)[] }).items[at]
|
|
99
|
+
const value = start != null && end != null ? raw.slice(Number(start), Number(end)) : ""
|
|
100
|
+
const country = String(row.country ?? "").toUpperCase()
|
|
101
|
+
|
|
102
|
+
if (!value || !country) continue
|
|
103
|
+
|
|
104
|
+
let tally = tallies.get(country)
|
|
105
|
+
|
|
106
|
+
if (!tally) {
|
|
107
|
+
tally = {
|
|
108
|
+
withRegion: 0,
|
|
109
|
+
region: 0,
|
|
110
|
+
secondLevelOnly: 0,
|
|
111
|
+
neither: 0,
|
|
112
|
+
secondLevelOnlyBySource: new Map(),
|
|
113
|
+
secondLevelOnlyValues: new Map(),
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
tallies.set(country, tally)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
tally.withRegion++
|
|
120
|
+
|
|
121
|
+
if (regions.holds(country, value) !== false) {
|
|
122
|
+
tally.region++
|
|
123
|
+
} else if (secondLevel.holds(country, value)) {
|
|
124
|
+
tally.secondLevelOnly++
|
|
125
|
+
increment(tally.secondLevelOnlyBySource, String(row.source))
|
|
126
|
+
increment(tally.secondLevelOnlyValues, value)
|
|
127
|
+
} else {
|
|
128
|
+
tally.neither++
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if ((index + 1) % 50 === 0) {
|
|
134
|
+
console.log(`${index + 1}/${manifest.files.length} files, ${Math.round((Date.now() - started) / 1000)}s`)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const top = (map: Map<string, number>) =>
|
|
139
|
+
Object.fromEntries([...map].toSorted((a, b) => b[1] - a[1]).slice(0, TOP_VALUES))
|
|
140
|
+
|
|
141
|
+
const countries = [...tallies]
|
|
142
|
+
.map(([country, tally]) => ({
|
|
143
|
+
country,
|
|
144
|
+
withRegion: tally.withRegion,
|
|
145
|
+
region: tally.region,
|
|
146
|
+
secondLevelOnly: tally.secondLevelOnly,
|
|
147
|
+
neither: tally.neither,
|
|
148
|
+
secondLevelShare: tally.secondLevelOnly / tally.withRegion,
|
|
149
|
+
secondLevelOnlyBySource: top(tally.secondLevelOnlyBySource),
|
|
150
|
+
secondLevelOnlyValues: top(tally.secondLevelOnlyValues),
|
|
151
|
+
}))
|
|
152
|
+
.toSorted((a, b) => b.secondLevelShare - a.secondLevelShare)
|
|
153
|
+
|
|
154
|
+
const table: SecondLevelRegionTable = {
|
|
155
|
+
$description:
|
|
156
|
+
"Per country, the base rows with a region and those whose region is a second-level (WOF county) name " +
|
|
157
|
+
"of the country and no region name of it. Written by packages/corpus/lib/tools/region-slot-census.run.ts; " +
|
|
158
|
+
"secondLevelAdmitted in packages/corpus/lib/build/region-names.ts decides which countries the region:unknown rule admits.",
|
|
159
|
+
manifest: manifestPath,
|
|
160
|
+
countries: Object.fromEntries(
|
|
161
|
+
countries
|
|
162
|
+
.toSorted((a, b) => a.country.localeCompare(b.country))
|
|
163
|
+
.map((country) => [country.country, { withRegion: country.withRegion, secondLevelOnly: country.secondLevelOnly }])
|
|
164
|
+
),
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
await writeLocalJSONFile(
|
|
168
|
+
{
|
|
169
|
+
manifest: manifestPath,
|
|
170
|
+
database: database.toString(),
|
|
171
|
+
seconds: Math.round((Date.now() - started) / 1000),
|
|
172
|
+
baseRows,
|
|
173
|
+
unread,
|
|
174
|
+
admitted: secondLevelAdmitted(table),
|
|
175
|
+
countries,
|
|
176
|
+
},
|
|
177
|
+
outPath
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
if (values.table) {
|
|
181
|
+
await writeLocalJSONFile(table, values.table)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
console.log(`done: ${secondLevelAdmitted(table).length} admitted of ${countries.length} countries`)
|
|
@@ -324,6 +324,25 @@ function validateCorpusReceipts(receipts: readonly ConfigInstance[]): void {
|
|
|
324
324
|
throw new TrainingConfigError(ConfigErrorKind.Value, `receipt ${named} min_draws must be positive`)
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
const fraction = field(receipt, "min_fraction_of_expected")
|
|
328
|
+
|
|
329
|
+
if (fraction != null) {
|
|
330
|
+
if (typeof fraction !== "number" || !(fraction > 0 && fraction <= 1)) {
|
|
331
|
+
throw new TrainingConfigError(
|
|
332
|
+
ConfigErrorKind.Value,
|
|
333
|
+
`receipt ${named} min_fraction_of_expected must be a number in (0, 1], got ${pythonRepr(fraction)}`
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// The expectation is a source's share of the epoch, so a receipt pooled over sources has none.
|
|
338
|
+
if (field(receipt, "source") == null) {
|
|
339
|
+
throw new TrainingConfigError(
|
|
340
|
+
ConfigErrorKind.Value,
|
|
341
|
+
`receipt ${named} min_fraction_of_expected needs a source: the expected draws are that source's share`
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
327
346
|
const invalid = (field(receipt, "component_sequence") as string[]).filter(bareTagProblem)
|
|
328
347
|
|
|
329
348
|
if (invalid.length) {
|
|
@@ -102,12 +102,18 @@ const sectionList = <Fields extends Record<string, ConfigFieldSpec>>(element: Co
|
|
|
102
102
|
/**
|
|
103
103
|
* The Python CorpusReceiptConfig dataclass: a floor on the training draws that
|
|
104
104
|
* hold one source, country and component sequence.
|
|
105
|
+
*
|
|
106
|
+
* `min_draws` is an absolute floor.
|
|
107
|
+
* `min_fraction_of_expected` states a floor as a fraction of the draws the receipt's
|
|
108
|
+
* source share expects, so it follows the source's weight.
|
|
109
|
+
* The epoch-mixture audit applies the larger of the two.
|
|
105
110
|
*/
|
|
106
111
|
export const CORPUS_RECEIPT_SECTION = {
|
|
107
112
|
className: "CorpusReceiptConfig",
|
|
108
113
|
fields: {
|
|
109
114
|
name: str(""),
|
|
110
115
|
min_draws: int(1n),
|
|
116
|
+
min_fraction_of_expected: optionalFloat(),
|
|
111
117
|
source: optionalStr(),
|
|
112
118
|
country: optionalStr(),
|
|
113
119
|
component_sequence: strList(),
|
package/lib/tw/registers.ts
CHANGED
|
@@ -34,9 +34,20 @@ export const TW_BOARD_BUCKET_MIN = 90
|
|
|
34
34
|
|
|
35
35
|
const DIGITS = "0-90-9"
|
|
36
36
|
const SUB = `(?:之|[--─‐−])[${DIGITS}]+`
|
|
37
|
-
const NUMBER = new RegExp(`^(?<number>[${DIGITS}]+(?:${SUB})*(?:附[${DIGITS}]+)?號(?:${SUB})?)(?<rest>.*)$`, "u")
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
/**
|
|
39
|
+
* A house number with its sub-numbers and 號 at the head of a string (`120號`, `64之3號`),
|
|
40
|
+
* with the remainder in `rest`.
|
|
41
|
+
*/
|
|
42
|
+
export const TW_HOUSE_NUMBER = new RegExp(
|
|
43
|
+
`^(?<number>[${DIGITS}]+(?:${SUB})*(?:附[${DIGITS}]+)?號(?:${SUB})?)(?<rest>.*)$`,
|
|
44
|
+
"u"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A floor written after a house number: `1樓`, `B1`, `地下室`, optionally in parentheses.
|
|
49
|
+
*/
|
|
50
|
+
export const TW_FLOOR = new RegExp(
|
|
40
51
|
`^[((]?(?:(?:地下|B|B)?[${DIGITS}一二三四五六七八九十]+(?:樓|層|F|F)(?:之[${DIGITS}]+)?|地下室|頂樓)[))]?$`,
|
|
41
52
|
"u"
|
|
42
53
|
)
|
|
@@ -227,7 +238,7 @@ export function alignRegisterAddress(text: string, index: TWKeyIndex): TWAligned
|
|
|
227
238
|
|
|
228
239
|
take(street, "street")
|
|
229
240
|
|
|
230
|
-
const match =
|
|
241
|
+
const match = TW_HOUSE_NUMBER.exec(characters.slice(at).join(""))
|
|
231
242
|
|
|
232
243
|
if (!match) return null
|
|
233
244
|
|
|
@@ -236,7 +247,7 @@ export function alignRegisterAddress(text: string, index: TWKeyIndex): TWAligned
|
|
|
236
247
|
const rest = match.groups!["rest"]!
|
|
237
248
|
|
|
238
249
|
if (rest) {
|
|
239
|
-
if (!
|
|
250
|
+
if (!TW_FLOOR.test(rest)) return null
|
|
240
251
|
|
|
241
252
|
take(rest, "unit")
|
|
242
253
|
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Taiwan's entry in the structures layer: Chunghwa Post's list of its post offices
|
|
6
|
+
* (中華郵政全國營業據點, data.gov.tw dataset 5950), as `mailwoman corpus fetch tw-chunghwa-post-offices` writes it.
|
|
7
|
+
*
|
|
8
|
+
* Each row holds the office's name (`臺北北門郵局`), its 5-digit and 6-digit postcodes,
|
|
9
|
+
* its 縣市 and 鄉鎮市區 in their own columns, the rest of its address (`忠孝西路一段120號1樓`)
|
|
10
|
+
* and a point. {@linkcode chunghwaPostAddress} splits the rest at its house number
|
|
11
|
+
* with `TW_HOUSE_NUMBER`, the pattern the GCIS register aligner reads: the street
|
|
12
|
+
* before it, the number with its 號, and a floor after it read by `TW_FLOOR`.
|
|
13
|
+
* A parenthesized note after the number (`(國立政治大學藝文中心內)`) names the building
|
|
14
|
+
* the office sits in and is left out.
|
|
15
|
+
*
|
|
16
|
+
* Every office is filed under the post-office category, and the list is Chunghwa Post's
|
|
17
|
+
* own record of its counters, so its provenance is the postal operator's.
|
|
18
|
+
*
|
|
19
|
+
* No corpus adapter reads this file.
|
|
20
|
+
* Taiwanese training rows are built by the CJK corpus builder (`#tw/corpus/assemble`),
|
|
21
|
+
* whose records are spanned by hand.
|
|
22
|
+
*
|
|
23
|
+
* The codex's Taiwanese layout prints every component this module returns,
|
|
24
|
+
* with the office name set off by a space after the address.
|
|
25
|
+
*
|
|
26
|
+
* License: 政府資料開放授權條款-第1版 (Open Government Data License, Taiwan, v1.0), whose 第2條
|
|
27
|
+
* grants «重製、散布、公開傳輸、公開播送、公開口述、公開上映、公開演出、編輯、改作» for any purpose, and whose 第3條 voids
|
|
28
|
+
* the grant from the start when the attribution it prescribes is missing.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { stringifyJSON } from "@mailwoman/core/json"
|
|
32
|
+
import type { PathBuilder } from "path-ts"
|
|
33
|
+
|
|
34
|
+
import { readCSVRecords } from "#recipes/scaffold"
|
|
35
|
+
import {
|
|
36
|
+
postOfficeCategoryID,
|
|
37
|
+
StructureProvenance,
|
|
38
|
+
type StructureRecord,
|
|
39
|
+
type StructureSource,
|
|
40
|
+
type StructureSourceRead,
|
|
41
|
+
} from "#structures/source"
|
|
42
|
+
import { readManifest } from "#tools/fetch/download"
|
|
43
|
+
import { TW_FLOOR, TW_HOUSE_NUMBER } from "#tw/registers"
|
|
44
|
+
import type { TWChunghwaPostManifest } from "#tw/tools/fetch/chunghwa-post"
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The source directory the fetcher writes.
|
|
48
|
+
*/
|
|
49
|
+
export const TW_CHUNGHWA_POST_SOURCE_ID = "tw-chunghwa-post-offices"
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The file the fetcher writes.
|
|
53
|
+
*/
|
|
54
|
+
export const TW_CHUNGHWA_POST_FILENAME = "post-offices.csv"
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The columns this module reads, in the publisher's spelling.
|
|
58
|
+
*/
|
|
59
|
+
export const TW_CHUNGHWA_POST_COLUMNS = [
|
|
60
|
+
"電腦局號",
|
|
61
|
+
"局名",
|
|
62
|
+
"郵遞區號",
|
|
63
|
+
"縣市",
|
|
64
|
+
"鄉鎮市區",
|
|
65
|
+
"地址",
|
|
66
|
+
"經度",
|
|
67
|
+
"緯度",
|
|
68
|
+
] as const
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* One CSV row, keyed by the publisher's column names.
|
|
72
|
+
*/
|
|
73
|
+
export type TWChunghwaPostRow = Readonly<Record<string, string | undefined>>
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A parenthesized note after the house number: the building or campus the office sits in.
|
|
77
|
+
*/
|
|
78
|
+
const TRAILING_NOTE = /[((][^))]*[))]$/u
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Several numbers an office spans, listed before one 號: `150、152、154號`, `235-1、235-2號`.
|
|
82
|
+
*
|
|
83
|
+
* The office stands at all of them, so the list is its house number.
|
|
84
|
+
*/
|
|
85
|
+
const NUMBER_LIST =
|
|
86
|
+
/^(?<number>[0-90-9]+(?:(?:之|[--])[0-90-9]+)?(?:、[0-90-9]+(?:(?:之|[--])[0-90-9]+)?)+號)(?<rest>.*)$/u
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The street line of an office split into components, or `null` when no house number with
|
|
90
|
+
* 號 follows a street, or something other than a floor or a note follows the number.
|
|
91
|
+
*/
|
|
92
|
+
export function chunghwaPostStreetLine(line: string): { street: string; house_number: string; unit?: string } | null {
|
|
93
|
+
const characters = [...line.replaceAll(/\s+/gu, "")]
|
|
94
|
+
|
|
95
|
+
for (let at = 1; at < characters.length; at++) {
|
|
96
|
+
const tail = characters.slice(at).join("")
|
|
97
|
+
const match = NUMBER_LIST.exec(tail) ?? TW_HOUSE_NUMBER.exec(tail)
|
|
98
|
+
|
|
99
|
+
if (!match) continue
|
|
100
|
+
|
|
101
|
+
const street = characters.slice(0, at).join("")
|
|
102
|
+
|
|
103
|
+
// A street ending in a digit or a list mark ends inside a number or a list of numbers.
|
|
104
|
+
if (/[0-90-9、,,\--]$/u.test(street)) continue
|
|
105
|
+
|
|
106
|
+
const rest = match.groups!["rest"]!.replace(TRAILING_NOTE, "")
|
|
107
|
+
|
|
108
|
+
if (rest && !TW_FLOOR.test(rest)) return null
|
|
109
|
+
|
|
110
|
+
return { street, house_number: match.groups!["number"]!, ...(rest ? { unit: rest } : {}) }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return null
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* An office's address as the components the parser labels, or `null` when its street line doesn't split.
|
|
118
|
+
*/
|
|
119
|
+
export function chunghwaPostAddress(row: TWChunghwaPostRow): StructureRecord["address"] {
|
|
120
|
+
const line = chunghwaPostStreetLine(row["地址"]?.trim() ?? "")
|
|
121
|
+
const postcode = row["郵遞區號"]?.trim()
|
|
122
|
+
const region = row["縣市"]?.trim()
|
|
123
|
+
const subregion = row["鄉鎮市區"]?.trim()
|
|
124
|
+
|
|
125
|
+
if (!line || !region || !subregion) return null
|
|
126
|
+
|
|
127
|
+
return { ...(postcode ? { postcode } : {}), region, subregion, ...line }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* One CSV row as a structure record, or `null` when it has no office number.
|
|
132
|
+
*/
|
|
133
|
+
export function chunghwaPostStructureRecord(row: TWChunghwaPostRow, category: string): StructureRecord | null {
|
|
134
|
+
const id = row["電腦局號"]?.trim()
|
|
135
|
+
|
|
136
|
+
if (!id) return null
|
|
137
|
+
|
|
138
|
+
const latitude = Number(row["緯度"])
|
|
139
|
+
const longitude = Number(row["經度"])
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
id,
|
|
143
|
+
name: row["局名"]?.trim() || null,
|
|
144
|
+
category,
|
|
145
|
+
point:
|
|
146
|
+
Number.isFinite(latitude) && Number.isFinite(longitude) && latitude && longitude ? { latitude, longitude } : null,
|
|
147
|
+
address: chunghwaPostAddress(row),
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function* records(path: PathBuilder): AsyncIterable<StructureRecord> {
|
|
152
|
+
const category = postOfficeCategoryID()
|
|
153
|
+
|
|
154
|
+
for await (const row of readCSVRecords(path)) {
|
|
155
|
+
const record = chunghwaPostStructureRecord(row as TWChunghwaPostRow, category)
|
|
156
|
+
|
|
157
|
+
if (!record) throw new Error(`${path}: a row has no 電腦局號: ${stringifyJSON(row).slice(0, 200)}`)
|
|
158
|
+
|
|
159
|
+
yield record
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const FETCH_COMMAND = "mailwoman corpus fetch tw-chunghwa-post-offices"
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Chunghwa Post's post offices.
|
|
167
|
+
*/
|
|
168
|
+
export const chunghwaPostStructures: StructureSource = {
|
|
169
|
+
id: "chunghwa-post-offices",
|
|
170
|
+
country: "TW",
|
|
171
|
+
publisher: "中華郵政股份有限公司 (Chunghwa Post)",
|
|
172
|
+
attribution: "中華郵政股份有限公司, 中華郵政全國營業據點 (data.gov.tw 5950), 政府資料開放授權條款-第1版",
|
|
173
|
+
license: "OGDL-Taiwan-1.0",
|
|
174
|
+
registerSource: "tw-postal-1",
|
|
175
|
+
provenance: StructureProvenance.PostalOperator,
|
|
176
|
+
fetchCommand: FETCH_COMMAND,
|
|
177
|
+
|
|
178
|
+
async read(sourcesRoot): Promise<StructureSourceRead> {
|
|
179
|
+
const directory = sourcesRoot(TW_CHUNGHWA_POST_SOURCE_ID)
|
|
180
|
+
const manifest = await readManifest<TWChunghwaPostManifest>(directory("MANIFEST.json"))
|
|
181
|
+
|
|
182
|
+
if (!manifest?.downloaded_at) {
|
|
183
|
+
throw new Error(`${directory} holds no MANIFEST.json with a fetch date. Run \`${FETCH_COMMAND}\` first.`)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
vintage: (manifest.publisher_version ?? manifest.downloaded_at).slice(0, 10),
|
|
188
|
+
records: records(directory(TW_CHUNGHWA_POST_FILENAME)),
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
}
|