@mailwoman/corpus 9.0.0 → 9.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 +3 -3
- package/data/PROVENANCE.md +227 -0
- package/data/reviewed-ve-postcode-tuples.json +74 -0
- package/data/sub-venue-lexicon.json +18269 -0
- package/out/src/adapters/ban/adapter.d.ts +1 -1
- package/out/src/adapters/ban/adapter.d.ts.map +1 -1
- package/out/src/adapters/ban/adapter.js +5 -4
- package/out/src/adapters/ban/adapter.js.map +1 -1
- package/out/src/adapters/fcc-bdc/adapter.d.ts +1 -1
- package/out/src/adapters/fcc-bdc/adapter.d.ts.map +1 -1
- package/out/src/adapters/fcc-bdc/adapter.js +3 -3
- package/out/src/adapters/fcc-bdc/adapter.js.map +1 -1
- package/out/src/adapters/geonames/adapter.d.ts +1 -1
- package/out/src/adapters/geonames/adapter.d.ts.map +1 -1
- package/out/src/adapters/geonames/adapter.js +2 -2
- package/out/src/adapters/geonames/adapter.js.map +1 -1
- package/out/src/adapters/geonames-postal/adapter.d.ts +1 -1
- package/out/src/adapters/geonames-postal/adapter.d.ts.map +1 -1
- package/out/src/adapters/geonames-postal/adapter.js +3 -3
- package/out/src/adapters/geonames-postal/adapter.js.map +1 -1
- package/out/src/adapters/gnaf/adapter.d.ts +1 -1
- package/out/src/adapters/gnaf/adapter.d.ts.map +1 -1
- package/out/src/adapters/gnaf/adapter.js +2 -2
- package/out/src/adapters/gnaf/adapter.js.map +1 -1
- package/out/src/adapters/gnaf/assemble.js +1 -1
- package/out/src/adapters/gnaf/assemble.js.map +1 -1
- package/out/src/adapters/index.d.ts +1 -1
- package/out/src/adapters/index.d.ts.map +1 -1
- package/out/src/adapters/index.js +1 -1
- package/out/src/adapters/index.js.map +1 -1
- package/out/src/adapters/openaddresses/adapter.d.ts +1 -1
- package/out/src/adapters/openaddresses/adapter.d.ts.map +1 -1
- package/out/src/adapters/openaddresses/adapter.js +3 -3
- package/out/src/adapters/openaddresses/adapter.js.map +1 -1
- package/out/src/adapters/overture/adapter.d.ts +1 -1
- package/out/src/adapters/overture/adapter.d.ts.map +1 -1
- package/out/src/adapters/overture/adapter.js +2 -2
- package/out/src/adapters/overture/adapter.js.map +1 -1
- package/out/src/adapters/state-hi-schools/adapter.d.ts +1 -1
- package/out/src/adapters/state-hi-schools/adapter.d.ts.map +1 -1
- package/out/src/adapters/state-hi-schools/adapter.js +7 -6
- package/out/src/adapters/state-hi-schools/adapter.js.map +1 -1
- package/out/src/adapters/state-ia-contractors/adapter.d.ts +1 -1
- package/out/src/adapters/state-ia-contractors/adapter.d.ts.map +1 -1
- package/out/src/adapters/state-ia-contractors/adapter.js +12 -7
- package/out/src/adapters/state-ia-contractors/adapter.js.map +1 -1
- package/out/src/adapters/state-ny-notaries/adapter.d.ts +1 -1
- package/out/src/adapters/state-ny-notaries/adapter.d.ts.map +1 -1
- package/out/src/adapters/state-ny-notaries/adapter.js +12 -18
- package/out/src/adapters/state-ny-notaries/adapter.js.map +1 -1
- package/out/src/adapters/state-tx-notaries/adapter.d.ts +1 -1
- package/out/src/adapters/state-tx-notaries/adapter.d.ts.map +1 -1
- package/out/src/adapters/state-tx-notaries/adapter.js +12 -7
- package/out/src/adapters/state-tx-notaries/adapter.js.map +1 -1
- package/out/src/adapters/synth-po-box/adapter.d.ts +3 -3
- package/out/src/adapters/synth-po-box/adapter.d.ts.map +1 -1
- package/out/src/adapters/synth-po-box/adapter.js +3 -3
- package/out/src/adapters/synth-po-box/adapter.js.map +1 -1
- package/out/src/adapters/tiger/adapter.d.ts +1 -1
- package/out/src/adapters/tiger/adapter.d.ts.map +1 -1
- package/out/src/adapters/tiger/adapter.js +2 -2
- package/out/src/adapters/tiger/adapter.js.map +1 -1
- package/out/src/adapters/usgov-hrsa-fqhc/adapter.d.ts +1 -1
- package/out/src/adapters/usgov-hrsa-fqhc/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-hrsa-fqhc/adapter.js +7 -6
- package/out/src/adapters/usgov-hrsa-fqhc/adapter.js.map +1 -1
- package/out/src/adapters/usgov-imls-pls/adapter.d.ts +1 -1
- package/out/src/adapters/usgov-imls-pls/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-imls-pls/adapter.js +11 -7
- package/out/src/adapters/usgov-imls-pls/adapter.js.map +1 -1
- package/out/src/adapters/usgov-irs-bmf/adapter.d.ts +1 -1
- package/out/src/adapters/usgov-irs-bmf/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-irs-bmf/adapter.js +6 -5
- package/out/src/adapters/usgov-irs-bmf/adapter.js.map +1 -1
- package/out/src/adapters/usgov-nad/adapter.d.ts +1 -1
- package/out/src/adapters/usgov-nad/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-nad/adapter.js +8 -8
- package/out/src/adapters/usgov-nad/adapter.js.map +1 -1
- package/out/src/adapters/usgov-nppes/adapter.d.ts +1 -1
- package/out/src/adapters/usgov-nppes/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-nppes/adapter.js +10 -10
- package/out/src/adapters/usgov-nppes/adapter.js.map +1 -1
- package/out/src/adapters/usgov-samhsa-treatment-locator/adapter.d.ts +1 -1
- package/out/src/adapters/usgov-samhsa-treatment-locator/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-samhsa-treatment-locator/adapter.js +7 -6
- package/out/src/adapters/usgov-samhsa-treatment-locator/adapter.js.map +1 -1
- package/out/src/{adapter.d.ts → adapters/utils/index.d.ts} +8 -2
- package/out/src/adapters/utils/index.d.ts.map +1 -0
- package/out/src/{adapter.js → adapters/utils/index.js} +11 -3
- package/out/src/adapters/utils/index.js.map +1 -0
- package/out/src/adapters/wof-admin-jp/adapter.d.ts +1 -1
- package/out/src/adapters/wof-admin-jp/adapter.d.ts.map +1 -1
- package/out/src/adapters/wof-admin-jp/adapter.js +5 -5
- package/out/src/adapters/wof-admin-jp/adapter.js.map +1 -1
- package/out/src/adapters/wof-admin-json/adapter.d.ts +4 -15
- package/out/src/adapters/wof-admin-json/adapter.d.ts.map +1 -1
- package/out/src/adapters/wof-admin-json/adapter.js +11 -35
- package/out/src/adapters/wof-admin-json/adapter.js.map +1 -1
- package/out/src/adapters/wof-json-rows.d.ts +32 -0
- package/out/src/adapters/wof-json-rows.d.ts.map +1 -0
- package/out/src/adapters/wof-json-rows.js +45 -0
- package/out/src/adapters/wof-json-rows.js.map +1 -0
- package/out/src/adapters/wof-postalcode-json/adapter.d.ts +4 -9
- package/out/src/adapters/wof-postalcode-json/adapter.d.ts.map +1 -1
- package/out/src/adapters/wof-postalcode-json/adapter.js +12 -37
- package/out/src/adapters/wof-postalcode-json/adapter.js.map +1 -1
- package/out/src/build.d.ts +4 -4
- package/out/src/build.d.ts.map +1 -1
- package/out/src/build.js +7 -7
- package/out/src/build.js.map +1 -1
- package/out/src/index.d.ts +3 -17
- package/out/src/index.d.ts.map +1 -1
- package/out/src/index.js +3 -17
- package/out/src/index.js.map +1 -1
- package/out/src/name-prone-us-suffixes.d.ts +12 -0
- package/out/src/name-prone-us-suffixes.d.ts.map +1 -0
- package/out/src/name-prone-us-suffixes.js +12 -0
- package/out/src/name-prone-us-suffixes.js.map +1 -0
- package/out/src/parquet-wrapper/reader.d.ts.map +1 -1
- package/out/src/parquet-wrapper/reader.js +5 -0
- package/out/src/parquet-wrapper/reader.js.map +1 -1
- package/out/src/runner.d.ts +2 -2
- package/out/src/runner.d.ts.map +1 -1
- package/out/src/runner.js +1 -1
- package/out/src/runner.js.map +1 -1
- package/out/src/shard-recipes/anchor-absorption.d.ts.map +1 -1
- package/out/src/shard-recipes/anchor-absorption.js +4 -5
- package/out/src/shard-recipes/anchor-absorption.js.map +1 -1
- package/out/src/shard-recipes/bare-country.d.ts +25 -0
- package/out/src/shard-recipes/bare-country.d.ts.map +1 -0
- package/out/src/shard-recipes/bare-country.js +87 -0
- package/out/src/shard-recipes/bare-country.js.map +1 -0
- package/out/src/shard-recipes/boundary-stress.d.ts.map +1 -1
- package/out/src/shard-recipes/boundary-stress.js +2 -2
- package/out/src/shard-recipes/boundary-stress.js.map +1 -1
- package/out/src/shard-recipes/country-balanced.d.ts.map +1 -1
- package/out/src/shard-recipes/country-balanced.js +14 -21
- package/out/src/shard-recipes/country-balanced.js.map +1 -1
- package/out/src/shard-recipes/cz-pcfirst-preposition.d.ts.map +1 -1
- package/out/src/shard-recipes/cz-pcfirst-preposition.js +28 -10
- package/out/src/shard-recipes/cz-pcfirst-preposition.js.map +1 -1
- package/out/src/shard-recipes/fr-admin-split.d.ts.map +1 -1
- package/out/src/shard-recipes/fr-admin-split.js +4 -3
- package/out/src/shard-recipes/fr-admin-split.js.map +1 -1
- package/out/src/shard-recipes/fr-bare-street.d.ts.map +1 -1
- package/out/src/shard-recipes/fr-bare-street.js +72 -11
- package/out/src/shard-recipes/fr-bare-street.js.map +1 -1
- package/out/src/shard-recipes/fr-lieudit.d.ts.map +1 -1
- package/out/src/shard-recipes/fr-lieudit.js +4 -3
- package/out/src/shard-recipes/fr-lieudit.js.map +1 -1
- package/out/src/shard-recipes/fr-order.d.ts.map +1 -1
- package/out/src/shard-recipes/fr-order.js +11 -20
- package/out/src/shard-recipes/fr-order.js.map +1 -1
- package/out/src/shard-recipes/german.d.ts.map +1 -1
- package/out/src/shard-recipes/german.js +8 -14
- package/out/src/shard-recipes/german.js.map +1 -1
- package/out/src/shard-recipes/house-venue.d.ts.map +1 -1
- package/out/src/shard-recipes/house-venue.js +1 -1
- package/out/src/shard-recipes/house-venue.js.map +1 -1
- package/out/src/shard-recipes/index.d.ts.map +1 -1
- package/out/src/shard-recipes/index.js +8 -1
- package/out/src/shard-recipes/index.js.map +1 -1
- package/out/src/shard-recipes/intersection.d.ts.map +1 -1
- package/out/src/shard-recipes/intersection.js +7 -13
- package/out/src/shard-recipes/intersection.js.map +1 -1
- package/out/src/shard-recipes/locale.d.ts +5 -5
- package/out/src/shard-recipes/locale.d.ts.map +1 -1
- package/out/src/shard-recipes/locale.js +13 -20
- package/out/src/shard-recipes/locale.js.map +1 -1
- package/out/src/shard-recipes/no-street.d.ts.map +1 -1
- package/out/src/shard-recipes/no-street.js +1 -1
- package/out/src/shard-recipes/no-street.js.map +1 -1
- package/out/src/shard-recipes/po-box-cedex.d.ts.map +1 -1
- package/out/src/shard-recipes/po-box-cedex.js +60 -43
- package/out/src/shard-recipes/po-box-cedex.js.map +1 -1
- package/out/src/shard-recipes/po-box.d.ts.map +1 -1
- package/out/src/shard-recipes/po-box.js +1 -1
- package/out/src/shard-recipes/po-box.js.map +1 -1
- package/out/src/shard-recipes/reviewed-postcode-tail.d.ts +47 -0
- package/out/src/shard-recipes/reviewed-postcode-tail.d.ts.map +1 -0
- package/out/src/shard-recipes/reviewed-postcode-tail.js +125 -0
- package/out/src/shard-recipes/reviewed-postcode-tail.js.map +1 -0
- package/out/src/shard-recipes/scaffold.d.ts +51 -23
- package/out/src/shard-recipes/scaffold.d.ts.map +1 -1
- package/out/src/shard-recipes/scaffold.js +59 -23
- package/out/src/shard-recipes/scaffold.js.map +1 -1
- package/out/src/shard-recipes/street-affix.d.ts +54 -0
- package/out/src/shard-recipes/street-affix.d.ts.map +1 -1
- package/out/src/shard-recipes/street-affix.js +203 -35
- package/out/src/shard-recipes/street-affix.js.map +1 -1
- package/out/src/shard-recipes/street-bare.d.ts.map +1 -1
- package/out/src/shard-recipes/street-bare.js +3 -3
- package/out/src/shard-recipes/street-bare.js.map +1 -1
- package/out/src/shard-recipes/street.d.ts.map +1 -1
- package/out/src/shard-recipes/street.js +2 -2
- package/out/src/shard-recipes/street.js.map +1 -1
- package/out/src/shard-recipes/sub-venue-sources.d.ts +3 -6
- package/out/src/shard-recipes/sub-venue-sources.d.ts.map +1 -1
- package/out/src/shard-recipes/sub-venue-sources.js +4 -9
- package/out/src/shard-recipes/sub-venue-sources.js.map +1 -1
- package/out/src/shard-recipes/sub-venue.d.ts +2 -2
- package/out/src/shard-recipes/sub-venue.d.ts.map +1 -1
- package/out/src/shard-recipes/sub-venue.js +7 -6
- package/out/src/shard-recipes/sub-venue.js.map +1 -1
- package/out/src/shard-recipes/trailing-region.d.ts +74 -0
- package/out/src/shard-recipes/trailing-region.d.ts.map +1 -0
- package/out/src/shard-recipes/trailing-region.js +157 -0
- package/out/src/shard-recipes/trailing-region.js.map +1 -0
- package/out/src/shard-recipes/unit.d.ts.map +1 -1
- package/out/src/shard-recipes/unit.js +6 -12
- package/out/src/shard-recipes/unit.js.map +1 -1
- package/out/src/{synthesize-anchor-absorption.d.ts → synthesizers/anchor-absorption.d.ts} +1 -1
- package/out/src/synthesizers/anchor-absorption.d.ts.map +1 -0
- package/out/src/{synthesize-anchor-absorption.js → synthesizers/anchor-absorption.js} +1 -1
- package/out/src/synthesizers/anchor-absorption.js.map +1 -0
- package/out/src/{synthesize-boundary-stress.d.ts → synthesizers/boundary-stress.d.ts} +3 -3
- package/out/src/synthesizers/boundary-stress.d.ts.map +1 -0
- package/out/src/{synthesize-boundary-stress.js → synthesizers/boundary-stress.js} +2 -2
- package/out/src/synthesizers/boundary-stress.js.map +1 -0
- package/out/src/{synthesize-german.d.ts → synthesizers/german.d.ts} +2 -2
- package/out/src/synthesizers/german.d.ts.map +1 -0
- package/out/src/{synthesize-german.js → synthesizers/german.js} +2 -2
- package/out/src/synthesizers/german.js.map +1 -0
- package/out/src/{synthesize-house-venue.d.ts → synthesizers/house-venue.d.ts} +4 -4
- package/out/src/synthesizers/house-venue.d.ts.map +1 -0
- package/out/src/{synthesize-house-venue.js → synthesizers/house-venue.js} +20 -6
- package/out/src/synthesizers/house-venue.js.map +1 -0
- package/out/src/{synthesize-intersection.d.ts → synthesizers/intersection.d.ts} +2 -2
- package/out/src/synthesizers/intersection.d.ts.map +1 -0
- package/out/src/{synthesize-intersection.js → synthesizers/intersection.js} +1 -1
- package/out/src/synthesizers/intersection.js.map +1 -0
- package/out/src/{synthesize-no-street.d.ts → synthesizers/no-street.d.ts} +3 -3
- package/out/src/synthesizers/no-street.d.ts.map +1 -0
- package/out/src/{synthesize-no-street.js → synthesizers/no-street.js} +2 -2
- package/out/src/synthesizers/no-street.js.map +1 -0
- package/out/src/{synthesize-po-box.d.ts → synthesizers/po-box.d.ts} +2 -2
- package/out/src/synthesizers/po-box.d.ts.map +1 -0
- package/out/src/{synthesize-po-box.js → synthesizers/po-box.js} +1 -1
- package/out/src/synthesizers/po-box.js.map +1 -0
- package/out/src/{synthesize-street.d.ts → synthesizers/street.d.ts} +2 -2
- package/out/src/synthesizers/street.d.ts.map +1 -0
- package/out/src/{synthesize-street.js → synthesizers/street.js} +4 -3
- package/out/src/synthesizers/street.js.map +1 -0
- package/out/src/{synthesize.d.ts → synthesizers/utils.d.ts} +3 -3
- package/out/src/synthesizers/utils.d.ts.map +1 -0
- package/out/src/{synthesize.js → synthesizers/utils.js} +5 -4
- package/out/src/synthesizers/utils.js.map +1 -0
- package/out/src/tools/align-shard.d.ts.map +1 -1
- package/out/src/tools/align-shard.js +2 -2
- package/out/src/tools/align-shard.js.map +1 -1
- package/out/src/tools/fetch/ban.d.ts.map +1 -1
- package/out/src/tools/fetch/ban.js +2 -18
- package/out/src/tools/fetch/ban.js.map +1 -1
- package/out/src/tools/fetch/download.d.ts +12 -3
- package/out/src/tools/fetch/download.d.ts.map +1 -1
- package/out/src/tools/fetch/download.js +20 -4
- package/out/src/tools/fetch/download.js.map +1 -1
- package/out/src/tools/fetch/geonames-dump.d.ts +87 -0
- package/out/src/tools/fetch/geonames-dump.d.ts.map +1 -0
- package/out/src/tools/fetch/geonames-dump.js +178 -0
- package/out/src/tools/fetch/geonames-dump.js.map +1 -0
- package/out/src/tools/fetch/geonames-postal.d.ts +76 -0
- package/out/src/tools/fetch/geonames-postal.d.ts.map +1 -0
- package/out/src/tools/fetch/geonames-postal.js +125 -0
- package/out/src/tools/fetch/geonames-postal.js.map +1 -0
- package/out/src/tools/fetch/imls-pls.d.ts.map +1 -1
- package/out/src/tools/fetch/imls-pls.js +5 -17
- package/out/src/tools/fetch/imls-pls.js.map +1 -1
- package/out/src/tools/fetch/index.d.ts +11 -0
- package/out/src/tools/fetch/index.d.ts.map +1 -1
- package/out/src/tools/fetch/index.js +11 -0
- package/out/src/tools/fetch/index.js.map +1 -1
- package/out/src/tools/fetch/nad.d.ts.map +1 -1
- package/out/src/tools/fetch/nad.js +20 -11
- package/out/src/tools/fetch/nad.js.map +1 -1
- package/out/src/tools/fetch/nppes.d.ts.map +1 -1
- package/out/src/tools/fetch/nppes.js +17 -22
- package/out/src/tools/fetch/nppes.js.map +1 -1
- package/out/src/tools/fetch/openaddresses.d.ts.map +1 -1
- package/out/src/tools/fetch/openaddresses.js +18 -17
- package/out/src/tools/fetch/openaddresses.js.map +1 -1
- package/out/src/tools/fetch/ourairports.d.ts.map +1 -1
- package/out/src/tools/fetch/ourairports.js +7 -2
- package/out/src/tools/fetch/ourairports.js.map +1 -1
- package/out/src/tools/fetch/ppd.d.ts +0 -4
- package/out/src/tools/fetch/ppd.d.ts.map +1 -1
- package/out/src/tools/fetch/ppd.js +1 -1
- package/out/src/tools/fetch/ppd.js.map +1 -1
- package/out/src/tools/fetch/state-hi-schools.d.ts.map +1 -1
- package/out/src/tools/fetch/state-hi-schools.js +3 -19
- package/out/src/tools/fetch/state-hi-schools.js.map +1 -1
- package/out/src/tools/fetch/state-sources.d.ts +4 -0
- package/out/src/tools/fetch/state-sources.d.ts.map +1 -1
- package/out/src/tools/fetch/state-sources.js +1 -5
- package/out/src/tools/fetch/state-sources.js.map +1 -1
- package/out/src/tools/fetch/tiger-full.d.ts.map +1 -1
- package/out/src/tools/fetch/tiger-full.js +15 -21
- package/out/src/tools/fetch/tiger-full.js.map +1 -1
- package/out/src/tools/golden-expand.d.ts.map +1 -1
- package/out/src/tools/golden-expand.js +34 -25
- package/out/src/tools/golden-expand.js.map +1 -1
- package/out/src/tools/golden-relabel-street.d.ts.map +1 -1
- package/out/src/tools/golden-relabel-street.js +4 -77
- package/out/src/tools/golden-relabel-street.js.map +1 -1
- package/out/src/tools/index.d.ts +2 -2
- package/out/src/tools/index.d.ts.map +1 -1
- package/out/src/tools/index.js +2 -2
- package/out/src/tools/index.js.map +1 -1
- package/out/src/tools/ingest-csv.d.ts.map +1 -1
- package/out/src/tools/ingest-csv.js +0 -11
- package/out/src/tools/ingest-csv.js.map +1 -1
- package/out/src/tools/overlay-manifest.d.ts +4 -0
- package/out/src/tools/overlay-manifest.d.ts.map +1 -1
- package/out/src/tools/overlay-manifest.js +16 -6
- package/out/src/tools/overlay-manifest.js.map +1 -1
- package/out/src/tools/postcode-triples.d.ts +175 -0
- package/out/src/tools/postcode-triples.d.ts.map +1 -0
- package/out/src/tools/postcode-triples.js +304 -0
- package/out/src/tools/postcode-triples.js.map +1 -0
- package/out/src/tools/shard-kryptonite.d.ts.map +1 -1
- package/out/src/tools/shard-kryptonite.js +1 -3
- package/out/src/tools/shard-kryptonite.js.map +1 -1
- package/out/src/tools/shard-translit.d.ts.map +1 -1
- package/out/src/tools/shard-translit.js +4 -27
- package/out/src/tools/shard-translit.js.map +1 -1
- package/out/src/tools/sub-venue/harvest.d.ts +100 -0
- package/out/src/tools/sub-venue/harvest.d.ts.map +1 -0
- package/out/src/tools/sub-venue/harvest.js +168 -0
- package/out/src/tools/sub-venue/harvest.js.map +1 -0
- package/out/src/tools/sub-venue/head-nouns.d.ts +50 -0
- package/out/src/tools/sub-venue/head-nouns.d.ts.map +1 -0
- package/out/src/tools/sub-venue/head-nouns.js +210 -0
- package/out/src/tools/sub-venue/head-nouns.js.map +1 -0
- package/out/src/tools/sub-venue/surfaces.d.ts +45 -0
- package/out/src/tools/sub-venue/surfaces.d.ts.map +1 -0
- package/out/src/tools/sub-venue/surfaces.js +77 -0
- package/out/src/tools/sub-venue/surfaces.js.map +1 -0
- package/out/src/tools/sub-venue/table.d.ts +229 -0
- package/out/src/tools/sub-venue/table.d.ts.map +1 -0
- package/out/src/tools/sub-venue/table.js +108 -0
- package/out/src/tools/sub-venue/table.js.map +1 -0
- package/out/src/tools/sub-venue/wikidata.d.ts +26 -0
- package/out/src/tools/sub-venue/wikidata.d.ts.map +1 -0
- package/out/src/tools/sub-venue/wikidata.js +62 -0
- package/out/src/tools/sub-venue/wikidata.js.map +1 -0
- package/out/src/tools/sub-venue-lexicon.d.ts +27 -378
- package/out/src/tools/sub-venue-lexicon.d.ts.map +1 -1
- package/out/src/tools/sub-venue-lexicon.js +30 -565
- package/out/src/tools/sub-venue-lexicon.js.map +1 -1
- package/out/src/{align.d.ts → utils/align.d.ts} +1 -1
- package/out/src/utils/align.d.ts.map +1 -0
- package/out/src/utils/align.js.map +1 -0
- package/out/src/utils/golden.d.ts.map +1 -0
- package/out/src/{golden.js → utils/golden.js} +2 -2
- package/out/src/utils/golden.js.map +1 -0
- package/out/src/utils/index.d.ts +14 -0
- package/out/src/utils/index.d.ts.map +1 -0
- package/out/src/utils/index.js +14 -0
- package/out/src/utils/index.js.map +1 -0
- package/out/src/utils/license.d.ts.map +1 -0
- package/out/src/{license.js → utils/license.js} +1 -1
- package/out/src/utils/license.js.map +1 -0
- package/out/src/{parquet.d.ts → utils/parquet.d.ts} +24 -5
- package/out/src/utils/parquet.d.ts.map +1 -0
- package/out/src/{parquet.js → utils/parquet.js} +6 -3
- package/out/src/utils/parquet.js.map +1 -0
- package/out/src/{split.d.ts → utils/split.d.ts} +1 -1
- package/out/src/utils/split.d.ts.map +1 -0
- package/out/src/{split.js → utils/split.js} +2 -2
- package/out/src/utils/split.js.map +1 -0
- package/out/src/utils/tokenize.d.ts.map +1 -0
- package/out/src/utils/tokenize.js.map +1 -0
- package/out/src/utils/wof-json.d.ts.map +1 -0
- package/out/src/utils/wof-json.js.map +1 -0
- package/package.json +287 -21
- package/src/adapters/ban/adapter.ts +7 -5
- package/src/adapters/fcc-bdc/adapter.ts +5 -4
- package/src/adapters/geonames/adapter.ts +3 -3
- package/src/adapters/geonames-postal/adapter.ts +4 -4
- package/src/adapters/gnaf/adapter.ts +3 -3
- package/src/adapters/gnaf/assemble.ts +1 -1
- package/src/adapters/index.ts +3 -2
- package/src/adapters/openaddresses/adapter.ts +4 -4
- package/src/adapters/overture/adapter.ts +3 -3
- package/src/adapters/state-hi-schools/adapter.ts +8 -7
- package/src/adapters/state-ia-contractors/adapter.ts +13 -8
- package/src/adapters/state-ny-notaries/adapter.ts +13 -32
- package/src/adapters/state-tx-notaries/adapter.ts +13 -8
- package/src/adapters/synth-po-box/adapter.ts +4 -4
- package/src/adapters/tiger/adapter.ts +5 -3
- package/src/adapters/usgov-hrsa-fqhc/adapter.ts +8 -7
- package/src/adapters/usgov-imls-pls/adapter.ts +12 -8
- package/src/adapters/usgov-irs-bmf/adapter.ts +7 -6
- package/src/adapters/usgov-nad/adapter.ts +9 -9
- package/src/adapters/usgov-nppes/adapter.ts +13 -12
- package/src/adapters/usgov-samhsa-treatment-locator/adapter.ts +8 -7
- package/src/{adapter.ts → adapters/utils/index.ts} +15 -3
- package/src/adapters/wof-admin-jp/adapter.ts +9 -12
- package/src/adapters/wof-admin-json/adapter.ts +15 -54
- package/src/adapters/wof-json-rows.ts +79 -0
- package/src/adapters/wof-postalcode-json/adapter.ts +16 -50
- package/src/build.ts +8 -8
- package/src/index.ts +3 -17
- package/src/name-prone-us-suffixes.ts +12 -0
- package/src/parquet-wrapper/reader.ts +9 -0
- package/src/runner.ts +2 -2
- package/src/shard-recipes/anchor-absorption.ts +5 -5
- package/src/shard-recipes/bare-country.ts +95 -0
- package/src/shard-recipes/boundary-stress.ts +3 -2
- package/src/shard-recipes/country-balanced.ts +16 -27
- package/src/shard-recipes/cz-pcfirst-preposition.ts +29 -10
- package/src/shard-recipes/fr-admin-split.ts +6 -4
- package/src/shard-recipes/fr-bare-street.ts +85 -10
- package/src/shard-recipes/fr-lieudit.ts +6 -4
- package/src/shard-recipes/fr-order.ts +13 -26
- package/src/shard-recipes/german.ts +9 -18
- package/src/shard-recipes/house-venue.ts +2 -1
- package/src/shard-recipes/index.ts +8 -1
- package/src/shard-recipes/intersection.ts +9 -17
- package/src/shard-recipes/locale.ts +16 -24
- package/src/shard-recipes/no-street.ts +2 -1
- package/src/shard-recipes/po-box-cedex.ts +76 -58
- package/src/shard-recipes/po-box.ts +2 -1
- package/src/shard-recipes/reviewed-postcode-tail.ts +189 -0
- package/src/shard-recipes/scaffold.ts +99 -24
- package/src/shard-recipes/street-affix.ts +284 -45
- package/src/shard-recipes/street-bare.ts +4 -3
- package/src/shard-recipes/street.ts +3 -2
- package/src/shard-recipes/sub-venue-sources.ts +13 -23
- package/src/shard-recipes/sub-venue.ts +11 -9
- package/src/shard-recipes/trailing-region.ts +183 -0
- package/src/shard-recipes/unit.ts +8 -17
- package/src/{synthesize-boundary-stress.ts → synthesizers/boundary-stress.ts} +2 -2
- package/src/{synthesize-german.ts → synthesizers/german.ts} +3 -2
- package/src/{synthesize-house-venue.ts → synthesizers/house-venue.ts} +20 -6
- package/src/{synthesize-intersection.ts → synthesizers/intersection.ts} +1 -1
- package/src/{synthesize-no-street.ts → synthesizers/no-street.ts} +2 -2
- package/src/{synthesize-po-box.ts → synthesizers/po-box.ts} +1 -1
- package/src/{synthesize-street.ts → synthesizers/street.ts} +5 -3
- package/src/{synthesize.ts → synthesizers/utils.ts} +6 -4
- package/src/tools/align-shard.ts +3 -2
- package/src/tools/fetch/ban.ts +2 -22
- package/src/tools/fetch/download.ts +22 -4
- package/src/tools/fetch/geonames-dump.ts +267 -0
- package/src/tools/fetch/geonames-postal.ts +180 -0
- package/src/tools/fetch/imls-pls.ts +6 -20
- package/src/tools/fetch/index.ts +11 -0
- package/src/tools/fetch/nad.ts +21 -10
- package/src/tools/fetch/nppes.ts +17 -23
- package/src/tools/fetch/openaddresses.ts +18 -22
- package/src/tools/fetch/ourairports.ts +7 -2
- package/src/tools/fetch/ppd.ts +1 -1
- package/src/tools/fetch/state-hi-schools.ts +3 -23
- package/src/tools/fetch/state-sources.ts +1 -1
- package/src/tools/fetch/tiger-full.ts +17 -24
- package/src/tools/golden-expand.ts +44 -33
- package/src/tools/golden-relabel-street.ts +5 -68
- package/src/tools/index.ts +2 -2
- package/src/tools/ingest-csv.ts +0 -13
- package/src/tools/overlay-manifest.ts +20 -8
- package/src/tools/postcode-triples.ts +375 -0
- package/src/tools/shard-kryptonite.ts +4 -5
- package/src/tools/shard-translit.ts +16 -35
- package/src/tools/sub-venue/harvest.ts +235 -0
- package/src/tools/sub-venue/head-nouns.ts +242 -0
- package/src/tools/sub-venue/surfaces.ts +95 -0
- package/src/tools/sub-venue/table.ts +281 -0
- package/src/tools/sub-venue/wikidata.ts +85 -0
- package/src/tools/sub-venue-lexicon.ts +67 -886
- package/src/{align.ts → utils/align.ts} +2 -1
- package/src/{golden.ts → utils/golden.ts} +2 -3
- package/src/utils/index.ts +14 -0
- package/src/{license.ts → utils/license.ts} +1 -1
- package/src/{parquet.ts → utils/parquet.ts} +22 -9
- package/src/{split.ts → utils/split.ts} +3 -3
- package/out/src/adapter.d.ts.map +0 -1
- package/out/src/adapter.js.map +0 -1
- package/out/src/align.d.ts.map +0 -1
- package/out/src/align.js.map +0 -1
- package/out/src/format.d.ts +0 -14
- package/out/src/format.d.ts.map +0 -1
- package/out/src/format.js +0 -14
- package/out/src/format.js.map +0 -1
- package/out/src/golden.d.ts.map +0 -1
- package/out/src/golden.js.map +0 -1
- package/out/src/license.d.ts.map +0 -1
- package/out/src/license.js.map +0 -1
- package/out/src/parquet.d.ts.map +0 -1
- package/out/src/parquet.js.map +0 -1
- package/out/src/split.d.ts.map +0 -1
- package/out/src/split.js.map +0 -1
- package/out/src/synthesize-anchor-absorption.d.ts.map +0 -1
- package/out/src/synthesize-anchor-absorption.js.map +0 -1
- package/out/src/synthesize-boundary-stress.d.ts.map +0 -1
- package/out/src/synthesize-boundary-stress.js.map +0 -1
- package/out/src/synthesize-german.d.ts.map +0 -1
- package/out/src/synthesize-german.js.map +0 -1
- package/out/src/synthesize-house-venue.d.ts.map +0 -1
- package/out/src/synthesize-house-venue.js.map +0 -1
- package/out/src/synthesize-intersection.d.ts.map +0 -1
- package/out/src/synthesize-intersection.js.map +0 -1
- package/out/src/synthesize-no-street.d.ts.map +0 -1
- package/out/src/synthesize-no-street.js.map +0 -1
- package/out/src/synthesize-po-box.d.ts.map +0 -1
- package/out/src/synthesize-po-box.js.map +0 -1
- package/out/src/synthesize-street.d.ts.map +0 -1
- package/out/src/synthesize-street.js.map +0 -1
- package/out/src/synthesize.d.ts.map +0 -1
- package/out/src/synthesize.js.map +0 -1
- package/out/src/tokenize.d.ts.map +0 -1
- package/out/src/tokenize.js.map +0 -1
- package/out/src/wof-json.d.ts.map +0 -1
- package/out/src/wof-json.js.map +0 -1
- package/src/format.ts +0 -14
- /package/out/src/{align.js → utils/align.js} +0 -0
- /package/out/src/{golden.d.ts → utils/golden.d.ts} +0 -0
- /package/out/src/{license.d.ts → utils/license.d.ts} +0 -0
- /package/out/src/{tokenize.d.ts → utils/tokenize.d.ts} +0 -0
- /package/out/src/{tokenize.js → utils/tokenize.js} +0 -0
- /package/out/src/{wof-json.d.ts → utils/wof-json.d.ts} +0 -0
- /package/out/src/{wof-json.js → utils/wof-json.js} +0 -0
- /package/src/{synthesize-anchor-absorption.ts → synthesizers/anchor-absorption.ts} +0 -0
- /package/src/{tokenize.ts → utils/tokenize.ts} +0 -0
- /package/src/{wof-json.ts → utils/wof-json.ts} +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Extract `(postcode, locality, region, country)` tuples for the `trailing-region` shard.
|
|
7
|
+
*
|
|
8
|
+
* This step used to be a one-off. Its output survived — 17,908 rows at
|
|
9
|
+
* `$MAILWOMAN_DATA_ROOT/corpus/tuples/trailing-region-structured-tuples.jsonl` — but the code that produced it did
|
|
10
|
+
* not, so a note describing the join was the only record and it did not match what the databases contain. That is the
|
|
11
|
+
* reason this file exists: the shard is unbuildable for a new country without it.
|
|
12
|
+
*
|
|
13
|
+
* ## Two sources, because one route does not reach every country
|
|
14
|
+
*
|
|
15
|
+
* - **`postalcode-intl.db`** carries a real `parent_id` that resolves in the admin gazetteer. Measured share of rows
|
|
16
|
+
* with a parent: NL 97.5%, FR 90.7%, DE 66.1%, ES 34.9%, IT 27.4%; of those, 93.8–100% land on a `locality` or
|
|
17
|
+
* `localadmin`, and the region comes from that place's own ancestry. It is the ONLY shard with this — every
|
|
18
|
+
* `postalcode-geonames-*` and `postalcode-<cc>-overture.db` row reads `parent_id = 0`.
|
|
19
|
+
* - **GeoNames postal exports** carry the place and admin1 NAMES in columns 3 and 4, so there is nothing to join.
|
|
20
|
+
* `mailwoman corpus fetch geonames-postal` puts them on disk.
|
|
21
|
+
*
|
|
22
|
+
* A nearest-locality-centroid join was measured as the general fallback and REJECTED: scored against the `parent_id`
|
|
23
|
+
* truth, it agreed NL 81.1% / DE 44.7% / ES 35.1% / FR 29.0% / IT 13.5%. A locality's centroid sits at its middle, so
|
|
24
|
+
* an edge postcode is routinely nearer a neighbouring town's centroid. Do not reach for it again.
|
|
25
|
+
*
|
|
26
|
+
* ## The hub cap is PER COUNTRY, because a pooled one is a mixture
|
|
27
|
+
*
|
|
28
|
+
* A few localities act as catch-all parents — `Schwedt/Oder` claims 9,222 DE postcodes against a DE median of 1. Left
|
|
29
|
+
* in, a handful of places dominate the shard. But the distribution differs so much by country that one threshold is
|
|
30
|
+
* not one rule: a p99 pooled across the five countries lands at 522, which keeps 100% of ES and IT, 83% of FR, 49% of
|
|
31
|
+
* NL and 19% of DE.
|
|
32
|
+
*
|
|
33
|
+
* So the bound is a QUOTA and not a threshold. A threshold DELETES a locality that exceeds it, which removes exactly
|
|
34
|
+
* the largest cities — the places a parser most needs to have seen. A quota keeps every locality and bounds how many
|
|
35
|
+
* of its postcodes ride along, which is the balance the cap was reaching for without the deletion.
|
|
36
|
+
*
|
|
37
|
+
* ## Placement is data, not a formatting choice
|
|
38
|
+
*
|
|
39
|
+
* Each tuple is stamped with its country's {@link PostcodePlacement}. The same digits change tag with position, so a
|
|
40
|
+
* tuple that does not carry its placement teaches whichever convention the recipe happens to default to — see the
|
|
41
|
+
* recipe's header for the measurement.
|
|
42
|
+
*/
|
|
43
|
+
import { existsSync } from "node:fs";
|
|
44
|
+
import { join } from "node:path";
|
|
45
|
+
import { DatabaseSync } from "node:sqlite";
|
|
46
|
+
import { dataRootPath } from "@mailwoman/core/utils";
|
|
47
|
+
import { TSVSpliterator } from "spliterator";
|
|
48
|
+
/**
|
|
49
|
+
* Where a country writes the postcode, and the locale tag its rows carry.
|
|
50
|
+
*
|
|
51
|
+
* A country is in this table only when a gauntlet board row ATTESTS its surface. An absent country is not an oversight
|
|
52
|
+
* to be filled in by guessing: extracting it with the wrong placement teaches a convention that country does not use,
|
|
53
|
+
* which is worse than not teaching it at all. `LEADING_POSTCODE_COUNTRIES` in `@mailwoman/neural`'s
|
|
54
|
+
* `placetype-pair-prior.ts` draws the same line for the same reason.
|
|
55
|
+
*
|
|
56
|
+
* AU and ZA are the worked examples of the bar. Both look like obvious additions and neither qualifies: the board's AU
|
|
57
|
+
* rows are bare-city (`Melbourne`, `Sydney, Australia`) and carry no postcode at all, so nothing here says where AU
|
|
58
|
+
* writes it; and ZA's `14 Long St, Green Point, Cape Town, 8001` carries no REGION, which this shard requires — a fact
|
|
59
|
+
* its GeoNames export agrees with, at 100% place and 0% admin1.
|
|
60
|
+
*/
|
|
61
|
+
export const POSTCODE_CONVENTIONS = new Map([
|
|
62
|
+
// `Rue de l'Église, 3, 29217 Plougonvelin, Bretagne, France` and its siblings — `fr_structured`, `de_structured`,
|
|
63
|
+
// `es_structured`, `it_structured`, `pt_structured`, `mx_supermanzana`, `nl-op4-p-r-sloterdijk`.
|
|
64
|
+
["FR", { placement: "leading", locale: "fr-FR" }],
|
|
65
|
+
["DE", { placement: "leading", locale: "de-DE" }],
|
|
66
|
+
["ES", { placement: "leading", locale: "es-ES" }],
|
|
67
|
+
["IT", { placement: "leading", locale: "it-IT" }],
|
|
68
|
+
["NL", { placement: "leading", locale: "nl-NL" }],
|
|
69
|
+
["PT", { placement: "leading", locale: "pt-PT" }],
|
|
70
|
+
["MX", { placement: "leading", locale: "es-MX" }],
|
|
71
|
+
// `…, Barcelona 6001, Anzoátegui, Venezuela` — the four `ve_city_postcode_trailing_state` rows. No postcode source
|
|
72
|
+
// on disk and GeoNames does not publish VE, so this entry currently yields nothing; it is here because the
|
|
73
|
+
// placement is what makes the absence legible.
|
|
74
|
+
["VE", { placement: "after_locality", locale: "es-VE" }],
|
|
75
|
+
// `12 MG Road, Indiranagar, Bengaluru, Karnataka 560038, India` — three `in_*` rows, and `AGENTS.md` says the same
|
|
76
|
+
// ("en-IN is absent BECAUSE the PIN goes last"). The one trailing placement with real data behind it.
|
|
77
|
+
["IN", { placement: "after_region", locale: "en-IN" }],
|
|
78
|
+
]);
|
|
79
|
+
/**
|
|
80
|
+
* How many postcodes one locality may contribute.
|
|
81
|
+
*
|
|
82
|
+
* A quota rather than a cut-off — see the header. It bounds repetition without deleting a locality: a city with 9,222
|
|
83
|
+
* postcodes contributes this many and stays in the shard.
|
|
84
|
+
*/
|
|
85
|
+
export const DEFAULT_LOCALITY_QUOTA = 24;
|
|
86
|
+
/**
|
|
87
|
+
* Take at most `quota` tuples per locality, in the order they arrive.
|
|
88
|
+
*
|
|
89
|
+
* Order matters and is the caller's to choose: both readers below walk their source in id / file order, which is stable
|
|
90
|
+
* across runs, so the same quota selects the same rows.
|
|
91
|
+
*/
|
|
92
|
+
export function applyLocalityQuota(triples, quota = DEFAULT_LOCALITY_QUOTA) {
|
|
93
|
+
const seen = new Map();
|
|
94
|
+
const kept = [];
|
|
95
|
+
for (const triple of triples) {
|
|
96
|
+
const key = `${triple.cc} ${triple.locality}`;
|
|
97
|
+
const n = seen.get(key) ?? 0;
|
|
98
|
+
if (n >= quota)
|
|
99
|
+
continue;
|
|
100
|
+
seen.set(key, n + 1);
|
|
101
|
+
kept.push(triple);
|
|
102
|
+
}
|
|
103
|
+
return kept;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Take at most `budget` tuples per COUNTRY, in the order they arrive.
|
|
107
|
+
*
|
|
108
|
+
* A per-locality quota bounds how often one place repeats; it cannot bound a country. IN has 128,152 distinct
|
|
109
|
+
* localities, so even at a quota of ONE it contributes 63,533 rows against 39,790 from the other seven combined — the
|
|
110
|
+
* shard would teach the trailing surface as an Indian fact rather than a general one, and at 103,323 rows it would take
|
|
111
|
+
* 30% of an 8,000-step run's sample budget at three reps per row.
|
|
112
|
+
*
|
|
113
|
+
* Applied AFTER {@link applyLocalityQuota}, so a country's budget is spent on breadth (many localities) rather than on
|
|
114
|
+
* one city's postcode list.
|
|
115
|
+
*/
|
|
116
|
+
export function applyCountryBudget(triples, budget) {
|
|
117
|
+
const spent = new Map();
|
|
118
|
+
const kept = [];
|
|
119
|
+
for (const triple of triples) {
|
|
120
|
+
const cap = typeof budget === "number" ? budget : budget.get(triple.cc);
|
|
121
|
+
if (cap === undefined)
|
|
122
|
+
continue;
|
|
123
|
+
const n = spent.get(triple.cc) ?? 0;
|
|
124
|
+
if (n >= cap)
|
|
125
|
+
continue;
|
|
126
|
+
spent.set(triple.cc, n + 1);
|
|
127
|
+
kept.push(triple);
|
|
128
|
+
}
|
|
129
|
+
return kept;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Read triples out of `postalcode-intl.db` by following each postcode's `parent_id` into the admin gazetteer and that
|
|
133
|
+
* place's ancestry to a region.
|
|
134
|
+
*
|
|
135
|
+
* A postcode whose parent does not resolve, or whose parent has no region ancestor, is DROPPED rather than emitted with
|
|
136
|
+
* a blank — the recipe already skips a tuple with no region, and a blank here would hide how much of the source is
|
|
137
|
+
* actually reachable.
|
|
138
|
+
*/
|
|
139
|
+
export function readTriplesFromParentJoin(countries, options = {}) {
|
|
140
|
+
const postcodeDB = options.postcodeDB ?? String(dataRootPath("wof", "postalcode-intl.db"));
|
|
141
|
+
const adminDB = options.adminDB ?? String(dataRootPath("wof", "admin-global-priority-importance.db"));
|
|
142
|
+
if (!existsSync(postcodeDB) || !existsSync(adminDB))
|
|
143
|
+
return [];
|
|
144
|
+
const db = new DatabaseSync(adminDB, { readOnly: true });
|
|
145
|
+
try {
|
|
146
|
+
db.exec(`ATTACH DATABASE '${postcodeDB.replaceAll("'", "''")}' AS pc`);
|
|
147
|
+
const statement = db.prepare(`
|
|
148
|
+
SELECT p.name AS postcode, a.name AS locality, r.name AS region, c.name AS country, p.country AS cc
|
|
149
|
+
FROM pc.spr p
|
|
150
|
+
JOIN spr a ON a.id = p.parent_id AND a.placetype IN ('locality', 'localadmin')
|
|
151
|
+
JOIN ancestors anc ON anc.id = a.id AND anc.ancestor_placetype = 'region'
|
|
152
|
+
JOIN spr r ON r.id = anc.ancestor_id
|
|
153
|
+
JOIN ancestors cnc ON cnc.id = a.id AND cnc.ancestor_placetype = 'country'
|
|
154
|
+
JOIN spr c ON c.id = cnc.ancestor_id
|
|
155
|
+
WHERE p.country = ? AND p.parent_id > 0
|
|
156
|
+
ORDER BY p.id
|
|
157
|
+
`);
|
|
158
|
+
const out = [];
|
|
159
|
+
for (const cc of countries) {
|
|
160
|
+
const convention = POSTCODE_CONVENTIONS.get(cc);
|
|
161
|
+
if (!convention)
|
|
162
|
+
continue;
|
|
163
|
+
for (const row of statement.all(cc)) {
|
|
164
|
+
if (!row["postcode"] || !row["locality"] || !row["region"])
|
|
165
|
+
continue;
|
|
166
|
+
out.push({
|
|
167
|
+
postcode: row["postcode"],
|
|
168
|
+
locality: row["locality"],
|
|
169
|
+
region: row["region"],
|
|
170
|
+
country: row["country"] ?? "",
|
|
171
|
+
cc,
|
|
172
|
+
locale: convention.locale,
|
|
173
|
+
postcodePlacement: convention.placement,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return out;
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
db.close();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* GeoNames postal columns (0-based), matching `@mailwoman/corpus`'s `geonames-postal` adapter.
|
|
185
|
+
*/
|
|
186
|
+
const GEONAMES_COL = { country: 0, postcode: 1, place: 2, admin1: 3, admin2: 5 };
|
|
187
|
+
/**
|
|
188
|
+
* A predicate answering whether a name is a LOCALITY the admin gazetteer knows, for one country.
|
|
189
|
+
*
|
|
190
|
+
* The parent-join reader gets this for free — its query restricts the parent to `locality`/`localadmin`, so every name
|
|
191
|
+
* it emits is one by construction. The GeoNames reader has no such guarantee, and the gap is large enough to matter:
|
|
192
|
+
* sampling 400 rows per country against the gazetteer, the share of GeoNames place names that name a locality we know
|
|
193
|
+
* is PT 75%, IN 62%, **MX 41%**. The Mexican misses are colonias — `Zona Centro`, `San Fernando INFONAVIT`, `FOVISSSTE
|
|
194
|
+
* 3a Sección` — and a row teaching one of those as `locality` trains the locality/dependent_locality boundary in the
|
|
195
|
+
* wrong direction. Dropping the row instead costs coverage and teaches nothing false, which is the better of the two.
|
|
196
|
+
*
|
|
197
|
+
* Returns a predicate that answers `true` for everything when the gazetteer is not on disk, so a checkout without it
|
|
198
|
+
* builds the same rows it did before rather than silently emitting none.
|
|
199
|
+
*/
|
|
200
|
+
export function createKnownLocalityGate(country, adminDB) {
|
|
201
|
+
const path = adminDB ?? String(dataRootPath("wof", "admin-global-priority-importance.db"));
|
|
202
|
+
if (!existsSync(path))
|
|
203
|
+
return () => true;
|
|
204
|
+
const db = new DatabaseSync(path, { readOnly: true });
|
|
205
|
+
try {
|
|
206
|
+
const names = new Set();
|
|
207
|
+
for (const row of db
|
|
208
|
+
.prepare("SELECT name FROM spr WHERE country = ? AND placetype IN ('locality', 'localadmin')")
|
|
209
|
+
.all(country)) {
|
|
210
|
+
if (row.name) {
|
|
211
|
+
names.add(row.name.toLowerCase());
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// An empty set means the gazetteer has no localities for this country at all, which is a coverage fact about the
|
|
215
|
+
// gazetteer rather than a verdict on the source — so gate nothing rather than drop everything.
|
|
216
|
+
if (!names.size)
|
|
217
|
+
return () => true;
|
|
218
|
+
return (name) => names.has(name.toLowerCase());
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
db.close();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Read triples straight out of a GeoNames `<CC>.txt` export — no join, the names are columns 3 and 4.
|
|
226
|
+
*
|
|
227
|
+
* COLUMN 3 IS NOT THE LOCALITY. It is the finest-grained named place for the code, and for `560001` that is `Mahatma
|
|
228
|
+
* Gandhi Road` — a STREET — while the city, `Bengaluru`, is column 5 (admin2). MX is the same shape (`Roma Norte` is a
|
|
229
|
+
* colonia inside `Cuauhtémoc`) and so is PT (`Abrigada` inside `Alenquer`). Reading column 3 as the locality is how the
|
|
230
|
+
* v4.8.0 shard came to teach street names as cities. So `admin2` is the locality, `admin1` the region, and column 3 the
|
|
231
|
+
* DEPENDENT locality — which is also the left context the shard needs.
|
|
232
|
+
*
|
|
233
|
+
* WHICH COUNTRIES THIS READER CAN SERVE. It needs `admin2` (the city) and `admin1` (the region), and a country can
|
|
234
|
+
* publish one without the other. Measured 2026-08-23 across the exports on disk:
|
|
235
|
+
*
|
|
236
|
+
* | country | rows | admin1 | admin2 | usable here |
|
|
237
|
+
* | ---------- | --------: | -----: | -----: | ------------------------------- |
|
|
238
|
+
* | PT, MX, IN | 145k–207k | 100% | 100% | yes |
|
|
239
|
+
* | BD, LK | 1.3k–1.8k | 100% | 100% | yes |
|
|
240
|
+
* | PH | 2,317 | 88% | 88% | yes, 88% of rows |
|
|
241
|
+
* | PK | 2,563 | 100% | **0%** | NO — no city column |
|
|
242
|
+
* | TH | 903 | 100% | **1%** | NO — effectively no city column |
|
|
243
|
+
* | ID | 81,058 | **0%** | 0% | NO — no region either |
|
|
244
|
+
* | ZA | 3,920 | **0%** | — | NO |
|
|
245
|
+
*
|
|
246
|
+
* A country in the NO rows yields zero from this reader, and that is the correct outcome rather than a gap to route
|
|
247
|
+
* around: taking column 3 as the locality is what made the v4.8.0 shard train `Mahatma Gandhi Road` as a city. If one
|
|
248
|
+
* of them is wanted, it needs a city column from somewhere else, not a relaxed mapping.
|
|
249
|
+
*
|
|
250
|
+
* NOT PUBLISHED AT ALL by GeoNames, checked the same day: VE, VN, NP, MM, KH. Those are acquisition questions, and for
|
|
251
|
+
* VE specifically OpenAddresses 404s too — see the arc retrospective.
|
|
252
|
+
*
|
|
253
|
+
* Three source properties a caller cannot see from a row count, all handled here. Hyphen-format countries publish each
|
|
254
|
+
* code TWICE (`3750-000` and `3750000`, exactly 2.00× for PT and PL), so the first surface of a code wins and its twin
|
|
255
|
+
* is dropped. Some countries populate the place but not admin1 — ZA is 100% place, 0% region — which yields nothing
|
|
256
|
+
* this shard can use, so those rows are dropped rather than emitted with a blank region. And the "place name" is often
|
|
257
|
+
* a SUB-locality, which {@link createKnownLocalityGate} filters.
|
|
258
|
+
*/
|
|
259
|
+
export async function readTriplesFromGeonames(country, path, countryName, options = {}) {
|
|
260
|
+
const convention = POSTCODE_CONVENTIONS.get(country);
|
|
261
|
+
if (!convention || !existsSync(path))
|
|
262
|
+
return [];
|
|
263
|
+
const isKnownLocality = options.isKnownLocality ?? createKnownLocalityGate(country);
|
|
264
|
+
const out = [];
|
|
265
|
+
const seen = new Set();
|
|
266
|
+
for await (const cells of TSVSpliterator.fromAsync(path, { header: false })) {
|
|
267
|
+
const postcode = (cells[GEONAMES_COL.postcode] ?? "").trim();
|
|
268
|
+
const dependentLocality = (cells[GEONAMES_COL.place] ?? "").trim();
|
|
269
|
+
const locality = (cells[GEONAMES_COL.admin2] ?? "").trim();
|
|
270
|
+
const region = (cells[GEONAMES_COL.admin1] ?? "").trim();
|
|
271
|
+
if (!postcode || !locality || !region)
|
|
272
|
+
continue;
|
|
273
|
+
// The gate applies to the LOCALITY — admin2 — not to the fine-grained name, which is expected to be a street or
|
|
274
|
+
// a colonia and is emitted as the dependent locality rather than dropped.
|
|
275
|
+
if (!isKnownLocality(locality))
|
|
276
|
+
continue;
|
|
277
|
+
// A dependent locality that merely repeats its parent teaches a doubled segment, not a boundary.
|
|
278
|
+
const dep = dependentLocality && dependentLocality !== locality ? dependentLocality : "";
|
|
279
|
+
// The bare twin of a punctuated code carries no new fact, and keeping both doubles the country's weight.
|
|
280
|
+
const key = `${postcode.replaceAll("-", "")} ${locality} ${dep}`;
|
|
281
|
+
if (seen.has(key))
|
|
282
|
+
continue;
|
|
283
|
+
seen.add(key);
|
|
284
|
+
out.push({
|
|
285
|
+
postcode,
|
|
286
|
+
...(dep ? { dependentLocality: dep } : {}),
|
|
287
|
+
locality,
|
|
288
|
+
region,
|
|
289
|
+
country: countryName,
|
|
290
|
+
cc: country,
|
|
291
|
+
locale: convention.locale,
|
|
292
|
+
postcodePlacement: convention.placement,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
return out;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Resolve a GeoNames export path under the standard fetch out-root.
|
|
299
|
+
*/
|
|
300
|
+
export function geonamesPostalPath(country, sourcesRoot) {
|
|
301
|
+
const root = sourcesRoot ?? String(dataRootPath("corpus", "sources"));
|
|
302
|
+
return join(root, "geonames-postal", `${country.toUpperCase()}.txt`);
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=postcode-triples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode-triples.js","sourceRoot":"","sources":["../../../src/tools/postcode-triples.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAyB5C;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
|
|
1
|
+
{"version":3,"file":"shard-kryptonite.d.ts","sourceRoot":"","sources":["../../../src/tools/shard-kryptonite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAaH,MAAM,WAAW,sBAAsB;IACtC,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAiCD,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,sBAAsB,EAC/B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,IAAI,CAAC,CA6Df"}
|
|
@@ -20,8 +20,7 @@ import { mkdir } from "node:fs/promises";
|
|
|
20
20
|
import { join } from "node:path";
|
|
21
21
|
import { parseJSONStrict } from "@mailwoman/core/objects";
|
|
22
22
|
import { JSONSpliterator } from "spliterator";
|
|
23
|
-
import { alignRow } from "
|
|
24
|
-
import { PARQUET_COLUMNS, ROW_GROUP_SIZE, SHARD_COMPRESSION, writeShards } from "../parquet.js";
|
|
23
|
+
import { alignRow, PARQUET_COLUMNS, ROW_GROUP_SIZE, SHARD_COMPRESSION, writeShards } from "#utils";
|
|
25
24
|
async function* canonicalRows(jsonl, corpusVersion) {
|
|
26
25
|
for await (const raw of JSONSpliterator.fromAsync(jsonl)) {
|
|
27
26
|
// Strip sidecar underscore-prefixed fields the generator left behind for debugging.
|
|
@@ -71,7 +70,6 @@ export async function buildKryptoniteShard(options, report) {
|
|
|
71
70
|
// first_source_id-prefix inference). Without this, deepseek-kryptonite IDs would have
|
|
72
71
|
// to match a prefix in KNOWN_SOURCE_PREFIXES — we add it there too as a belt-and-braces.
|
|
73
72
|
for (const sh of newManifest.shards) {
|
|
74
|
-
;
|
|
75
73
|
sh.source = source;
|
|
76
74
|
}
|
|
77
75
|
// Compose the final corpus-v0.4.0 manifest: every shard from base + the new shard(s).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shard-kryptonite.js","sourceRoot":"","sources":["../../../src/tools/shard-kryptonite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"shard-kryptonite.js","sourceRoot":"","sources":["../../../src/tools/shard-kryptonite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAiBlG,KAAK,SAAS,CAAC,CAAC,aAAa,CAAC,KAAa,EAAE,aAAqB;IACjE,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,eAAe,CAAC,SAAS,CAA0B,KAAK,CAAC,EAAE,CAAC;QACnF,oFAAoF;QACpF,MAAM,UAAU,GAAG,GAAG,CAAC,YAAY,CAA2B,CAAA;QAE9D,MAAM;YACL,GAAG,EAAE,GAAG,CAAC,KAAK,CAAW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"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;
|
|
1
|
+
{"version":3,"file":"shard-translit.d.ts","sourceRoot":"","sources":["../../../src/tools/shard-translit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAwBH,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AA0ED,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,IAAI,CAAC,CAgGf"}
|
|
@@ -33,9 +33,8 @@ import { join } from "node:path";
|
|
|
33
33
|
import { parseJSONStrict } from "@mailwoman/core/objects";
|
|
34
34
|
import { mailwomanDataRoot, sha256File } from "@mailwoman/core/utils";
|
|
35
35
|
import { JSONSpliterator } from "spliterator";
|
|
36
|
-
import { alignRow } from "
|
|
36
|
+
import { alignRow, appendShape, LABELED_ROW_SCHEMA, PARQUET_COLUMNS, ROW_GROUP_SIZE, rowToParquet, SHARD_COMPRESSION, } from "#utils";
|
|
37
37
|
import { ParquetWriter } from "../parquet-wrapper/index.js";
|
|
38
|
-
import { LABELED_ROW_SCHEMA, PARQUET_COLUMNS, ROW_GROUP_SIZE, rowToParquet, SHARD_COMPRESSION } from "../parquet.js";
|
|
39
38
|
function toCanonicalRow(raw, corpusVersion) {
|
|
40
39
|
return {
|
|
41
40
|
raw: raw["raw"],
|
|
@@ -49,28 +48,6 @@ function toCanonicalRow(raw, corpusVersion) {
|
|
|
49
48
|
synth: raw["synth"],
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
|
-
function appendShape(row) {
|
|
53
|
-
const out = {
|
|
54
|
-
raw: row.raw,
|
|
55
|
-
tokens: row.tokens,
|
|
56
|
-
labels: row.labels,
|
|
57
|
-
country: row.country,
|
|
58
|
-
source: row.source,
|
|
59
|
-
source_id: row.source_id,
|
|
60
|
-
corpus_version: row.corpus_version,
|
|
61
|
-
license: row.license,
|
|
62
|
-
};
|
|
63
|
-
if (row.locale !== null) {
|
|
64
|
-
out.locale = row.locale;
|
|
65
|
-
}
|
|
66
|
-
if (row.synth_method !== null) {
|
|
67
|
-
out.synth_method = row.synth_method;
|
|
68
|
-
}
|
|
69
|
-
if (row.synth_base_id !== null) {
|
|
70
|
-
out.synth_base_id = row.synth_base_id;
|
|
71
|
-
}
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
51
|
/**
|
|
75
52
|
* Write one shard for a single source slug. Returns the populated ShardDescriptor + a list of quarantine reasons for
|
|
76
53
|
* rows that failed alignment.
|
|
@@ -105,9 +82,8 @@ async function writeOneShard(rows, outPath, source, corpusVersion) {
|
|
|
105
82
|
sha256,
|
|
106
83
|
first_source_id: firstSourceID,
|
|
107
84
|
last_source_id: lastSourceID,
|
|
108
|
-
// Stamp source so audit.ts attributes the shard without falling back to filename-prefix
|
|
109
|
-
|
|
110
|
-
...{ source },
|
|
85
|
+
// Stamp source so audit.ts attributes the shard without falling back to filename-prefix inference.
|
|
86
|
+
source,
|
|
111
87
|
};
|
|
112
88
|
}
|
|
113
89
|
function canonicalizeShardPath(path, legacyPrefix, canonicalPrefix) {
|
|
@@ -117,6 +93,7 @@ function canonicalizeShardPath(path, legacyPrefix, canonicalPrefix) {
|
|
|
117
93
|
}
|
|
118
94
|
export async function buildTranslitShard(options, report) {
|
|
119
95
|
const corpusVersion = options.corpusVersion ?? "0.4.0";
|
|
96
|
+
// This is a portable manifest namespace, not a host filesystem default.
|
|
120
97
|
const canonicalPathPrefix = options.canonicalPathPrefix ?? "/data/";
|
|
121
98
|
const legacyPathPrefix = options.legacyPathPrefix ?? `${mailwomanDataRoot()}/`;
|
|
122
99
|
if (!existsSync(options.jsonl))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shard-translit.js","sourceRoot":"","sources":["../../../src/tools/shard-translit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"shard-translit.js","sourceRoot":"","sources":["../../../src/tools/shard-translit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EACN,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,iBAAiB,GACjB,MAAM,QAAQ,CAAA;AAGf,OAAO,EAAE,aAAa,EAAE,MAAM,6BA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AC,CAAA;IAChG,MAAM,EAAE,CAAC,YAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,UAAU,IAAI,CAAC,MAAM,CAAC,MAAM,WAAW,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;IACtG,MAAM,EAAE,CAAC,iBAAiB,iBAAiB,EAAE,CAAC,CAAA;IAC9C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,IAAI,CAAC,CAAC,MAAM,CAAA;IAEtF,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QACjB,MAAM,EAAE,CAAC,qCAAqC,OAAO,aAAa,gBAAgB,QAAQ,mBAAmB,IAAI,CAAC,CAAA;IACnH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* @file The harvest side of the sub-venue lexicon: what one row of a harvestable source looks like,
|
|
7
|
+
* how a file of them is read back, and what a pass over them extracts — attested surfaces plus the
|
|
8
|
+
* measured shape of each designator's identifier half.
|
|
9
|
+
*
|
|
10
|
+
* {@link SubVenueHarvestRow} is SOURCE-NEUTRAL, and verified so: an Overture Places row from the
|
|
11
|
+
* `airport_terminal` category is `{ designatorID, name }` and fits unchanged. It is declared here
|
|
12
|
+
* rather than imported so the builder does not take a dependency on `@mailwoman/osm` (which
|
|
13
|
+
* `@mailwoman/corpus` does not depend on) just to name a shape it reads from a file.
|
|
14
|
+
*
|
|
15
|
+
* Two measurements shape {@link extractAttestedPhrases}, and both are the reason it is safe to run
|
|
16
|
+
* over raw OSM at all:
|
|
17
|
+
*
|
|
18
|
+
* **A feature's `name` is usually the VENUE's name, not a sub-venue phrase.** On the Berlin extract
|
|
19
|
+
* (2,060 matched features) a `railway=platform` is named `Stendaler Straße` and an `amenity=university`
|
|
20
|
+
* is named `Hertie School`; across 250,116 named Great Britain features only 6,003 (2.40%) contain a
|
|
21
|
+
* designator token at all. So names are not harvested wholesale — a name contributes only when it
|
|
22
|
+
* CONTAINS a phrase already in the surface index, which is what makes `Terminal E (Untere Ebene)`
|
|
23
|
+
* evidence and `Otto Lilienthal Flughafen Berlin Tegel` not.
|
|
24
|
+
*
|
|
25
|
+
* **A matched phrase belongs to the record the PHRASE names, not the record the ROW carries.**
|
|
26
|
+
* Attributing every hit to `row.designatorID` — the rule that matched the FEATURE — produced `west →
|
|
27
|
+
* platform`, `hall → platform` and `biggin → platform` on the GB extract, because a bus stop tagged
|
|
28
|
+
* `public_transport=platform` is named "Village Hall" or "West Kensington"; 108 of 133 OSM-derived
|
|
29
|
+
* surfaces named a different record than the one they pointed at. Attribution therefore runs through
|
|
30
|
+
* the index, and the row's own designator is kept as `context` — exactly the axis a confound board
|
|
31
|
+
* needs, since a `hall` seen on a platform is a confound and a `hall` seen on a terminal is evidence.
|
|
32
|
+
*/
|
|
33
|
+
import { type SurfaceIndex } from "./surfaces.ts";
|
|
34
|
+
import type { IdentifierShape, SubVenueSurface } from "./table.ts";
|
|
35
|
+
/**
|
|
36
|
+
* One row of a harvestable source, as read back off JSONL or out of a layer database.
|
|
37
|
+
*
|
|
38
|
+
* SOURCE-NEUTRAL by design, and verified so in wave 2: an Overture Places row from the `airport_terminal` category is
|
|
39
|
+
* `{ designatorID, name }` and fits unchanged. What did NOT fit was the harvest function's hardcoded `osm:name` source
|
|
40
|
+
* stamp — see `overture-subvenue.ts`'s docstring. Declared locally so the builder does not import `@mailwoman/osm`
|
|
41
|
+
* (which `@mailwoman/corpus` does not depend on) just to name a shape it reads from a file.
|
|
42
|
+
*/
|
|
43
|
+
export interface SubVenueHarvestRow {
|
|
44
|
+
/**
|
|
45
|
+
* The designator the SOURCE's rule assigned to the FEATURE. Not necessarily the record a matched phrase names — see
|
|
46
|
+
* this file's header on phrase attribution. Carried into {@link SubVenueSurface.context}.
|
|
47
|
+
*/
|
|
48
|
+
designatorID: string;
|
|
49
|
+
/**
|
|
50
|
+
* `venue` (station, airport, campus) or `sub_venue`, when the source's rule assigns one. The harvest itself does not
|
|
51
|
+
* read it; the sub-venue shard recipe fills its venue slot from it.
|
|
52
|
+
*/
|
|
53
|
+
tier?: string;
|
|
54
|
+
name?: string | null;
|
|
55
|
+
ref?: string | null;
|
|
56
|
+
localizedNames?: Record<string, string>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Classify an OSM `ref` into an {@link IdentifierShape} class.
|
|
60
|
+
*
|
|
61
|
+
* The classes are the ones Berlin's gates actually produced, plus the two aviation forms the corpus task names
|
|
62
|
+
* (`Terminal 2F` is digit-letter, `Concourse B` is letter). `range` covers both separators OSM uses for a gate serving
|
|
63
|
+
* more than one stand: `16-18` and `0/1`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function classifyIdentifier(ref: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Options for one harvest pass — which source stamp its surfaces carry and which region they were attested in.
|
|
68
|
+
*
|
|
69
|
+
* Both default to the OSM/unknown-region values wave 1 hardcoded, so an existing caller is unchanged.
|
|
70
|
+
*/
|
|
71
|
+
export interface HarvestOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Source family: `osm` yields `osm:name` / `osm:name:<lang>`, `overture` yields `overture:name`.
|
|
74
|
+
*/
|
|
75
|
+
source?: string;
|
|
76
|
+
/**
|
|
77
|
+
* ISO 3166-1 alpha-2 of the extract or partition. `""` when unknown.
|
|
78
|
+
*/
|
|
79
|
+
region?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Harvest attested phrases and identifier shapes out of a source's rows.
|
|
83
|
+
*
|
|
84
|
+
* `index` gates the name harvest — a name contributes only when it CONTAINS a phrase already in the table. That filter
|
|
85
|
+
* is the whole reason this function is safe to run over raw OSM: see this file's header for the Berlin measurement that
|
|
86
|
+
* motivated it. The index also decides ATTRIBUTION: a hit is a surface of the record the PHRASE names, and the row's
|
|
87
|
+
* own designator is recorded as `context`.
|
|
88
|
+
*
|
|
89
|
+
* Returns surfaces with real `observations` counts, so the lexicon can rank `terminal` above a phrase attested once.
|
|
90
|
+
*/
|
|
91
|
+
export declare function extractAttestedPhrases(rows: Iterable<SubVenueHarvestRow>, index: SurfaceIndex, options?: HarvestOptions): {
|
|
92
|
+
surfaces: SubVenueSurface[];
|
|
93
|
+
identifierShapes: IdentifierShape[];
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Read a JSONL file of {@link SubVenueHarvestRow}s. Blank lines and unparseable rows are skipped rather than fatal — an
|
|
97
|
+
* extract is a build output, and one malformed line should not cost the whole lexicon.
|
|
98
|
+
*/
|
|
99
|
+
export declare function readSubVenueJSONL(path: string): SubVenueHarvestRow[];
|
|
100
|
+
//# sourceMappingURL=harvest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harvest.d.ts","sourceRoot":"","sources":["../../../../src/tools/sub-venue/harvest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAOH,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAElE;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CActD;AAYD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAClC,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,cAAmB,GAC1B;IAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;IAAC,gBAAgB,EAAE,eAAe,EAAE,CAAA;CAAE,CAiFtE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAmBpE"}
|