@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
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Build the sub-venue designator lexicon (#35) — the vocabulary a corpus shard and, eventually,
|
|
7
|
-
* span proposer read to recognize `Terminal 5`, `North Terminal`, `Concourse B`, `ターミナル1` as
|
|
8
|
-
* venue-INTERIOR structure.
|
|
6
|
+
* @file Build the sub-venue designator lexicon (#35) — the vocabulary a corpus shard and, eventually,
|
|
7
|
+
* the span proposer read to recognize `Terminal 5`, `North Terminal`, `Concourse B`, `ターミナル1` as
|
|
8
|
+
* venue-INTERIOR structure. This is the assembly: the record schema lives in `sub-venue/table.ts`, the
|
|
9
|
+
* per-stage machinery in its siblings, and the curation decisions in `sub-venue-promotions.ts`.
|
|
9
10
|
*
|
|
10
11
|
* Reads the fetch outputs (`mailwoman corpus fetch wikidata-subvenue`, a JSONL of
|
|
11
12
|
* `@mailwoman/osm/sdk`'s `SubVenueSourceRow`s per region, and the Overture slice of `poi.db` via
|
|
12
|
-
* `overture-subvenue.ts`) and emits one committed JSON table.
|
|
13
|
-
* `@mailwoman/poi-taxonomy`'s `taxonomy.json` idiom exactly — typed records plus a FLAT phrase array
|
|
14
|
-
* keyed back to a record id, which is what makes a longest-match phrase index cheap to build over it.
|
|
15
|
-
* {@link SubVenueSurface} is this table's `SynonymEntry`.
|
|
13
|
+
* `overture-subvenue.ts`) and emits one committed JSON table.
|
|
16
14
|
*
|
|
17
15
|
* ── Determinism ──────────────────────────────────────────────────────────────────────────────────
|
|
18
16
|
* {@link buildSubVenueLexicon} is a PURE function of its inputs with a stable sort on every array, so
|
|
@@ -20,550 +18,39 @@
|
|
|
20
18
|
* reason `taxonomy.json` carries none — a clock in the artifact makes every regenerate a diff.
|
|
21
19
|
* Vintages live in `sources[]`, taken from the fetch manifests.
|
|
22
20
|
*
|
|
23
|
-
* ──
|
|
21
|
+
* ── Where the stages live ────────────────────────────────────────────────────────────────────────
|
|
22
|
+
* Each stage carries the measurements that shaped it; the order they run in is
|
|
23
|
+
* {@link buildSubVenueLexicon}'s own docstring, and it is load-bearing.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* `Otto Lilienthal Flughafen Berlin Tegel` not.
|
|
32
|
-
*
|
|
33
|
-
* **2. The identifier lives in `ref`, not in `name`.** Every one of Berlin's 26 `aeroway=gate`
|
|
34
|
-
* features is unnamed and carries only a `ref`: `13`, `6`, `0/1`, `14/15`, `16-18`. That means
|
|
35
|
-
* `Gate A12` is a RENDERING (`<designator> <ref>`) rather than a string anyone has written down, and a
|
|
36
|
-
* shard that wants to generate the designator+identifier form needs the identifier DISTRIBUTION, not
|
|
37
|
-
* a list of phrases. {@link IdentifierShape} is that distribution, and it is why the artifact has a
|
|
38
|
-
* section for it at all.
|
|
39
|
-
*
|
|
40
|
-
* **3. A matched phrase belongs to the record the PHRASE names, not to the record the ROW carries.**
|
|
41
|
-
* Wave 1 attributed every hit to `row.designatorID`, which is the rule that matched the FEATURE. On
|
|
42
|
-
* the GB extract that produced `west → platform`, `hall → platform`, `biggin → platform` — 108 of 133
|
|
43
|
-
* OSM-derived surfaces had a `phrase` that named a different record than the one they pointed at,
|
|
44
|
-
* because a bus stop tagged `public_transport=platform` is named "Village Hall" or "West Kensington".
|
|
45
|
-
* {@link extractAttestedPhrases} now takes a phrase → record INDEX and attributes by phrase; the row's
|
|
46
|
-
* own designator is kept as `context`, which is exactly the axis a confound board needs (a `hall` seen
|
|
47
|
-
* on a platform is a confound; a `hall` seen on a terminal is evidence).
|
|
25
|
+
* - `sub-venue/table.ts` — the emitted record schema plus the shipped seed vocabulary.
|
|
26
|
+
* - `sub-venue/surfaces.ts` — phrase normalization, the phrase → record index, and the name-match
|
|
27
|
+
* operator that gates the harvest.
|
|
28
|
+
* - `sub-venue/wikidata.ts` — the designator-label SPARQL payload turned into surfaces.
|
|
29
|
+
* - `sub-venue/head-nouns.ts` — the addressed form derived from an encyclopaedic label.
|
|
30
|
+
* - `sub-venue/harvest.ts` — the harvestable row shape, its JSONL reader, and the attestation pass.
|
|
48
31
|
*
|
|
49
32
|
* ── What `curated: false` means, and how a surface stops being it ────────────────────────────────
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* A surface becomes curated ONLY by matching a {@link SubVenuePromotion} in
|
|
57
|
-
* `sub-venue-promotions.ts` — a per-designator, per-LOCALE decision carrying the census that backs
|
|
58
|
-
* it. Promotion is per-locale because the same token is a designator in one language and a disaster
|
|
59
|
-
* in another: `hall` is `Halle 2` at Frankfurt and `Village Hall` at 3,205 British bus stops.
|
|
60
|
-
*
|
|
61
|
-
* ── The seed DUPLICATES `neural/venue-structure.ts`, knowingly ───────────────────────────────────
|
|
62
|
-
* `@mailwoman/corpus` does not depend on `@mailwoman/neural` (the dependency runs the other way for
|
|
63
|
-
* the training path, and pulling onnxruntime into a corpus build to read three string arrays would be
|
|
64
|
-
* absurd), so the shipped vocabulary is re-declared below. That is a drift surface and it is stated
|
|
65
|
-
* rather than hidden: `sub-venue-lexicon.test.ts` pins the seed's contents literally, so a change in
|
|
66
|
-
* either place fails a test rather than passing silently.
|
|
33
|
+
* Every machine-derived surface lands `curated: false`, and {@link SubVenueLexiconTable} consumers
|
|
34
|
+
* that gate parsing MUST filter to `curated: true`. A surface becomes curated ONLY by matching a
|
|
35
|
+
* {@link SubVenuePromotion} in `sub-venue-promotions.ts` — a per-designator, per-LOCALE decision
|
|
36
|
+
* carrying the census that backs it. Promotion is per-locale because the same token is a designator in
|
|
37
|
+
* one language and a disaster in another: `hall` is `Halle 2` at Frankfurt and `Village Hall` at 3,205
|
|
38
|
+
* British bus stops.
|
|
67
39
|
*/
|
|
68
40
|
import { readFileSync, statSync, writeFileSync } from "node:fs";
|
|
69
41
|
import { basename, join } from "node:path";
|
|
70
42
|
import { parseJSONStrict } from "@mailwoman/core/objects";
|
|
71
|
-
import { TextSpliterator } from "spliterator";
|
|
72
43
|
import { SUBVENUE_PROMOTIONS } from "./sub-venue-promotions.js";
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
export const LexiconTier = {
|
|
85
|
-
SubVenue: "subvenue",
|
|
86
|
-
Venue: "venue",
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* The vocabulary that already ships in `neural/venue-structure.ts`, re-declared. See the module docstring for why this
|
|
90
|
-
* duplication exists.
|
|
91
|
-
*
|
|
92
|
-
* `tier` is added here (the shipped list has no such field): the seven WOF placetypes plus `terminal`/`gate` are all
|
|
93
|
-
* venue-INTERIOR, except `campus` and `building`, which name a whole venue as often as a part of one. They are marked
|
|
94
|
-
* `subvenue` anyway, because that is the role the span proposer uses them in — `Building 43, Googleplex` is a unit
|
|
95
|
-
* inside a venue.
|
|
96
|
-
*/
|
|
97
|
-
export const SHIPPED_DESIGNATOR_SEED = [
|
|
98
|
-
{ id: "arcade", modifierEligible: true, provenance: ["wof:placetype"] },
|
|
99
|
-
{ id: "building", modifierEligible: false, provenance: ["wof:placetype"] },
|
|
100
|
-
{ id: "campus", modifierEligible: true, provenance: ["wof:placetype"] },
|
|
101
|
-
{ id: "concourse", modifierEligible: true, provenance: ["wof:placetype"] },
|
|
102
|
-
{ id: "enclosure", modifierEligible: false, provenance: ["wof:placetype"] },
|
|
103
|
-
{ id: "gate", modifierEligible: false, provenance: ["osm:aeroway=gate"] },
|
|
104
|
-
{ id: "installation", modifierEligible: false, provenance: ["wof:placetype"] },
|
|
105
|
-
{ id: "terminal", modifierEligible: true, provenance: ["osm:aeroway=terminal"] },
|
|
106
|
-
{ id: "wing", modifierEligible: true, provenance: ["wof:placetype"] },
|
|
107
|
-
];
|
|
108
|
-
/**
|
|
109
|
-
* The shipped positional modifiers, re-declared from `neural/venue-structure.ts`'s `VENUE_STRUCTURE_MODIFIERS`.
|
|
110
|
-
*/
|
|
111
|
-
export const SHIPPED_MODIFIER_SEED = [
|
|
112
|
-
"central",
|
|
113
|
-
"east",
|
|
114
|
-
"front",
|
|
115
|
-
"inner",
|
|
116
|
-
"lower",
|
|
117
|
-
"main",
|
|
118
|
-
"north",
|
|
119
|
-
"outer",
|
|
120
|
-
"rear",
|
|
121
|
-
"south",
|
|
122
|
-
"upper",
|
|
123
|
-
"west",
|
|
124
|
-
];
|
|
125
|
-
/**
|
|
126
|
-
* Designators the lexicon ADDS beyond what ships, each with the source that attests it.
|
|
127
|
-
*
|
|
128
|
-
* `platform`, `station` and `airport` come from the OSM extractor's rule table and are the rail/aviation venue-side
|
|
129
|
-
* vocabulary the corpus line needs. `hall` and `satellite` come from Wikidata concepts and from
|
|
130
|
-
* `wof-osm-placetype-map.mdx`'s own "plausible additions" note, which lists `hall` explicitly. `pier` joins them in
|
|
131
|
-
* wave 2 on 282 Overture attestations in the `pier` category plus 162 in the GB extract — the corpus task names `Pier
|
|
132
|
-
* C` as a target shape, so the record has to exist before a shard can generate it.
|
|
133
|
-
*
|
|
134
|
-
* None is `modifierEligible`: that claim needs a confound board per term AND per locale, and `sub-venue-promotions.ts`
|
|
135
|
-
* is where those live. A promotion marks a SURFACE usable; it does not widen the modifier grammar.
|
|
136
|
-
*/
|
|
137
|
-
export const PROPOSED_DESIGNATORS = [
|
|
138
|
-
{ id: "airport", tier: LexiconTier.Venue, provenance: ["osm:aeroway=aerodrome"] },
|
|
139
|
-
{ id: "hall", tier: LexiconTier.SubVenue, provenance: ["wikidata:Q240854"] },
|
|
140
|
-
{ id: "pier", tier: LexiconTier.SubVenue, provenance: ["overture:pier"] },
|
|
141
|
-
{ id: "platform", tier: LexiconTier.SubVenue, provenance: ["osm:public_transport=platform", "osm:railway=platform"] },
|
|
142
|
-
{ id: "satellite", tier: LexiconTier.SubVenue, provenance: ["wikidata:Q15990706"] },
|
|
143
|
-
{ id: "station", tier: LexiconTier.Venue, provenance: ["osm:railway=station"] },
|
|
144
|
-
];
|
|
145
|
-
/**
|
|
146
|
-
* `designatorID` → Wikidata QID, mirroring `fetch/wikidata-subvenue.ts`'s `SUBVENUE_CONCEPTS`. Re-declared here so the
|
|
147
|
-
* builder stays a pure function over PARSED input rather than reaching into a fetch module for a constant; the test
|
|
148
|
-
* pins the two against each other.
|
|
149
|
-
*/
|
|
150
|
-
export const CONCEPT_QIDS = {
|
|
151
|
-
terminal: "Q849706",
|
|
152
|
-
gate: "Q247739",
|
|
153
|
-
concourse: "Q862212",
|
|
154
|
-
campus: "Q209465",
|
|
155
|
-
building: "Q41176",
|
|
156
|
-
arcade: "Q186637",
|
|
157
|
-
hall: "Q240854",
|
|
158
|
-
satellite: "Q15990706",
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* How many real `ref` values each {@link IdentifierShape} keeps.
|
|
162
|
-
*
|
|
163
|
-
* Eight, not "all" and not one. The field exists so a shard author can see what a class actually CONTAINS — GB's
|
|
164
|
-
* `other` class turned out to be semicolon multi-values (`1;2;3`, `13;14`), which one example would have hidden and
|
|
165
|
-
* which the class name does not say. Eight fits a terminal line and covers the variety inside every class the GB
|
|
166
|
-
* extract produced. The COUNT lives in `observations`; this is a sample, not a census.
|
|
167
|
-
*/
|
|
168
|
-
const IDENTIFIER_EXAMPLES_PER_SHAPE = 8;
|
|
169
|
-
/**
|
|
170
|
-
* Scripts whose case is meaningful to fold. Everything else is left as written — see {@link SubVenueSurface.phrase}.
|
|
171
|
-
*/
|
|
172
|
-
const CASE_FOLDING_SCRIPT = /^[\p{Script=Latin}\p{Script=Cyrillic}\p{Script=Greek}\d\s\p{P}]+$/u;
|
|
173
|
-
/**
|
|
174
|
-
* Scripts written without spaces between words, where a token split cannot find a designator and a SUBSTRING test is
|
|
175
|
-
* the correct operator. Han, Hiragana, Katakana; Hangul is excluded because Korean does space its words.
|
|
176
|
-
*
|
|
177
|
-
* The Germanic-compound argument that keeps {@link nameContainsSurface} token-bounded for Latin script does not transfer
|
|
178
|
-
* here — there is no `-gate`/`-hall` street-name suffix class in Japanese, and `第1ターミナル` is unreachable by any token
|
|
179
|
-
* split. Measured on the Japan extract: see the harvest counts in `corpus/data/PROVENANCE.md`.
|
|
180
|
-
*/
|
|
181
|
-
const NON_SPACING_SCRIPT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u;
|
|
182
|
-
/**
|
|
183
|
-
* Normalize a surface for the table: trim, collapse internal whitespace, and lowercase ONLY when the string is entirely
|
|
184
|
-
* in a bicameral script. `ターミナルビル` and `航站楼` pass through untouched; `Flughafenterminal` folds.
|
|
185
|
-
*/
|
|
186
|
-
export function normalizeSurface(text) {
|
|
187
|
-
const trimmed = text.trim().replaceAll(/\s+/gu, " ");
|
|
188
|
-
return CASE_FOLDING_SCRIPT.test(trimmed) ? trimmed.toLowerCase() : trimmed;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Turn the Wikidata designator-label payload into surfaces.
|
|
192
|
-
*
|
|
193
|
-
* A row is dropped when its language tag is empty (an untagged literal, which Wikidata occasionally carries), when the
|
|
194
|
-
* QID maps to no designator in {@link CONCEPT_QIDS}, or when the normalized phrase is empty. Everything that survives
|
|
195
|
-
* lands `curated: false` — see the module docstring.
|
|
196
|
-
*/
|
|
197
|
-
export function surfacesFromWikidata(payload, conceptQIDs = CONCEPT_QIDS) {
|
|
198
|
-
const byQID = new Map(Object.entries(conceptQIDs).map(([id, qid]) => [qid, id]));
|
|
199
|
-
const envelope = payload;
|
|
200
|
-
const seen = new Set();
|
|
201
|
-
const out = [];
|
|
202
|
-
for (const binding of envelope.results?.bindings ?? []) {
|
|
203
|
-
const qid = binding.item?.value?.split("/").pop();
|
|
204
|
-
const recordID = qid ? byQID.get(qid) : undefined;
|
|
205
|
-
const lang = binding.lang?.value;
|
|
206
|
-
const raw = binding.label?.value;
|
|
207
|
-
if (!recordID || !lang || !raw)
|
|
208
|
-
continue;
|
|
209
|
-
const phrase = normalizeSurface(raw);
|
|
210
|
-
if (!phrase)
|
|
211
|
-
continue;
|
|
212
|
-
const source = binding.kind?.value === "alt" ? "wikidata:alt" : "wikidata:label";
|
|
213
|
-
// A concept can carry the same string as both a label and an alias, and across dialect subtags
|
|
214
|
-
// (`zh`, `zh-cn`, `zh-hans` all say 航站楼). Key the dedupe on the tuple that identifies a row.
|
|
215
|
-
const key = `${phrase}${recordID}${lang}${source}`;
|
|
216
|
-
if (seen.has(key))
|
|
217
|
-
continue;
|
|
218
|
-
seen.add(key);
|
|
219
|
-
out.push({
|
|
220
|
-
phrase,
|
|
221
|
-
recordID,
|
|
222
|
-
recordKind: "designator",
|
|
223
|
-
lang,
|
|
224
|
-
region: "",
|
|
225
|
-
source,
|
|
226
|
-
curated: false,
|
|
227
|
-
observations: 0,
|
|
228
|
-
context: {},
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
return out;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Classify an OSM `ref` into an {@link IdentifierShape} class.
|
|
235
|
-
*
|
|
236
|
-
* The classes are the ones Berlin's gates actually produced, plus the two aviation forms the corpus task names
|
|
237
|
-
* (`Terminal 2F` is digit-letter, `Concourse B` is letter). `range` covers both separators OSM uses for a gate serving
|
|
238
|
-
* more than one stand: `16-18` and `0/1`.
|
|
239
|
-
*/
|
|
240
|
-
export function classifyIdentifier(ref) {
|
|
241
|
-
const value = ref.trim();
|
|
242
|
-
if (/^[0-9]+$/.test(value))
|
|
243
|
-
return "digit";
|
|
244
|
-
if (/^[A-Za-z]$/.test(value))
|
|
245
|
-
return "letter";
|
|
246
|
-
if (/^[A-Za-z]+[0-9]+$/.test(value))
|
|
247
|
-
return "letter-digit";
|
|
248
|
-
if (/^[0-9]+[A-Za-z]+$/.test(value))
|
|
249
|
-
return "digit-letter";
|
|
250
|
-
if (/^[0-9A-Za-z]+\s*[-/]\s*[0-9A-Za-z]+$/.test(value))
|
|
251
|
-
return "range";
|
|
252
|
-
return "other";
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Index the surfaces accumulated so far by phrase. First writer wins, so a seed record beats a Wikidata alias that
|
|
256
|
-
* happens to collide — `terminal` stays the `terminal` designator even though it is also an Italian alias for it.
|
|
257
|
-
*/
|
|
258
|
-
export function buildSurfaceIndex(surfaces) {
|
|
259
|
-
const index = new Map();
|
|
260
|
-
for (const surface of surfaces) {
|
|
261
|
-
if (index.has(surface.phrase))
|
|
262
|
-
continue;
|
|
263
|
-
index.set(surface.phrase, { recordID: surface.recordID, recordKind: surface.recordKind });
|
|
264
|
-
}
|
|
265
|
-
return index;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Every known phrase found in `name`, as whole-token runs for spacing scripts and as substrings for non-spacing ones.
|
|
269
|
-
*
|
|
270
|
-
* Token-boundary matching for Latin script, not substring: `Nordterminal` is a real German compound in which `terminal`
|
|
271
|
-
* is a suffix, and a substring test would also fire on `Terminalstraße`. The compound case is a genuine miss and it is
|
|
272
|
-
* the right miss — admitting suffix matches would fire on every `-hall`/`-gate` compound in Germanic and Nordic street
|
|
273
|
-
* naming, which is exactly the confound class `Briggate`/`Kirkgate` represents.
|
|
274
|
-
*
|
|
275
|
-
* For Han/Kana names that rule finds nothing at all, because the script has no word boundaries: `第1ターミナル` splits into
|
|
276
|
-
* one token that matches no surface. There the LONGEST known substring is the correct operator, and the compound
|
|
277
|
-
* objection does not transfer — Japanese has no `-gate` street-name suffix class.
|
|
278
|
-
*/
|
|
279
|
-
export function nameContainsSurfaces(name, index) {
|
|
280
|
-
const normalized = normalizeSurface(name);
|
|
281
|
-
const hits = new Set();
|
|
282
|
-
for (const token of normalized.split(/[\s,()/]+/u)) {
|
|
283
|
-
const stripped = token.replaceAll(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "");
|
|
284
|
-
if (stripped && index.has(stripped)) {
|
|
285
|
-
hits.add(stripped);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (NON_SPACING_SCRIPT.test(normalized)) {
|
|
289
|
-
for (const [phrase] of index) {
|
|
290
|
-
if (NON_SPACING_SCRIPT.test(phrase) && normalized.includes(phrase)) {
|
|
291
|
-
hits.add(phrase);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return [...hits];
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Harvest attested phrases and identifier shapes out of a source's rows.
|
|
299
|
-
*
|
|
300
|
-
* `index` gates the name harvest — a name contributes only when it CONTAINS a phrase already in the table. That filter
|
|
301
|
-
* is the whole reason this function is safe to run over raw OSM: see the module docstring's finding 1 for the Berlin
|
|
302
|
-
* measurement that motivated it. The index also decides ATTRIBUTION (finding 3): a hit is a surface of the record the
|
|
303
|
-
* PHRASE names, and the row's own designator is recorded as `context`.
|
|
304
|
-
*
|
|
305
|
-
* Returns surfaces with real `observations` counts, so the lexicon can rank `terminal` above a phrase attested once.
|
|
306
|
-
*/
|
|
307
|
-
export function extractAttestedPhrases(rows, index, options = {}) {
|
|
308
|
-
const source = options.source ?? "osm";
|
|
309
|
-
const region = options.region ?? "";
|
|
310
|
-
/**
|
|
311
|
-
* `phrase\0lang\0source` → { count, context }.
|
|
312
|
-
*/
|
|
313
|
-
const surfaceCounts = new Map();
|
|
314
|
-
/**
|
|
315
|
-
* `designatorID\0shape` → { count, examples }.
|
|
316
|
-
*/
|
|
317
|
-
const shapes = new Map();
|
|
318
|
-
const note = (phrase, lang, sourceTag, context) => {
|
|
319
|
-
const key = `${phrase}${lang}${sourceTag}`;
|
|
320
|
-
const entry = surfaceCounts.get(key) ?? { count: 0, context: new Map() };
|
|
321
|
-
entry.count++;
|
|
322
|
-
entry.context.set(context, (entry.context.get(context) ?? 0) + 1);
|
|
323
|
-
surfaceCounts.set(key, entry);
|
|
324
|
-
};
|
|
325
|
-
for (const row of rows) {
|
|
326
|
-
if (row.name) {
|
|
327
|
-
for (const hit of nameContainsSurfaces(row.name, index)) {
|
|
328
|
-
// `und` — the default `name` tag carries no language. Overture's `name` is the same: a
|
|
329
|
-
// primary name in whatever language the place uses, untagged.
|
|
330
|
-
note(hit, "und", `${source}:name`, row.designatorID);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
for (const [lang, localized] of Object.entries(row.localizedNames ?? {})) {
|
|
334
|
-
for (const hit of nameContainsSurfaces(localized, index)) {
|
|
335
|
-
note(hit, lang, `${source}:name:${lang}`, row.designatorID);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
if (row.ref) {
|
|
339
|
-
const shape = classifyIdentifier(row.ref);
|
|
340
|
-
const key = `${row.designatorID}${shape}`;
|
|
341
|
-
const entry = shapes.get(key) ?? { count: 0, examples: new Set() };
|
|
342
|
-
entry.count++;
|
|
343
|
-
if (entry.examples.size < IDENTIFIER_EXAMPLES_PER_SHAPE) {
|
|
344
|
-
entry.examples.add(row.ref.trim());
|
|
345
|
-
}
|
|
346
|
-
shapes.set(key, entry);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
const surfaces = [...surfaceCounts].map(([key, entry]) => {
|
|
350
|
-
const [phrase, lang, sourceTag] = key.split("");
|
|
351
|
-
const record = index.get(phrase);
|
|
352
|
-
return {
|
|
353
|
-
phrase,
|
|
354
|
-
recordID: record.recordID,
|
|
355
|
-
recordKind: record.recordKind,
|
|
356
|
-
lang,
|
|
357
|
-
region,
|
|
358
|
-
source: sourceTag,
|
|
359
|
-
curated: false,
|
|
360
|
-
observations: entry.count,
|
|
361
|
-
context: Object.fromEntries([...entry.context].toSorted((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))),
|
|
362
|
-
};
|
|
363
|
-
});
|
|
364
|
-
const identifierShapes = [...shapes].map(([key, entry]) => {
|
|
365
|
-
const [designatorID, shape] = key.split("");
|
|
366
|
-
return {
|
|
367
|
-
designatorID,
|
|
368
|
-
region,
|
|
369
|
-
shape,
|
|
370
|
-
observations: entry.count,
|
|
371
|
-
examples: [...entry.examples].toSorted((a, b) => a.localeCompare(b)),
|
|
372
|
-
};
|
|
373
|
-
});
|
|
374
|
-
return { surfaces, identifierShapes };
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Diacritic-flattened ASCII fold, for comparing a Slavic or Turkish inflection against its Latin root.
|
|
378
|
-
*/
|
|
379
|
-
function asciiFold(text) {
|
|
380
|
-
return text
|
|
381
|
-
.normalize("NFD")
|
|
382
|
-
.replaceAll(/\p{Diacritic}/gu, "")
|
|
383
|
-
.toLowerCase();
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* How many leading characters two ASCII-folded forms must share for one to count as the other's inflection.
|
|
387
|
-
*
|
|
388
|
-
* Five, or the id's own length when that is shorter (`hall`, `gate`, `wing`, `pier` are four). Measured against the
|
|
389
|
-
* committed Wikidata pull: at five, `terminal`/`terminál`/`terminale`/`terminali`/`terminála`/`terminalo` are all
|
|
390
|
-
* accepted for `terminal` while `campo` and `campws` are both rejected for `campus` (they share four). At six the
|
|
391
|
-
* Spanish `satélite` is lost; at four, Italian `campo` is admitted and it means FIELD.
|
|
392
|
-
*/
|
|
393
|
-
const HEAD_NOUN_PREFIX_FLOOR = 5;
|
|
394
|
-
/**
|
|
395
|
-
* The shortest substring a non-Latin head-noun candidate may be. Two: `航站` and `터미널` are both real, `楼` alone is
|
|
396
|
-
* "building" and would fire on every Chinese building name.
|
|
397
|
-
*/
|
|
398
|
-
const NON_LATIN_HEAD_MIN_LENGTH = 2;
|
|
399
|
-
/**
|
|
400
|
-
* How many head-noun candidates one non-Latin record+language group may contribute. Six — enough to carry `ターミナル`,
|
|
401
|
-
* `ターミナルビル` and `旅客ターミナル` together, capped because the substring lattice of a nine-character label is large and, ranked
|
|
402
|
-
* by attesting-surface count, nothing past the sixth has more than the minimum two.
|
|
403
|
-
*/
|
|
404
|
-
const NON_LATIN_HEAD_CANDIDATE_CAP = 6;
|
|
405
|
-
/**
|
|
406
|
-
* Latin-script test — the scripts an ASCII-folded prefix comparison against a Latin designator id can work on.
|
|
407
|
-
*/
|
|
408
|
-
const LATIN_PHRASE = /^[\p{Script=Latin}\d\s\p{P}]+$/u;
|
|
409
|
-
/**
|
|
410
|
-
* The scripts the shared-substring derivation is allowed to run on: Han, Hiragana, Katakana, Hangul.
|
|
411
|
-
*
|
|
412
|
-
* NARROWER than "not Latin", and the narrowing was earned. Run over every non-Latin phrase in the table, the derivation
|
|
413
|
-
* produced 90 fragments of Cyrillic, Greek, Arabic, Thai, Burmese and Tamil words — `сгра`, `град`, `κτίρ`,
|
|
414
|
-
* `ิ่งก่อสร้า` — because those languages have exactly one surface per concept and the only substrings shared inside a
|
|
415
|
-
* group are pieces of one word. Every one of them was unusable, and none could ever be counted: `poi.db` is four
|
|
416
|
-
* countries and this wave's extracts are GB, DE, FR, ES and JP, so nothing in reach attests a Thai or Burmese surface.
|
|
417
|
-
* Deriving a candidate no available source can confirm is not a hypothesis, it is table weight.
|
|
418
|
-
*/
|
|
419
|
-
const SHARED_SUBSTRING_SCRIPT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
|
|
420
|
-
/**
|
|
421
|
-
* Derive the HEAD NOUN of every multi-part surface, so `terminal aeroportuaria` contributes the form anyone actually
|
|
422
|
-
* writes on an envelope.
|
|
423
|
-
*
|
|
424
|
-
* The problem this solves is the whole reason wave 1 shipped 1,014 uncurated surfaces: Wikidata's label for a concept
|
|
425
|
-
* is the ENCYCLOPAEDIC name (`terminal aeroportuaria`, `letištní terminál`, `havalimanı terminali`), while the
|
|
426
|
-
* addressed form is the bare head (`Terminal`, `Terminál`, `Terminali`). Nothing can promote the encyclopaedic form, so
|
|
427
|
-
* the head has to be extracted before the curation pass has anything to decide about.
|
|
428
|
-
*
|
|
429
|
-
* Two derivations, because the table holds two kinds of writing:
|
|
430
|
-
*
|
|
431
|
-
* - **Latin script — the COGNATE test.** A token is the head when its ASCII fold shares {@link HEAD_NOUN_PREFIX_FLOOR}
|
|
432
|
-
* leading characters with the designator's own canonical id. Nothing subtler survived contact with the data: an
|
|
433
|
-
* earlier version matched a token against any SINGLE-TOKEN surface of the record, and because Dutch `universiteit` is
|
|
434
|
-
* a one-token surface of `campus`, it derived `universitario`, `universitaire`, `üniversite` and twenty more as head
|
|
435
|
-
* nouns of `campus`. Those are the MODIFIER half of the label, and admitting them would have taught the harvest to
|
|
436
|
-
* read "Ciudad Universitaria" as sub-venue structure.
|
|
437
|
-
* - **Non-Latin script — the SHARED-SUBSTRING test.** The cognate test cannot reach a script the id is not written in,
|
|
438
|
-
* and for Han and Kana a token split finds nothing at all. So every substring of length ≥
|
|
439
|
-
* {@link NON_LATIN_HEAD_MIN_LENGTH} occurring in at least two DISTINCT surfaces of the same record and primary
|
|
440
|
-
* language becomes a candidate, ranked by how many surfaces carry it. Japanese yields `ターミナル` (in all five `ja`
|
|
441
|
-
* terminal labels) ahead of `ターミナルビル` (three); Chinese yields `航站`, `航站楼`, `航站樓`. Where the script DOES space its
|
|
442
|
-
* words (Korean, Greek, Cyrillic) a candidate must be a whole token, so `공항 터미널` ∩ `공항터미널` gives `터미널` and never a
|
|
443
|
-
* fragment.
|
|
444
|
-
*
|
|
445
|
-
* The non-Latin branch deliberately emits SEVERAL candidates instead of picking one. Choosing between `航站` and `航站楼`
|
|
446
|
-
* from Wikidata alone is guesswork; the Japan extract answers it by counting, and the promotion ledger records which
|
|
447
|
-
* count won. Everything derived lands `curated: false` — the derivation is a hypothesis about what the addressed form
|
|
448
|
-
* is, and a locale's own data is what confirms or kills it.
|
|
449
|
-
*/
|
|
450
|
-
export function deriveHeadNounSurfaces(surfaces) {
|
|
451
|
-
const derived = new Map();
|
|
452
|
-
const seen = new Set(surfaces.map((s) => `${s.phrase}${s.recordID}${s.lang}`));
|
|
453
|
-
const emit = (phrase, from) => {
|
|
454
|
-
if (phrase === from.phrase)
|
|
455
|
-
return;
|
|
456
|
-
const key = `${phrase}${from.recordID}${from.lang}`;
|
|
457
|
-
if (seen.has(key) || derived.has(key))
|
|
458
|
-
return;
|
|
459
|
-
derived.set(key, {
|
|
460
|
-
phrase,
|
|
461
|
-
recordID: from.recordID,
|
|
462
|
-
recordKind: from.recordKind,
|
|
463
|
-
lang: from.lang,
|
|
464
|
-
region: "",
|
|
465
|
-
source: "derived:head-noun",
|
|
466
|
-
curated: false,
|
|
467
|
-
observations: 0,
|
|
468
|
-
context: {},
|
|
469
|
-
});
|
|
470
|
-
};
|
|
471
|
-
// ── Spacing scripts: prefix-match a token against a single-token surface of the same record ──────
|
|
472
|
-
// Latin script: a token that is a cognate of the designator's own canonical id.
|
|
473
|
-
for (const surface of surfaces) {
|
|
474
|
-
if (!LATIN_PHRASE.test(surface.phrase))
|
|
475
|
-
continue;
|
|
476
|
-
const parts = surface.phrase.split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
477
|
-
if (parts.length < 2)
|
|
478
|
-
continue;
|
|
479
|
-
const root = asciiFold(surface.recordID);
|
|
480
|
-
const floor = Math.min(HEAD_NOUN_PREFIX_FLOOR, root.length);
|
|
481
|
-
for (const part of parts) {
|
|
482
|
-
const folded = asciiFold(part);
|
|
483
|
-
if (folded.length >= floor && commonPrefixLength(folded, root) >= floor) {
|
|
484
|
-
emit(part, surface);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
// Non-Latin script: substrings shared by two or more surfaces of the same record + language.
|
|
489
|
-
const groups = new Map();
|
|
490
|
-
for (const surface of surfaces) {
|
|
491
|
-
if (!SHARED_SUBSTRING_SCRIPT.test(surface.phrase))
|
|
492
|
-
continue;
|
|
493
|
-
// Group `zh`, `zh-cn`, `zh-hant` together: they are writing systems for one vocabulary, and the
|
|
494
|
-
// simplified/traditional pair is exactly the evidence a shared substring needs.
|
|
495
|
-
const key = `${surface.recordID} ${surface.lang.split(/[-_]/u)[0]}`;
|
|
496
|
-
const pool = groups.get(key) ?? new Set();
|
|
497
|
-
pool.add(surface.phrase);
|
|
498
|
-
groups.set(key, pool);
|
|
499
|
-
}
|
|
500
|
-
const candidatesByGroup = new Map();
|
|
501
|
-
for (const [key, pool] of groups) {
|
|
502
|
-
if (pool.size < 2)
|
|
503
|
-
continue;
|
|
504
|
-
candidatesByGroup.set(key, sharedSubstringCandidates(pool));
|
|
505
|
-
}
|
|
506
|
-
for (const surface of surfaces) {
|
|
507
|
-
if (!SHARED_SUBSTRING_SCRIPT.test(surface.phrase))
|
|
508
|
-
continue;
|
|
509
|
-
const key = `${surface.recordID} ${surface.lang.split(/[-_]/u)[0]}`;
|
|
510
|
-
for (const candidate of candidatesByGroup.get(key) ?? []) {
|
|
511
|
-
if (surface.phrase.includes(candidate)) {
|
|
512
|
-
emit(candidate, surface);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
return [...derived.values()];
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* Length of the shared leading run of two strings.
|
|
520
|
-
*/
|
|
521
|
-
function commonPrefixLength(a, b) {
|
|
522
|
-
const limit = Math.min(a.length, b.length);
|
|
523
|
-
let i = 0;
|
|
524
|
-
while (i < limit && a[i] === b[i]) {
|
|
525
|
-
i++;
|
|
526
|
-
}
|
|
527
|
-
return i;
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Substrings occurring in at least two DISTINCT members of `pool`, ranked by that count and then by length, capped at
|
|
531
|
-
* {@link NON_LATIN_HEAD_CANDIDATE_CAP}.
|
|
532
|
-
*
|
|
533
|
-
* A candidate never spans whitespace, and in a pool whose members contain whitespace a candidate must be a whole token
|
|
534
|
-
* of some member. That is what keeps Korean `공항 터미널` from contributing a fragment straddling the space.
|
|
535
|
-
*
|
|
536
|
-
* MAXIMAL candidates only: one contained in a longer candidate carried by the SAME number of surfaces is dropped, since
|
|
537
|
-
* counting can never separate the two. Every one of `ターミナル`'s five ja labels also contains `ターミ`, `ターミナ` and `ミナル`, so
|
|
538
|
-
* without this the group contributes four indistinguishable candidates and the Japan harvest returns four identical
|
|
539
|
-
* counts. `航站` survives next to `航站楼` because six surfaces carry it against that one's two.
|
|
540
|
-
*/
|
|
541
|
-
function sharedSubstringCandidates(pool) {
|
|
542
|
-
const phrases = [...pool];
|
|
543
|
-
const spaced = phrases.some((phrase) => /\s/u.test(phrase));
|
|
544
|
-
const tokens = spaced ? new Set(phrases.flatMap((phrase) => phrase.split(/\s+/u).filter(Boolean))) : null;
|
|
545
|
-
const counts = new Map();
|
|
546
|
-
for (const phrase of phrases) {
|
|
547
|
-
const local = new Set();
|
|
548
|
-
for (let length = NON_LATIN_HEAD_MIN_LENGTH; length <= phrase.length; length++) {
|
|
549
|
-
for (let start = 0; start + length <= phrase.length; start++) {
|
|
550
|
-
const candidate = phrase.slice(start, start + length);
|
|
551
|
-
if (/\s/u.test(candidate))
|
|
552
|
-
continue;
|
|
553
|
-
local.add(candidate);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
for (const candidate of local) {
|
|
557
|
-
counts.set(candidate, (counts.get(candidate) ?? 0) + 1);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
const kept = [...counts].filter(([candidate, count]) => count >= 2 && (!tokens || tokens.has(candidate)));
|
|
561
|
-
return kept
|
|
562
|
-
.filter(([candidate, count]) => kept.every(([other, otherCount]) => other === candidate || otherCount !== count || !other.includes(candidate)))
|
|
563
|
-
.toSorted((a, b) => b[1] - a[1] || b[0].length - a[0].length || a[0].localeCompare(b[0]))
|
|
564
|
-
.slice(0, NON_LATIN_HEAD_CANDIDATE_CAP)
|
|
565
|
-
.map(([candidate]) => candidate);
|
|
566
|
-
}
|
|
44
|
+
import { extractAttestedPhrases, readSubVenueJSONL } from "./sub-venue/harvest.js";
|
|
45
|
+
import { deriveHeadNounSurfaces } from "./sub-venue/head-nouns.js";
|
|
46
|
+
import { buildSurfaceIndex } from "./sub-venue/surfaces.js";
|
|
47
|
+
import { CONCEPT_QIDS, LexiconTier, PROPOSED_DESIGNATORS, SHIPPED_DESIGNATOR_SEED, SHIPPED_MODIFIER_SEED, SUBVENUE_LEXICON_VERSION, } from "./sub-venue/table.js";
|
|
48
|
+
import { surfacesFromWikidata } from "./sub-venue/wikidata.js";
|
|
49
|
+
export * from "./sub-venue/harvest.js";
|
|
50
|
+
export * from "./sub-venue/head-nouns.js";
|
|
51
|
+
export * from "./sub-venue/surfaces.js";
|
|
52
|
+
export * from "./sub-venue/table.js";
|
|
53
|
+
export * from "./sub-venue/wikidata.js";
|
|
567
54
|
/**
|
|
568
55
|
* Apply the curation decisions to a surface list, IN PLACE on a copy.
|
|
569
56
|
*
|
|
@@ -725,28 +212,6 @@ export function buildSubVenueLexicon(input) {
|
|
|
725
212
|
export function serializeSubVenueLexicon(table) {
|
|
726
213
|
return JSON.stringify(table, null, 2) + "\n";
|
|
727
214
|
}
|
|
728
|
-
/**
|
|
729
|
-
* Read a JSONL file of {@link SubVenueHarvestRow}s. Blank lines and unparseable rows are skipped rather than fatal — an
|
|
730
|
-
* extract is a build output, and one malformed line should not cost the whole lexicon.
|
|
731
|
-
*/
|
|
732
|
-
export function readSubVenueJSONL(path) {
|
|
733
|
-
const out = [];
|
|
734
|
-
// `TextSpliterator` rather than `split("\n")` — a whole-country extract runs to 250,000 lines
|
|
735
|
-
// (52 MB for Great Britain), and materializing every segment before reading the first is exactly
|
|
736
|
-
// what the repo lint rule exists to prevent.
|
|
737
|
-
for (const line of TextSpliterator.from(readFileSync(path, "utf8"))) {
|
|
738
|
-
const trimmed = line.trim();
|
|
739
|
-
if (!trimmed)
|
|
740
|
-
continue;
|
|
741
|
-
try {
|
|
742
|
-
out.push(parseJSONStrict(trimmed));
|
|
743
|
-
}
|
|
744
|
-
catch {
|
|
745
|
-
continue;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
return out;
|
|
749
|
-
}
|
|
750
215
|
/**
|
|
751
216
|
* Read the fetch outputs, build the table, and write it.
|
|
752
217
|
*
|