@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
package/out/utils/wof-json.js
CHANGED
|
@@ -15,10 +15,40 @@
|
|
|
15
15
|
import { readLocalJSONFile, readLocalTextFile } from "@mailwoman/core/fs/readers";
|
|
16
16
|
import { tryParsingJSON } from "@mailwoman/core/json";
|
|
17
17
|
import { resolveModulePath } from "@mailwoman/core/module/resolvers";
|
|
18
|
-
import { compareByScalarValue } from "@mailwoman/core/strings/compare";
|
|
19
18
|
import { agreedHierarchyAncestors } from "@mailwoman/gazetteer/whosonfirst/hierarchy";
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The WOF concordances whose leading two letters are the code of the country a region is a
|
|
21
|
+
* subdivision of: the ISO code and the HASC code (`GF` for French Guiana, `BQ.BO` for Bonaire).
|
|
22
|
+
*/
|
|
23
|
+
export const SUBDIVISION_OF_SOURCES = ["iso:id", "iso:code", "hasc:id"];
|
|
24
|
+
const CODE_COUNTRY = /^([A-Z]{2})(?:[-.]|$)/u;
|
|
25
|
+
/**
|
|
26
|
+
* The country code that leads an ISO 3166 or HASC code, `GF` for `GF` and `BQ` for `BQ.BO`
|
|
27
|
+
* or `BQ-BO`, or `null` for a code that leads with none.
|
|
28
|
+
*/
|
|
29
|
+
export function codeCountry(code) {
|
|
30
|
+
return CODE_COUNTRY.exec(code.toUpperCase())?.[1] ?? null;
|
|
31
|
+
}
|
|
32
|
+
const NO_CODE_COUNTRIES = Object.freeze([]);
|
|
33
|
+
/**
|
|
34
|
+
* The {@linkcode WOFRecord.codeCountries} of a record's properties.
|
|
35
|
+
*/
|
|
36
|
+
function codeCountriesOf(props, country) {
|
|
37
|
+
const concordances = props["wof:concordances"];
|
|
38
|
+
if (!concordances || typeof concordances !== "object")
|
|
39
|
+
return NO_CODE_COUNTRIES;
|
|
40
|
+
const found = new Set();
|
|
41
|
+
for (const source of SUBDIVISION_OF_SOURCES) {
|
|
42
|
+
const code = concordances[source];
|
|
43
|
+
const named = typeof code === "string" ? codeCountry(code) : null;
|
|
44
|
+
if (named && named !== country) {
|
|
45
|
+
found.add(named);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// An admin run holds millions of records.
|
|
49
|
+
// Most hold no other country's code, so those records share one empty list.
|
|
50
|
+
return found.size ? [...found] : NO_CODE_COUNTRIES;
|
|
51
|
+
}
|
|
22
52
|
/**
|
|
23
53
|
* `mz:is_current` ∈ {`1`, `-1`} → keep, `0` → drop.
|
|
24
54
|
*
|
|
@@ -173,6 +203,7 @@ export function recordFromFeature(feature, refutedParents) {
|
|
|
173
203
|
country,
|
|
174
204
|
nameVariants: extractNameVariants(props),
|
|
175
205
|
ancestors: placed ? agreedHierarchyAncestors(id, props["wof:hierarchy"]) : [],
|
|
206
|
+
codeCountries: codeCountriesOf(props, country),
|
|
176
207
|
};
|
|
177
208
|
}
|
|
178
209
|
/**
|
|
@@ -199,55 +230,10 @@ export function readRefutedParentIDs() {
|
|
|
199
230
|
export function isAtOrigin(props) {
|
|
200
231
|
return props["geom:latitude"] === 0 && props["geom:longitude"] === 0;
|
|
201
232
|
}
|
|
202
|
-
/**
|
|
203
|
-
* Stream every canonical GeoJSON file under `repoDir` and yield parsed `WOFRecord`s;
|
|
204
|
-
* `repoDir` may be a single cloned `whosonfirst-data-*` repo or a parent holding several
|
|
205
|
-
* (the corpus pipeline clones all four into a shared `wof/repos/` root).
|
|
206
|
-
*
|
|
207
|
-
* `-alt-` siblings are skipped as alternate-geometry exports.
|
|
208
|
-
* They do not represent new records.
|
|
209
|
-
*
|
|
210
|
-
* Per-file errors (unreadable files, malformed JSON, or missing properties) are swallowed
|
|
211
|
-
* so one bad file doesn't poison a multi-gigabyte walk.
|
|
212
|
-
*
|
|
213
|
-
* The libuv threadpool has four workers by default; `UV_THREADPOOL_SIZE` can change that count.
|
|
214
|
-
* `parallelMap` reads files concurrently up to the threadpool capacity.
|
|
215
|
-
*
|
|
216
|
-
* Records are yielded in the code-point order of their absolute paths.
|
|
217
|
-
* Code-point order is the byte order of the paths' UTF-8 spellings.
|
|
218
|
-
*
|
|
219
|
-
* The adapters deduplicate surface strings first-come.
|
|
220
|
-
* The yield order therefore decides which record claims a shared name.
|
|
221
|
-
*
|
|
222
|
-
* The directory listing's own order comes from `opendir` and varies with the filesystem.
|
|
223
|
-
* ext4's hashed directory index lists `2.geojson` before `1.geojson`.
|
|
224
|
-
* The listing is sorted before the ordered parallel read.
|
|
225
|
-
*
|
|
226
|
-
* Two hosts that hold the same checkout then yield the same sequence.
|
|
227
|
-
*/
|
|
228
|
-
export async function* walkFeatures(repoDir, opts = {}) {
|
|
229
|
-
const listed = await Globerator.from("**/*.geojson", {
|
|
230
|
-
cwd: repoDir,
|
|
231
|
-
absolute: true,
|
|
232
|
-
exclude: ["**/*-alt-*.geojson"],
|
|
233
|
-
// Bundle repositories can expose their data through a link.
|
|
234
|
-
followSymlinks: true,
|
|
235
|
-
signal: opts.signal,
|
|
236
|
-
}).toArray();
|
|
237
|
-
const records = AsyncSequence.from(listed.toSorted(compareByScalarValue)).parallelMap(readFeatureRecord, {
|
|
238
|
-
ordered: true,
|
|
239
|
-
signal: opts.signal,
|
|
240
|
-
});
|
|
241
|
-
for await (const rec of records) {
|
|
242
|
-
if (rec) {
|
|
243
|
-
yield rec;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
233
|
/**
|
|
248
234
|
* The record one GeoJSON file holds, or `null` when the file is unreadable, malformed or skipped.
|
|
249
235
|
*
|
|
250
|
-
*
|
|
236
|
+
* The single-record explorer reads its record and ancestors through this.
|
|
251
237
|
*/
|
|
252
238
|
export async function readFeatureRecord(filePath) {
|
|
253
239
|
let text;
|
|
@@ -269,72 +255,69 @@ export async function readFeatureRecord(filePath) {
|
|
|
269
255
|
*/
|
|
270
256
|
export const ANCESTOR_NAME_TAGS = ["locality", "subregion", "region", "country"];
|
|
271
257
|
/**
|
|
272
|
-
*
|
|
258
|
+
* Each ancestor record's `wof:name`, per tag.
|
|
273
259
|
*
|
|
274
|
-
* `wof-postalcode`
|
|
260
|
+
* `wof-postalcode` renders a postcode's hierarchy from these names and reads no other ancestor field.
|
|
275
261
|
*/
|
|
276
|
-
export function
|
|
277
|
-
const
|
|
278
|
-
for (const
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (name) {
|
|
283
|
-
names[tag] = name;
|
|
284
|
-
}
|
|
262
|
+
export function ancestorNamesOf(records) {
|
|
263
|
+
const names = {};
|
|
264
|
+
for (const tag of ANCESTOR_NAME_TAGS) {
|
|
265
|
+
const name = records[tag]?.name;
|
|
266
|
+
if (name) {
|
|
267
|
+
names[tag] = name;
|
|
285
268
|
}
|
|
286
|
-
index.set(id, names);
|
|
287
269
|
}
|
|
288
|
-
return
|
|
270
|
+
return names;
|
|
289
271
|
}
|
|
290
272
|
/**
|
|
291
|
-
*
|
|
273
|
+
* The nearest ancestor record per tag in {@linkcode ANCESTOR_NAME_TAGS} for one record.
|
|
292
274
|
*
|
|
275
|
+
* `lookup` returns a record the reader kept, or `undefined`.
|
|
293
276
|
* `tagOf` maps a WOF placetype to a component tag, or returns a value outside
|
|
294
277
|
* {@linkcode ANCESTOR_NAME_TAGS} for a placetype no builder looks up.
|
|
278
|
+
*
|
|
295
279
|
* It is a parameter because `placetypeToTag` lives with the adapters and this module doesn't import them.
|
|
296
280
|
*
|
|
297
|
-
* The
|
|
298
|
-
*
|
|
299
|
-
*
|
|
281
|
+
* The `wof:hierarchy` levels are read first, then the parent chain.
|
|
282
|
+
* The chain stops at the first id `lookup` cannot return, and at any re-visit.
|
|
283
|
+
* Only a corrupt fixture holds a cycle.
|
|
300
284
|
*
|
|
301
285
|
* A record whose ancestors are absent resolves the tags it can reach rather than failing.
|
|
286
|
+
*
|
|
287
|
+
* An ancestor in another country claims no tag, unless its own ISO or HASC code leads with
|
|
288
|
+
* the record's country, as France's region Guadeloupe (`GP`) does for a record in `GP`.
|
|
289
|
+
* A row takes its country from the record, so any other such ancestor would write another country's
|
|
290
|
+
* region under it: WOF files Monaco's quarters under Alpes-Maritimes and Macau's under Guangdong.
|
|
302
291
|
*/
|
|
303
|
-
export function
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (!
|
|
311
|
-
|
|
312
|
-
const tag = tagOf(ancestor.placetype);
|
|
313
|
-
for (const wanted of ANCESTOR_NAME_TAGS) {
|
|
314
|
-
if (tag === wanted && !names[wanted]) {
|
|
315
|
-
names[wanted] = ancestor;
|
|
316
|
-
}
|
|
292
|
+
export function ancestorRecordsOf(rec, lookup, tagOf) {
|
|
293
|
+
const names = {};
|
|
294
|
+
const claim = (ancestor) => {
|
|
295
|
+
if (ancestor.country !== rec.country && !ancestor.codeCountries.includes(rec.country))
|
|
296
|
+
return;
|
|
297
|
+
const tag = tagOf(ancestor.placetype);
|
|
298
|
+
for (const wanted of ANCESTOR_NAME_TAGS) {
|
|
299
|
+
if (tag === wanted && !names[wanted]) {
|
|
300
|
+
names[wanted] = ancestor;
|
|
317
301
|
}
|
|
318
302
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (guard.has(parent.id))
|
|
326
|
-
break;
|
|
327
|
-
const tag = tagOf(parent.placetype);
|
|
328
|
-
for (const wanted of ANCESTOR_NAME_TAGS) {
|
|
329
|
-
if (tag === wanted && !names[wanted]) {
|
|
330
|
-
names[wanted] = parent;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
guard.add(parent.id);
|
|
334
|
-
cur = parent.parent_id;
|
|
303
|
+
};
|
|
304
|
+
// `wof:hierarchy` names every ancestor level directly, including for a record whose parent is -4.
|
|
305
|
+
for (const ancestorID of rec.ancestors) {
|
|
306
|
+
const ancestor = lookup(ancestorID);
|
|
307
|
+
if (ancestor) {
|
|
308
|
+
claim(ancestor);
|
|
335
309
|
}
|
|
336
|
-
index.set(id, names);
|
|
337
310
|
}
|
|
338
|
-
|
|
311
|
+
const guard = new Set([rec.id]);
|
|
312
|
+
let cur = rec.parent_id;
|
|
313
|
+
while (cur !== null && cur > 0) {
|
|
314
|
+
const parent = lookup(cur);
|
|
315
|
+
if (!parent || guard.has(parent.id))
|
|
316
|
+
break;
|
|
317
|
+
claim(parent);
|
|
318
|
+
guard.add(parent.id);
|
|
319
|
+
cur = parent.parent_id;
|
|
320
|
+
}
|
|
321
|
+
return names;
|
|
339
322
|
}
|
|
340
323
|
//# sourceMappingURL=wof-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wof-json.js","sourceRoot":"","sources":["../../lib/utils/wof-json.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"wof-json.js","sourceRoot":"","sources":["../../lib/utils/wof-json.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAA;AA4DrF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAA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CAAC,GAAG,CAAC,CAAA;QAE1B,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAAE,MAAK;QAC1C,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACpB,GAAG,GAAG,MAAM,CAAC,SAAS,CAAA;IACvB,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/corpus",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Mailwoman corpus pipeline: BIO-labeled dataset builder for the neural classifier.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
@@ -116,23 +116,23 @@
|
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
"dependencies": {
|
|
119
|
-
"@mailwoman/ban": "11.
|
|
120
|
-
"@mailwoman/bdc": "11.
|
|
121
|
-
"@mailwoman/codex": "11.
|
|
122
|
-
"@mailwoman/core": "11.
|
|
123
|
-
"@mailwoman/dictionaries": "11.
|
|
124
|
-
"@mailwoman/evidence": "11.
|
|
125
|
-
"@mailwoman/gazetteer": "11.
|
|
126
|
-
"@mailwoman/normalize": "11.
|
|
127
|
-
"@mailwoman/poi-taxonomy": "11.
|
|
128
|
-
"@mailwoman/postcode": "11.
|
|
129
|
-
"@mailwoman/
|
|
130
|
-
"@mailwoman/record": "11.
|
|
131
|
-
"@mailwoman/resolver": "11.
|
|
132
|
-
"@mailwoman/resolver-wof-sqlite": "11.
|
|
133
|
-
"@mailwoman/spatial": "11.
|
|
134
|
-
"@mailwoman/sqlite": "11.
|
|
135
|
-
"@mailwoman/tiger": "11.
|
|
119
|
+
"@mailwoman/ban": "11.2.0",
|
|
120
|
+
"@mailwoman/bdc": "11.2.0",
|
|
121
|
+
"@mailwoman/codex": "11.2.0",
|
|
122
|
+
"@mailwoman/core": "11.2.0",
|
|
123
|
+
"@mailwoman/dictionaries": "11.2.0",
|
|
124
|
+
"@mailwoman/evidence": "11.2.0",
|
|
125
|
+
"@mailwoman/gazetteer": "11.2.0",
|
|
126
|
+
"@mailwoman/normalize": "11.2.0",
|
|
127
|
+
"@mailwoman/poi-taxonomy": "11.2.0",
|
|
128
|
+
"@mailwoman/postcode": "11.2.0",
|
|
129
|
+
"@mailwoman/recognizer": "11.2.0",
|
|
130
|
+
"@mailwoman/record": "11.2.0",
|
|
131
|
+
"@mailwoman/resolver": "11.2.0",
|
|
132
|
+
"@mailwoman/resolver-wof-sqlite": "11.2.0",
|
|
133
|
+
"@mailwoman/spatial": "11.2.0",
|
|
134
|
+
"@mailwoman/sqlite": "11.2.0",
|
|
135
|
+
"@mailwoman/tiger": "11.2.0",
|
|
136
136
|
"apache-arrow": "^21.2.0",
|
|
137
137
|
"fastest-levenshtein": "^1.0.16",
|
|
138
138
|
"parquet-wasm": "0.9.0",
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
-
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file Reuses the parsed WOF records of an earlier walk when no input file and no parser line has changed.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { dataRootPath } from "@mailwoman/core/data-root"
|
|
9
|
-
import { pathExists } from "@mailwoman/core/fs/readers/stat"
|
|
10
|
-
import { openWriteStream } from "@mailwoman/core/fs/streams"
|
|
11
|
-
import { makeDirectories, movePath, removePathIfPresent } from "@mailwoman/core/fs/writers"
|
|
12
|
-
import { sha256File, sha256Hex } from "@mailwoman/core/hash"
|
|
13
|
-
import { stringifyJSON } from "@mailwoman/core/json"
|
|
14
|
-
import { fileURLToPath } from "@mailwoman/core/module/file-url"
|
|
15
|
-
import { once } from "@mailwoman/core/utils/events"
|
|
16
|
-
import { dirname, type PathBuilderLike, resolvePathBuilder } from "path-ts"
|
|
17
|
-
import { JSONSpliterator } from "spliterator"
|
|
18
|
-
|
|
19
|
-
import { $public } from "#env"
|
|
20
|
-
import { extractFingerprint } from "#parquet/record"
|
|
21
|
-
import { REFUTED_PARENTS_PATH, walkFeatures, type WOFRecord } from "#utils/wof-json"
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A {@link WOFRecord} as one cache line: `nameVariants` as entries, since a `Map` has no JSON form.
|
|
25
|
-
*/
|
|
26
|
-
interface CachedRecord extends Omit<WOFRecord, "nameVariants"> {
|
|
27
|
-
nameVariants: Array<[string, string | readonly string[]]>
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The module whose parsing the cache stands in for.
|
|
32
|
-
* A change to it changes the cache key.
|
|
33
|
-
*/
|
|
34
|
-
const PARSER_MODULE = import.meta.resolve("#utils/wof-json")
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The cache file for `repoDir`: its {@linkcode extractFingerprint}, which lists every file's path, size
|
|
38
|
-
* and modification time, the sha256 of the parser module and the sha256 of the refuted-parent list.
|
|
39
|
-
*
|
|
40
|
-
* A commit, an uncommitted edit, a parser change or a list change gives a new key.
|
|
41
|
-
*/
|
|
42
|
-
export async function wofRecordCachePath(repoDir: PathBuilderLike, cacheDir: PathBuilderLike): Promise<string> {
|
|
43
|
-
const parser = await sha256File(fileURLToPath(PARSER_MODULE))
|
|
44
|
-
const refuted = await sha256File(REFUTED_PARENTS_PATH)
|
|
45
|
-
const key = sha256Hex(`${await extractFingerprint(repoDir)}\n${parser}\n${refuted}`)
|
|
46
|
-
|
|
47
|
-
return resolvePathBuilder(cacheDir, `${key}.jsonl`).toString()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The cache directory `MAILWOMAN_WOF_RECORD_CACHE` sets, resolved against the
|
|
52
|
-
* data root when relative, or `null`.
|
|
53
|
-
*/
|
|
54
|
-
function configuredCacheDir(): string | null {
|
|
55
|
-
const configured = $public.MAILWOMAN_WOF_RECORD_CACHE
|
|
56
|
-
|
|
57
|
-
if (!configured) return null
|
|
58
|
-
|
|
59
|
-
return configured.startsWith("/") ? configured : dataRootPath(configured).toString()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Every record {@linkcode walkFeatures} yields for `repoDir`, in the same order,
|
|
64
|
-
* read from the cache when its key matches.
|
|
65
|
-
*
|
|
66
|
-
* `cacheDir` defaults to `MAILWOMAN_WOF_RECORD_CACHE`; with neither, this is {@linkcode walkFeatures}.
|
|
67
|
-
* A walk that finishes writes the cache.
|
|
68
|
-
* An aborted or abandoned walk leaves none.
|
|
69
|
-
*/
|
|
70
|
-
export async function* walkFeaturesCached(
|
|
71
|
-
repoDir: PathBuilderLike,
|
|
72
|
-
opts: { signal?: AbortSignal; cacheDir?: PathBuilderLike } = {}
|
|
73
|
-
): AsyncIterable<WOFRecord> {
|
|
74
|
-
const cacheDir = opts.cacheDir ?? configuredCacheDir()
|
|
75
|
-
|
|
76
|
-
if (!cacheDir) {
|
|
77
|
-
yield* walkFeatures(repoDir, { signal: opts.signal })
|
|
78
|
-
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const file = await wofRecordCachePath(repoDir, cacheDir)
|
|
83
|
-
|
|
84
|
-
if (await pathExists(file)) {
|
|
85
|
-
for await (const line of JSONSpliterator.fromAsync<CachedRecord>(file)) {
|
|
86
|
-
if (opts.signal?.aborted) return
|
|
87
|
-
|
|
88
|
-
yield { ...line, nameVariants: new Map(line.nameVariants) }
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
await makeDirectories(dirname(file))
|
|
95
|
-
|
|
96
|
-
const partial = `${file}.partial`
|
|
97
|
-
const stream = openWriteStream(partial, { encoding: "utf8" })
|
|
98
|
-
let complete = false
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
for await (const record of walkFeatures(repoDir, { signal: opts.signal })) {
|
|
102
|
-
const line: CachedRecord = { ...record, nameVariants: [...record.nameVariants] }
|
|
103
|
-
|
|
104
|
-
if (!stream.write(`${stringifyJSON(line)}\n`)) {
|
|
105
|
-
await once(stream, "drain")
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
yield record
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
complete = !opts.signal?.aborted
|
|
112
|
-
} finally {
|
|
113
|
-
stream.end()
|
|
114
|
-
await once(stream, "close")
|
|
115
|
-
|
|
116
|
-
await (complete ? movePath(partial, file) : removePathIfPresent(partial))
|
|
117
|
-
}
|
|
118
|
-
}
|
package/lib/build/heap.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
-
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file The heap a build needs before a resident-record adapter may run.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Adapter ids whose run holds every source record resident before yielding a row.
|
|
10
|
-
*
|
|
11
|
-
* Both WOF adapters build a `Map` of the whole dataset and then sort its keys,
|
|
12
|
-
* so peak memory is a property of the source rather than of `limit`.
|
|
13
|
-
* Measured 2026-09-26: `wof-admin` peaks at 14,020 MiB.
|
|
14
|
-
* Both in one process peak at 14,883 MiB.
|
|
15
|
-
*/
|
|
16
|
-
const RESIDENT_RECORD_ADAPTERS: ReadonlySet<string> = new Set(["wof-admin", "wof-postalcode"])
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Whether `adapterID`'s run holds every source record resident before yielding a row.
|
|
20
|
-
*/
|
|
21
|
-
export function isResidentRecordAdapter(adapterID: string): boolean {
|
|
22
|
-
return RESIDENT_RECORD_ADAPTERS.has(adapterID)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The heap a build needs before a resident-record adapter may run, in bytes.
|
|
27
|
-
*
|
|
28
|
-
* At Node's 4 GB default both WOF adapters abort with SIGABRT, `wof-admin` at 4,085 MB after 722 seconds.
|
|
29
|
-
* The floor sits under the measured 14,883 MiB peak by enough to admit a 16 GB cap
|
|
30
|
-
* and refuse the 4 GB default.
|
|
31
|
-
*/
|
|
32
|
-
export const RESIDENT_ADAPTER_HEAP_FLOOR_BYTES = 15 * 1024 * 1024 * 1024
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Refuses a build whose heap cannot hold a resident-record adapter's dataset.
|
|
36
|
-
*
|
|
37
|
-
* The failure this replaces is a SIGABRT twelve minutes into an eight-hour build.
|
|
38
|
-
* That abort reports no cause and loses the adapter phase.
|
|
39
|
-
* A startup read of the limit costs one call.
|
|
40
|
-
*
|
|
41
|
-
* The `corpus build` command calls this rather than `buildCorpus`, because this package's
|
|
42
|
-
* own tests run `wof-admin` against a five-kilobyte fixture at the default heap.
|
|
43
|
-
*
|
|
44
|
-
* @throws When a resident-record adapter is configured and the heap limit is under the floor.
|
|
45
|
-
*/
|
|
46
|
-
export function assertHeapForAdapters(adapterIDs: readonly string[], heapLimitBytes: number): void {
|
|
47
|
-
const resident = adapterIDs.filter((id) => RESIDENT_RECORD_ADAPTERS.has(id))
|
|
48
|
-
|
|
49
|
-
if (!resident.length || heapLimitBytes >= RESIDENT_ADAPTER_HEAP_FLOOR_BYTES) return
|
|
50
|
-
|
|
51
|
-
const gib = (bytes: number): string => `${(bytes / 1024 / 1024 / 1024).toFixed(1)} GiB`
|
|
52
|
-
|
|
53
|
-
throw new Error(
|
|
54
|
-
`corpus build: the heap limit is ${gib(heapLimitBytes)} and ${resident.join(", ")} ` +
|
|
55
|
-
`${resident.length === 1 ? "holds" : "hold"} every source record resident. That peaked at 14,883 MiB ` +
|
|
56
|
-
`on 2026-09-26. Re-run with NODE_OPTIONS="--max-old-space-size=20480", or leave ` +
|
|
57
|
-
`${resident.join(", ")} out of --inputs. Under ${gib(RESIDENT_ADAPTER_HEAP_FLOOR_BYTES)} the run aborts ` +
|
|
58
|
-
`with SIGABRT partway through the adapter phase.`
|
|
59
|
-
)
|
|
60
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
-
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The official post-office lists `mailwoman gazetteer build post-offices` folds into `post-offices.db`.
|
|
6
|
-
*
|
|
7
|
-
* One entry per source.
|
|
8
|
-
* A new country's source is written under `lib/<cc>/post-offices/` to the
|
|
9
|
-
* contract in `#post-offices/source` and added here.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { PostOfficeSource } from "#post-offices/source"
|
|
13
|
-
import { usgsNationalMapPostOffices } from "#us/post-offices/usgs-national-map"
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Every registered post-office source, in the order the layer reads them.
|
|
17
|
-
*/
|
|
18
|
-
export const POST_OFFICE_SOURCES: readonly PostOfficeSource[] = [usgsNationalMapPostOffices]
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
-
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The United States entry of the post-office layer: the post offices (feature code 78006) in
|
|
6
|
-
* the USGS National Map structures layer, as `mailwoman corpus fetch usgs-post-offices` writes them.
|
|
7
|
-
*
|
|
8
|
-
* The list is the USGS's compilation rather than the Postal Service's own facility list,
|
|
9
|
-
* so its provenance is a mapping agency's.
|
|
10
|
-
* A work of the United States Government, public domain under 17 U.S.C. § 105.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type { PathBuilder } from "path-ts"
|
|
14
|
-
import { JSONSpliterator } from "spliterator"
|
|
15
|
-
|
|
16
|
-
import { createUnitSplitter, type UnitSplitter } from "#adapters/street/unit"
|
|
17
|
-
import {
|
|
18
|
-
PostOfficeProvenance,
|
|
19
|
-
type PostOfficeRecord,
|
|
20
|
-
type PostOfficeSource,
|
|
21
|
-
type PostOfficeSourceRead,
|
|
22
|
-
} from "#post-offices/source"
|
|
23
|
-
import { readManifest } from "#tools/fetch/download"
|
|
24
|
-
import {
|
|
25
|
-
USGOV_USGS_POST_OFFICES_ADAPTER_ID,
|
|
26
|
-
USGS_POST_OFFICES_FILENAME,
|
|
27
|
-
type USGSPostOfficeFeature,
|
|
28
|
-
usgsPostOfficeAddress,
|
|
29
|
-
} from "#us/adapters/usgov/usgs-post-offices/adapter"
|
|
30
|
-
import type { USGSPostOfficesManifest } from "#us/tools/fetch/usgs-post-offices"
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* One fetched feature as a post-office record, or `null` when it has no permanent identifier.
|
|
34
|
-
*
|
|
35
|
-
* The address is split as the `usgov-usgs-post-offices` adapter splits it.
|
|
36
|
-
*/
|
|
37
|
-
export function usgsPostOfficeRecord(feature: USGSPostOfficeFeature, units: UnitSplitter): PostOfficeRecord | null {
|
|
38
|
-
const id = feature.properties.permanent_identifier
|
|
39
|
-
|
|
40
|
-
if (!id) return null
|
|
41
|
-
|
|
42
|
-
const [longitude, latitude] = feature.geometry?.coordinates ?? []
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
id,
|
|
46
|
-
name: feature.properties.name,
|
|
47
|
-
point: typeof latitude === "number" && typeof longitude === "number" ? { latitude, longitude } : null,
|
|
48
|
-
address: usgsPostOfficeAddress(feature.properties, units),
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function* records(path: PathBuilder): AsyncIterable<PostOfficeRecord> {
|
|
53
|
-
const units = await createUnitSplitter()
|
|
54
|
-
|
|
55
|
-
for await (const feature of JSONSpliterator.fromAsync<USGSPostOfficeFeature>(path.toString())) {
|
|
56
|
-
const record = usgsPostOfficeRecord(feature, units)
|
|
57
|
-
|
|
58
|
-
if (record) {
|
|
59
|
-
yield record
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const FETCH_COMMAND = "mailwoman corpus fetch usgs-post-offices"
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The USGS National Map's post offices.
|
|
68
|
-
*/
|
|
69
|
-
export const usgsNationalMapPostOffices: PostOfficeSource = {
|
|
70
|
-
id: "usgs-national-map",
|
|
71
|
-
country: "US",
|
|
72
|
-
publisher: "U.S. Geological Survey",
|
|
73
|
-
attribution: "U.S. Geological Survey, The National Map",
|
|
74
|
-
license: "LicenseRef-USGov-Public-Domain",
|
|
75
|
-
registerSource: "us-public-administration-3",
|
|
76
|
-
provenance: PostOfficeProvenance.MappingAgency,
|
|
77
|
-
fetchCommand: FETCH_COMMAND,
|
|
78
|
-
|
|
79
|
-
async read(sourcesRoot): Promise<PostOfficeSourceRead> {
|
|
80
|
-
const directory = sourcesRoot(USGOV_USGS_POST_OFFICES_ADAPTER_ID)
|
|
81
|
-
const manifest = await readManifest<USGSPostOfficesManifest>(directory("MANIFEST.json"))
|
|
82
|
-
|
|
83
|
-
if (!manifest?.downloaded_at) {
|
|
84
|
-
throw new Error(`${directory} holds no MANIFEST.json with a fetch date. Run \`${FETCH_COMMAND}\` first.`)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return { vintage: manifest.downloaded_at.slice(0, 10), records: records(directory(USGS_POST_OFFICES_FILENAME)) }
|
|
88
|
-
},
|
|
89
|
-
}
|