@mailwoman/resolver-wof-sqlite 11.2.0 → 11.4.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/lib/address/duplicate.ts +1 -1
- package/lib/address/keys/attribution.ts +6 -1
- package/lib/address/keys/build.ts +1 -1
- package/lib/address/keys/layout.ts +27 -1
- package/lib/address/keys/lookup.ts +2 -2
- package/lib/address/keys/point-lookup.ts +2 -2
- package/lib/address/number-forms.ts +42 -6
- package/lib/address/point/interpolation.ts +11 -3
- package/lib/address/point/schema.ts +1 -1
- package/lib/address/point.ts +15 -14
- package/lib/address/record.ts +1 -1
- package/lib/build/candidate.ts +136 -40
- package/lib/build/slim.ts +4 -1
- package/lib/build/sources.ts +50 -0
- package/lib/candidate/alias-bags.ts +22 -8
- package/lib/candidate/ancestors/schema.ts +1 -1
- package/lib/candidate/ancestors/sidecar.ts +13 -2
- package/lib/candidate/bare-admin-names.ts +1 -1
- package/lib/{capital-schema.ts → candidate/capital-schema.ts} +3 -3
- package/lib/{capitals.ts → candidate/capitals.ts} +1 -1
- package/lib/candidate/country-display-names.ts +1 -1
- package/lib/candidate/{extract-fold.ts → extract-rows.ts} +7 -4
- package/lib/candidate/importance.ts +86 -8
- package/lib/candidate/key-fold.ts +1 -1
- package/lib/candidate/lookup.ts +79 -48
- package/lib/candidate/name-roles.ts +1 -1
- package/lib/candidate/nickname-namesakes.ts +8 -1
- package/lib/candidate/overture-twins.ts +83 -0
- package/lib/candidate/place-attrs.ts +2 -2
- package/lib/candidate/postcode-browse.ts +173 -0
- package/lib/candidate/schema.ts +43 -2
- package/lib/candidate/scoring.ts +4 -4
- package/lib/convention.ts +1 -1
- package/lib/env.ts +15 -3
- package/lib/fst/builder.ts +8 -6
- package/lib/fst/deserialize-web.ts +1 -1
- package/lib/fst/freshness.ts +2 -2
- package/lib/fst/serialize.ts +1 -1
- package/lib/fts/query.ts +1 -1
- package/lib/{search-fetch.ts → fts/search-fetch.ts} +2 -2
- package/lib/geonames/aliases.ts +37 -33
- package/lib/geonames/postal.ts +3 -3
- package/lib/index.ts +20 -17
- package/lib/{postal/city → labels/locality/postal-city}/alias/lookup.ts +1 -1
- package/lib/{postal/city → labels/locality/postal-city}/candidate-schema.ts +1 -1
- package/lib/labels/locality.ts +6 -0
- package/lib/{region-keys.ts → labels/region.ts} +5 -2
- package/lib/{street → labels/street}/centroid/schema.ts +1 -1
- package/lib/{street → labels/street}/centroid.ts +7 -7
- package/lib/{interpolation.ts → labels/street/interpolation.ts} +56 -5
- package/lib/labels/street/locale.ts +117 -0
- package/lib/{street → labels/street}/morphology/fst/loader.ts +1 -1
- package/lib/{street → labels/street}/name-lookup.ts +2 -0
- package/lib/{street → labels/street}/normalize.ts +293 -133
- package/lib/{street → labels/street}/segment-schema.ts +1 -1
- package/lib/{street → labels/street}/table.ts +1 -1
- package/lib/labels/street.ts +11 -0
- package/lib/landmark/rows.ts +1 -1
- package/lib/lookup/browse.ts +304 -0
- package/lib/{extracts.ts → lookup/extracts.ts} +1 -1
- package/lib/lookup/former-divisions.ts +183 -0
- package/lib/{postcode-point-lookup.ts → lookup/postcode-point.ts} +5 -0
- package/lib/{reverse.ts → lookup/reverse.ts} +4 -4
- package/lib/{types.ts → lookup/types.ts} +10 -0
- package/lib/lookup.ts +21 -31
- package/lib/poi/schema.ts +1 -1
- package/lib/{primary-preference.ts → ranking/primary-preference.ts} +5 -0
- package/lib/schema/overture-match.ts +79 -0
- package/lib/{place-importance-schema.ts → schema/place-importance.ts} +86 -0
- package/lib/schema.ts +3 -3
- package/lib/sqlite/convention-source.ts +1 -1
- package/lib/uprn/existence.ts +2 -0
- package/lib/{weights-overlay-linker.ts → weights/overlay-linker.ts} +244 -103
- package/out/address/duplicate.js +1 -1
- package/out/address/duplicate.js.map +1 -1
- package/out/address/keys/attribution.d.ts +4 -0
- package/out/address/keys/attribution.d.ts.map +1 -1
- package/out/address/keys/attribution.js +5 -1
- package/out/address/keys/attribution.js.map +1 -1
- package/out/address/keys/build.d.ts.map +1 -1
- package/out/address/keys/build.js +1 -1
- package/out/address/keys/build.js.map +1 -1
- package/out/address/keys/layout.d.ts +18 -1
- package/out/address/keys/layout.d.ts.map +1 -1
- package/out/address/keys/layout.js +23 -1
- package/out/address/keys/layout.js.map +1 -1
- package/out/address/keys/lookup.js +2 -2
- package/out/address/keys/lookup.js.map +1 -1
- package/out/address/keys/point-lookup.d.ts.map +1 -1
- package/out/address/keys/point-lookup.js +2 -2
- package/out/address/keys/point-lookup.js.map +1 -1
- package/out/address/number-forms.d.ts +6 -1
- package/out/address/number-forms.d.ts.map +1 -1
- package/out/address/number-forms.js +36 -5
- package/out/address/number-forms.js.map +1 -1
- package/out/address/point/interpolation.d.ts +1 -1
- package/out/address/point/interpolation.d.ts.map +1 -1
- package/out/address/point/interpolation.js +9 -2
- package/out/address/point/interpolation.js.map +1 -1
- package/out/address/point/schema.d.ts +1 -1
- package/out/address/point/schema.d.ts.map +1 -1
- package/out/address/point.d.ts +4 -5
- package/out/address/point.d.ts.map +1 -1
- package/out/address/point.js +11 -11
- package/out/address/point.js.map +1 -1
- package/out/address/record.d.ts +1 -1
- package/out/address/record.d.ts.map +1 -1
- package/out/address/record.js +1 -1
- package/out/address/record.js.map +1 -1
- package/out/build/candidate.d.ts +26 -1
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +71 -32
- package/out/build/candidate.js.map +1 -1
- package/out/build/slim.d.ts.map +1 -1
- package/out/build/slim.js +4 -1
- package/out/build/slim.js.map +1 -1
- package/out/build/sources.d.ts +32 -0
- package/out/build/sources.d.ts.map +1 -0
- package/out/build/sources.js +35 -0
- package/out/build/sources.js.map +1 -0
- package/out/candidate/alias-bags.d.ts +0 -3
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +22 -7
- package/out/candidate/alias-bags.js.map +1 -1
- package/out/candidate/ancestors/schema.d.ts +1 -1
- package/out/candidate/ancestors/schema.d.ts.map +1 -1
- package/out/candidate/ancestors/sidecar.d.ts +0 -3
- package/out/candidate/ancestors/sidecar.d.ts.map +1 -1
- package/out/candidate/ancestors/sidecar.js +16 -2
- package/out/candidate/ancestors/sidecar.js.map +1 -1
- package/out/candidate/bare-admin-names.js +1 -1
- package/out/candidate/bare-admin-names.js.map +1 -1
- package/out/{capital-schema.d.ts → candidate/capital-schema.d.ts} +2 -2
- package/out/candidate/capital-schema.d.ts.map +1 -0
- package/out/{capital-schema.js → candidate/capital-schema.js} +2 -2
- package/out/candidate/capital-schema.js.map +1 -0
- package/out/candidate/capitals.d.ts.map +1 -0
- package/out/{capitals.js → candidate/capitals.js} +1 -1
- package/out/candidate/capitals.js.map +1 -0
- package/out/candidate/country-display-names.js +1 -1
- package/out/candidate/country-display-names.js.map +1 -1
- package/out/{coverage-manifest-schema.d.ts → candidate/coverage-manifest.d.ts} +1 -1
- package/out/candidate/coverage-manifest.d.ts.map +1 -0
- package/out/{coverage-manifest-schema.js → candidate/coverage-manifest.js} +1 -1
- package/out/candidate/coverage-manifest.js.map +1 -0
- package/out/candidate/{extract-fold.d.ts → extract-rows.d.ts} +2 -2
- package/out/candidate/extract-rows.d.ts.map +1 -0
- package/out/candidate/{extract-fold.js → extract-rows.js} +8 -5
- package/out/candidate/extract-rows.js.map +1 -0
- package/out/candidate/importance.d.ts +34 -3
- package/out/candidate/importance.d.ts.map +1 -1
- package/out/candidate/importance.js +53 -8
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/key-fold.d.ts +1 -1
- package/out/candidate/key-fold.d.ts.map +1 -1
- package/out/candidate/key-fold.js +1 -1
- package/out/candidate/key-fold.js.map +1 -1
- package/out/candidate/lookup.d.ts +5 -1
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +59 -43
- package/out/candidate/lookup.js.map +1 -1
- package/out/candidate/name-roles.d.ts.map +1 -1
- package/out/candidate/name-roles.js +1 -1
- package/out/candidate/name-roles.js.map +1 -1
- package/out/candidate/nickname-namesakes.d.ts +0 -4
- package/out/candidate/nickname-namesakes.d.ts.map +1 -1
- package/out/candidate/nickname-namesakes.js +12 -1
- package/out/candidate/nickname-namesakes.js.map +1 -1
- package/out/candidate/overture-twins.d.ts +30 -0
- package/out/candidate/overture-twins.d.ts.map +1 -0
- package/out/candidate/overture-twins.js +40 -0
- package/out/candidate/overture-twins.js.map +1 -0
- package/out/candidate/place-attrs.d.ts +2 -2
- package/out/candidate/postcode-browse.d.ts +36 -0
- package/out/candidate/postcode-browse.d.ts.map +1 -0
- package/out/candidate/postcode-browse.js +119 -0
- package/out/candidate/postcode-browse.js.map +1 -0
- package/out/candidate/schema.d.ts +30 -2
- package/out/candidate/schema.d.ts.map +1 -1
- package/out/candidate/schema.js +29 -0
- package/out/candidate/schema.js.map +1 -1
- package/out/candidate/scoring.d.ts +3 -3
- package/out/candidate/scoring.d.ts.map +1 -1
- package/out/candidate/scoring.js +2 -2
- package/out/candidate/scoring.js.map +1 -1
- package/out/convention.d.ts +1 -1
- package/out/convention.d.ts.map +1 -1
- package/out/env.d.ts +3 -0
- package/out/env.d.ts.map +1 -1
- package/out/env.js +14 -3
- package/out/env.js.map +1 -1
- package/out/fst/builder.d.ts.map +1 -1
- package/out/fst/builder.js +8 -6
- package/out/fst/builder.js.map +1 -1
- package/out/fst/deserialize-web.js +1 -1
- package/out/fst/deserialize-web.js.map +1 -1
- package/out/fst/freshness.js +2 -2
- package/out/fst/freshness.js.map +1 -1
- package/out/fst/serialize.js +1 -1
- package/out/fst/serialize.js.map +1 -1
- package/out/fts/query.d.ts +1 -1
- package/out/fts/query.d.ts.map +1 -1
- package/out/{search-fetch.d.ts → fts/search-fetch.d.ts} +2 -2
- package/out/fts/search-fetch.d.ts.map +1 -0
- package/out/fts/search-fetch.js.map +1 -0
- package/out/geonames/aliases.d.ts +18 -18
- package/out/geonames/aliases.d.ts.map +1 -1
- package/out/geonames/aliases.js +17 -17
- package/out/geonames/aliases.js.map +1 -1
- package/out/geonames/postal.d.ts +1 -1
- package/out/geonames/postal.js +3 -3
- package/out/index.d.ts +17 -17
- package/out/index.d.ts.map +1 -1
- package/out/index.js +12 -12
- package/out/index.js.map +1 -1
- package/out/{postal/city → labels/locality/postal-city}/alias/lookup.d.ts +1 -1
- package/out/labels/locality/postal-city/alias/lookup.d.ts.map +1 -0
- package/out/labels/locality/postal-city/alias/lookup.js.map +1 -0
- package/out/labels/locality/postal-city/alias/schema.d.ts.map +1 -0
- package/out/labels/locality/postal-city/alias/schema.js.map +1 -0
- package/out/{postal/city → labels/locality/postal-city}/candidate-schema.d.ts +1 -1
- package/out/labels/locality/postal-city/candidate-schema.d.ts.map +1 -0
- package/out/labels/locality/postal-city/candidate-schema.js.map +1 -0
- package/out/labels/locality.d.ts +4 -0
- package/out/labels/locality.d.ts.map +1 -0
- package/out/labels/locality.js +6 -0
- package/out/labels/locality.js.map +1 -0
- package/out/{region-keys.d.ts → labels/region.d.ts} +1 -1
- package/out/{region-keys.d.ts.map → labels/region.d.ts.map} +1 -1
- package/out/{region-keys.js → labels/region.js} +6 -3
- package/out/labels/region.js.map +1 -0
- package/out/{street → labels/street}/centroid/schema.d.ts +1 -1
- package/out/labels/street/centroid/schema.d.ts.map +1 -0
- package/out/labels/street/centroid/schema.js.map +1 -0
- package/out/{street → labels/street}/centroid.d.ts +5 -5
- package/out/labels/street/centroid.d.ts.map +1 -0
- package/out/{street → labels/street}/centroid.js +5 -5
- package/out/labels/street/centroid.js.map +1 -0
- package/out/{interpolation.d.ts → labels/street/interpolation.d.ts} +6 -1
- package/out/labels/street/interpolation.d.ts.map +1 -0
- package/out/{interpolation.js → labels/street/interpolation.js} +40 -9
- package/out/labels/street/interpolation.js.map +1 -0
- package/out/labels/street/locale.d.ts +26 -0
- package/out/labels/street/locale.d.ts.map +1 -0
- package/out/labels/street/locale.js +98 -0
- package/out/labels/street/locale.js.map +1 -0
- package/out/labels/street/morphology/fst/builder.d.ts.map +1 -0
- package/out/labels/street/morphology/fst/builder.js.map +1 -0
- package/out/labels/street/morphology/fst/loader.d.ts.map +1 -0
- package/out/{street → labels/street}/morphology/fst/loader.js +1 -1
- package/out/labels/street/morphology/fst/loader.js.map +1 -0
- package/out/labels/street/name-lookup.d.ts.map +1 -0
- package/out/{street → labels/street}/name-lookup.js +2 -0
- package/out/labels/street/name-lookup.js.map +1 -0
- package/out/labels/street/normalize.d.ts +207 -0
- package/out/labels/street/normalize.d.ts.map +1 -0
- package/out/{street → labels/street}/normalize.js +198 -119
- package/out/labels/street/normalize.js.map +1 -0
- package/out/{street → labels/street}/segment-schema.d.ts +1 -1
- package/out/labels/street/segment-schema.d.ts.map +1 -0
- package/out/labels/street/segment-schema.js.map +1 -0
- package/out/labels/street/table.d.ts.map +1 -0
- package/out/{street → labels/street}/table.js +1 -1
- package/out/labels/street/table.js.map +1 -0
- package/out/labels/street.d.ts +9 -0
- package/out/labels/street.d.ts.map +1 -0
- package/out/labels/street.js +11 -0
- package/out/labels/street.js.map +1 -0
- package/out/landmark/rows.js +1 -1
- package/out/landmark/rows.js.map +1 -1
- package/out/lookup/browse.d.ts +79 -0
- package/out/lookup/browse.d.ts.map +1 -0
- package/out/lookup/browse.js +194 -0
- package/out/lookup/browse.js.map +1 -0
- package/out/lookup/exact-match.d.ts.map +1 -0
- package/out/lookup/exact-match.js.map +1 -0
- package/out/lookup/extracts.d.ts.map +1 -0
- package/out/{extracts.js → lookup/extracts.js} +1 -1
- package/out/lookup/extracts.js.map +1 -0
- package/out/lookup/former-divisions.d.ts +99 -0
- package/out/lookup/former-divisions.d.ts.map +1 -0
- package/out/lookup/former-divisions.js +98 -0
- package/out/lookup/former-divisions.js.map +1 -0
- package/out/{postcode-point-lookup.d.ts → lookup/postcode-point.d.ts} +5 -1
- package/out/lookup/postcode-point.d.ts.map +1 -0
- package/out/{postcode-point-lookup.js → lookup/postcode-point.js} +1 -1
- package/out/lookup/postcode-point.js.map +1 -0
- package/out/{reverse.d.ts → lookup/reverse.d.ts} +1 -1
- package/out/lookup/reverse.d.ts.map +1 -0
- package/out/{reverse.js → lookup/reverse.js} +3 -3
- package/out/lookup/reverse.js.map +1 -0
- package/out/{types.d.ts → lookup/types.d.ts} +9 -0
- package/out/lookup/types.d.ts.map +1 -0
- package/out/lookup/types.js.map +1 -0
- package/out/lookup.d.ts +4 -4
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +14 -20
- package/out/lookup.js.map +1 -1
- package/out/poi/schema.d.ts +1 -1
- package/out/poi/schema.d.ts.map +1 -1
- package/out/ranking/name-score.d.ts.map +1 -0
- package/out/ranking/name-score.js.map +1 -0
- package/out/ranking/primary-preference.d.ts.map +1 -0
- package/out/{primary-preference.js → ranking/primary-preference.js} +4 -0
- package/out/ranking/primary-preference.js.map +1 -0
- package/out/ranking/proximity-rerank.d.ts.map +1 -0
- package/out/ranking/proximity-rerank.js.map +1 -0
- package/out/{ranking-weights.d.ts → ranking/weights.d.ts} +1 -1
- package/out/ranking/weights.d.ts.map +1 -0
- package/out/{ranking-weights.js → ranking/weights.js} +1 -1
- package/out/ranking/weights.js.map +1 -0
- package/out/schema/importance-source.d.ts.map +1 -0
- package/out/schema/importance-source.js.map +1 -0
- package/out/schema/overture-match.d.ts +53 -0
- package/out/schema/overture-match.d.ts.map +1 -0
- package/out/schema/overture-match.js +33 -0
- package/out/schema/overture-match.js.map +1 -0
- package/out/{place-importance-schema.d.ts → schema/place-importance.d.ts} +50 -1
- package/out/schema/place-importance.d.ts.map +1 -0
- package/out/{place-importance-schema.js → schema/place-importance.js} +34 -1
- package/out/schema/place-importance.js.map +1 -0
- package/out/{polygon-schema.d.ts → schema/polygon.d.ts} +1 -1
- package/out/schema/polygon.d.ts.map +1 -0
- package/out/{polygon-schema.js → schema/polygon.js} +1 -1
- package/out/schema/polygon.js.map +1 -0
- package/out/{unified-schema.d.ts → schema/unified.d.ts} +1 -1
- package/out/schema/unified.d.ts.map +1 -0
- package/out/{unified-schema.js → schema/unified.js} +1 -1
- package/out/schema/unified.js.map +1 -0
- package/out/schema.d.ts +3 -3
- package/out/sqlite/convention-source.js +1 -1
- package/out/sqlite/convention-source.js.map +1 -1
- package/out/uprn/existence.d.ts.map +1 -1
- package/out/uprn/existence.js +2 -0
- package/out/uprn/existence.js.map +1 -1
- package/out/{weights-overlay-linker.d.ts → weights/overlay-linker.d.ts} +43 -24
- package/out/weights/overlay-linker.d.ts.map +1 -0
- package/out/{weights-overlay-linker.js → weights/overlay-linker.js} +182 -66
- package/out/weights/overlay-linker.js.map +1 -0
- package/package.json +12 -32
- package/lib/postal.ts +0 -6
- package/lib/street/locale.ts +0 -64
- package/lib/street.ts +0 -11
- package/out/candidate/extract-fold.d.ts.map +0 -1
- package/out/candidate/extract-fold.js.map +0 -1
- package/out/capital-schema.d.ts.map +0 -1
- package/out/capital-schema.js.map +0 -1
- package/out/capitals.d.ts.map +0 -1
- package/out/capitals.js.map +0 -1
- package/out/coverage-manifest-schema.d.ts.map +0 -1
- package/out/coverage-manifest-schema.js.map +0 -1
- package/out/exact-match.d.ts.map +0 -1
- package/out/exact-match.js.map +0 -1
- package/out/extracts.d.ts.map +0 -1
- package/out/extracts.js.map +0 -1
- package/out/importance-source.d.ts.map +0 -1
- package/out/importance-source.js.map +0 -1
- package/out/interpolation.d.ts.map +0 -1
- package/out/interpolation.js.map +0 -1
- package/out/name-score.d.ts.map +0 -1
- package/out/name-score.js.map +0 -1
- package/out/place-importance-schema.d.ts.map +0 -1
- package/out/place-importance-schema.js.map +0 -1
- package/out/polygon-schema.d.ts.map +0 -1
- package/out/polygon-schema.js.map +0 -1
- package/out/postal/city/alias/lookup.d.ts.map +0 -1
- package/out/postal/city/alias/lookup.js.map +0 -1
- package/out/postal/city/alias/schema.d.ts.map +0 -1
- package/out/postal/city/alias/schema.js.map +0 -1
- package/out/postal/city/candidate-schema.d.ts.map +0 -1
- package/out/postal/city/candidate-schema.js.map +0 -1
- package/out/postal.d.ts +0 -4
- package/out/postal.d.ts.map +0 -1
- package/out/postal.js +0 -6
- package/out/postal.js.map +0 -1
- package/out/postcode-point-lookup.d.ts.map +0 -1
- package/out/postcode-point-lookup.js.map +0 -1
- package/out/primary-preference.d.ts.map +0 -1
- package/out/primary-preference.js.map +0 -1
- package/out/proximity-rerank.d.ts.map +0 -1
- package/out/proximity-rerank.js.map +0 -1
- package/out/ranking-weights.d.ts.map +0 -1
- package/out/ranking-weights.js.map +0 -1
- package/out/region-keys.js.map +0 -1
- package/out/reverse.d.ts.map +0 -1
- package/out/reverse.js.map +0 -1
- package/out/search-fetch.d.ts.map +0 -1
- package/out/search-fetch.js.map +0 -1
- package/out/street/centroid/schema.d.ts.map +0 -1
- package/out/street/centroid/schema.js.map +0 -1
- package/out/street/centroid.d.ts.map +0 -1
- package/out/street/centroid.js.map +0 -1
- package/out/street/locale.d.ts +0 -12
- package/out/street/locale.d.ts.map +0 -1
- package/out/street/locale.js +0 -54
- package/out/street/locale.js.map +0 -1
- package/out/street/morphology/fst/builder.d.ts.map +0 -1
- package/out/street/morphology/fst/builder.js.map +0 -1
- package/out/street/morphology/fst/loader.d.ts.map +0 -1
- package/out/street/morphology/fst/loader.js.map +0 -1
- package/out/street/name-lookup.d.ts.map +0 -1
- package/out/street/name-lookup.js.map +0 -1
- package/out/street/normalize.d.ts +0 -130
- package/out/street/normalize.d.ts.map +0 -1
- package/out/street/normalize.js.map +0 -1
- package/out/street/segment-schema.d.ts.map +0 -1
- package/out/street/segment-schema.js.map +0 -1
- package/out/street/table.d.ts.map +0 -1
- package/out/street/table.js.map +0 -1
- package/out/street.d.ts +0 -9
- package/out/street.d.ts.map +0 -1
- package/out/street.js +0 -11
- package/out/street.js.map +0 -1
- package/out/types.d.ts.map +0 -1
- package/out/types.js.map +0 -1
- package/out/unified-schema.d.ts.map +0 -1
- package/out/unified-schema.js.map +0 -1
- package/out/weights-overlay-linker.d.ts.map +0 -1
- package/out/weights-overlay-linker.js.map +0 -1
- /package/lib/{coverage-manifest-schema.ts → candidate/coverage-manifest.ts} +0 -0
- /package/lib/{postal/city → labels/locality/postal-city}/alias/schema.ts +0 -0
- /package/lib/{street → labels/street}/morphology/fst/builder.ts +0 -0
- /package/lib/{exact-match.ts → lookup/exact-match.ts} +0 -0
- /package/lib/{name-score.ts → ranking/name-score.ts} +0 -0
- /package/lib/{proximity-rerank.ts → ranking/proximity-rerank.ts} +0 -0
- /package/lib/{ranking-weights.ts → ranking/weights.ts} +0 -0
- /package/lib/{importance-source.ts → schema/importance-source.ts} +0 -0
- /package/lib/{polygon-schema.ts → schema/polygon.ts} +0 -0
- /package/lib/{unified-schema.ts → schema/unified.ts} +0 -0
- /package/out/{capitals.d.ts → candidate/capitals.d.ts} +0 -0
- /package/out/{search-fetch.js → fts/search-fetch.js} +0 -0
- /package/out/{postal/city → labels/locality/postal-city}/alias/lookup.js +0 -0
- /package/out/{postal/city → labels/locality/postal-city}/alias/schema.d.ts +0 -0
- /package/out/{postal/city → labels/locality/postal-city}/alias/schema.js +0 -0
- /package/out/{postal/city → labels/locality/postal-city}/candidate-schema.js +0 -0
- /package/out/{street → labels/street}/centroid/schema.js +0 -0
- /package/out/{street → labels/street}/morphology/fst/builder.d.ts +0 -0
- /package/out/{street → labels/street}/morphology/fst/builder.js +0 -0
- /package/out/{street → labels/street}/morphology/fst/loader.d.ts +0 -0
- /package/out/{street → labels/street}/name-lookup.d.ts +0 -0
- /package/out/{street → labels/street}/segment-schema.js +0 -0
- /package/out/{street → labels/street}/table.d.ts +0 -0
- /package/out/{exact-match.d.ts → lookup/exact-match.d.ts} +0 -0
- /package/out/{exact-match.js → lookup/exact-match.js} +0 -0
- /package/out/{extracts.d.ts → lookup/extracts.d.ts} +0 -0
- /package/out/{types.js → lookup/types.js} +0 -0
- /package/out/{name-score.d.ts → ranking/name-score.d.ts} +0 -0
- /package/out/{name-score.js → ranking/name-score.js} +0 -0
- /package/out/{primary-preference.d.ts → ranking/primary-preference.d.ts} +0 -0
- /package/out/{proximity-rerank.d.ts → ranking/proximity-rerank.d.ts} +0 -0
- /package/out/{proximity-rerank.js → ranking/proximity-rerank.js} +0 -0
- /package/out/{importance-source.d.ts → schema/importance-source.d.ts} +0 -0
- /package/out/{importance-source.js → schema/importance-source.js} +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
3
|
|
|
4
|
+
import { HOUSE_NUMBER_REPETITION_INDEXES } from "@mailwoman/codex/labels/house-number/repetition"
|
|
4
5
|
import { AbbreviationToDirectional, US_STREET_SUFFIX_LOOKUP } from "@mailwoman/codex/us"
|
|
5
6
|
import type { Tagged } from "type-fest"
|
|
6
7
|
|
|
7
|
-
import { streetLocaleForCountry } from "#street/locale"
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* A place name folded by {@link normalizeLocalityForKey}, minted only by calling the fold.
|
|
11
10
|
*/
|
|
@@ -142,58 +141,20 @@ export function normalizeStreetForKey(street: string): StreetKey {
|
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
*
|
|
144
|
+
* The name of one row of {@link STREET_KEY_RULES}, the rules a database's street,
|
|
145
|
+
* locality and house-number keys are built under.
|
|
146
|
+
*
|
|
147
|
+
* Two functions produce one: `streetLocaleForCountry` in `#labels/street/locale`, for a country,
|
|
148
|
+
* and {@link parseStreetLocale}, for a spelling an artifact manifest records or a command line passes.
|
|
149
|
+
* A string literal is therefore refused where a street locale is expected,
|
|
150
|
+
* and code reads a locale's behavior from its row with {@link streetKeyRulesOf}.
|
|
152
151
|
*/
|
|
153
|
-
export
|
|
154
|
-
"us",
|
|
155
|
-
"en",
|
|
156
|
-
"es",
|
|
157
|
-
"fr",
|
|
158
|
-
"de",
|
|
159
|
-
"it",
|
|
160
|
-
"nl",
|
|
161
|
-
"pl",
|
|
162
|
-
"vn",
|
|
163
|
-
"id",
|
|
164
|
-
"zh",
|
|
165
|
-
"und",
|
|
166
|
-
] as const satisfies readonly StreetLocale[]
|
|
152
|
+
export type StreetLocale = Tagged<string, "StreetLocale">
|
|
167
153
|
|
|
168
154
|
function foldHan(input: string): string {
|
|
169
155
|
return input.normalize("NFKC").replaceAll("臺", "台").replaceAll(/\s+/g, "").toLowerCase()
|
|
170
156
|
}
|
|
171
157
|
|
|
172
|
-
/**
|
|
173
|
-
* Creates the street-locale lookup for one source's built databases.
|
|
174
|
-
*
|
|
175
|
-
* `localeFor` answers {@link streetLocaleForCountry} for a country in `countries`
|
|
176
|
-
* and throws for any other, since that source has built no database there to fold a query for.
|
|
177
|
-
* Every source therefore folds a country's streets under one locale.
|
|
178
|
-
*/
|
|
179
|
-
export function createStreetLocaleRegistry(
|
|
180
|
-
countries: readonly string[],
|
|
181
|
-
label: string
|
|
182
|
-
): { localeFor: (countryCode: string) => StreetLocale; supported: () => string[] } {
|
|
183
|
-
const built = new Set(countries.map((country) => country.toLowerCase()))
|
|
184
|
-
|
|
185
|
-
return {
|
|
186
|
-
localeFor: (countryCode) => {
|
|
187
|
-
if (!built.has(countryCode.toLowerCase())) {
|
|
188
|
-
throw new Error(`No database is registered for country "${countryCode}". ${label}`)
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return streetLocaleForCountry(countryCode)
|
|
192
|
-
},
|
|
193
|
-
supported: () => [...built],
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
158
|
const FR_STREET_ABBREV = new Map<string, string>([
|
|
198
159
|
["av", "avenue"],
|
|
199
160
|
["ave", "avenue"],
|
|
@@ -261,83 +222,253 @@ const ID_STREET_ABBREV = new Map<string, string>([
|
|
|
261
222
|
["gg", "gang"],
|
|
262
223
|
])
|
|
263
224
|
|
|
225
|
+
const FRENCH_LEAD_TYPE =
|
|
226
|
+
/^(?:rue|ruelle|av|ave|avenue|boul|bd|boulevard|ch|che|chemin|all[ée]e|imp|impasse|mont[ée]e|c[ôo]te|pl|place|prom|promenade|rang|rte|route|autoroute|carr[eé]|croissant|terrasse|sentier)(?=[\s.-]|$)/i
|
|
227
|
+
|
|
264
228
|
/**
|
|
265
|
-
*
|
|
266
|
-
*
|
|
229
|
+
* The rules one street locale builds and probes keys under.
|
|
230
|
+
*
|
|
231
|
+
* A builder and a reader of one database read the same row, so they agree on every key.
|
|
267
232
|
*/
|
|
268
|
-
export
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
233
|
+
export interface StreetKeyRules {
|
|
234
|
+
/**
|
|
235
|
+
* Builds the key a street name is stored and probed under.
|
|
236
|
+
*/
|
|
237
|
+
streetKey: (street: string) => StreetKey
|
|
238
|
+
/**
|
|
239
|
+
* The streets keyed under another locale's rules: a street whose surface matches
|
|
240
|
+
* `pattern` is keyed under the row that `locale` spells.
|
|
241
|
+
*
|
|
242
|
+
* `null` keys every street under this row.
|
|
243
|
+
*/
|
|
244
|
+
surfaceRoute: { pattern: RegExp; locale: string } | null
|
|
245
|
+
/**
|
|
246
|
+
* Whether a reader also probes the English respellings of a street: a doubled type word, a numbered
|
|
247
|
+
* street with and without its ordinal suffix, `Saint` for `St`, and a numbered route's designators.
|
|
248
|
+
*/
|
|
249
|
+
englishRespellings: boolean
|
|
250
|
+
/**
|
|
251
|
+
* Builds the key a locality name is stored and probed under.
|
|
252
|
+
*/
|
|
253
|
+
localityKey: (locality: string) => NameKey
|
|
254
|
+
/**
|
|
255
|
+
* Whether the stored locality keys are abbreviated or replaced by a parent place.
|
|
256
|
+
*
|
|
257
|
+
* A reader then lets a row's locality select a row and never reject one.
|
|
258
|
+
*/
|
|
259
|
+
localityKeys: "abbreviated" | "full"
|
|
260
|
+
/**
|
|
261
|
+
* Whether a reader strips a trailing arrondissement designator from a query's locality key,
|
|
262
|
+
* because the builder keyed each arrondissement at its base city.
|
|
263
|
+
*/
|
|
264
|
+
arrondissementAtBaseCity: boolean
|
|
265
|
+
/**
|
|
266
|
+
* Whether the stored locality key is the parse's `region` and `subregion` written together,
|
|
267
|
+
* for a register whose rows state neither postcode nor locality.
|
|
268
|
+
*/
|
|
269
|
+
localityFromRegionAndSubregion: boolean
|
|
270
|
+
/**
|
|
271
|
+
* Builds the key a house number is stored and probed under.
|
|
272
|
+
*/
|
|
273
|
+
houseNumberKey: (number: string) => string
|
|
274
|
+
/**
|
|
275
|
+
* Matches a house number written as a base number with joined sub-numbers, and captures the base.
|
|
276
|
+
* A reader probes the base after the written number misses.
|
|
277
|
+
*
|
|
278
|
+
* `null` when the locale writes no such number.
|
|
279
|
+
*/
|
|
280
|
+
houseNumberBase: RegExp | null
|
|
281
|
+
/**
|
|
282
|
+
* The repetition indexes the locale writes after a house number (`20 bis`, `20 ter`),
|
|
283
|
+
* each of which a register may store as the word or as its first letter (`20 b`).
|
|
284
|
+
*
|
|
285
|
+
* A reader probes the other spellings of an index after the written number misses.
|
|
286
|
+
*
|
|
287
|
+
* `null` when the locale writes no repetition index.
|
|
288
|
+
*/
|
|
289
|
+
houseNumberRepetition: readonly string[] | null
|
|
290
|
+
}
|
|
272
291
|
|
|
273
|
-
|
|
292
|
+
/**
|
|
293
|
+
* The key of a street written in space-separated words: case folded, accents removed,
|
|
294
|
+
* `ß` written `ss`, hyphens read as spaces, and the words then passed to `rewrite`.
|
|
295
|
+
*/
|
|
296
|
+
function wordStreetKey(street: string, rewrite?: (words: string[]) => void): StreetKey {
|
|
297
|
+
const words = fold(street)
|
|
274
298
|
.replaceAll("ß", "ss")
|
|
275
299
|
.replaceAll("-", " ")
|
|
276
300
|
.split(/\s+/)
|
|
277
301
|
.filter((value) => value.length)
|
|
278
302
|
|
|
279
|
-
if (!
|
|
303
|
+
if (!words.length) return "" as StreetKey
|
|
304
|
+
|
|
305
|
+
rewrite?.(words)
|
|
306
|
+
|
|
307
|
+
return words.join(" ") as StreetKey
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Replaces every word that `expansions` lists.
|
|
312
|
+
*/
|
|
313
|
+
function expandEveryWord(expansions: ReadonlyMap<string, string>): (words: string[]) => void {
|
|
314
|
+
return (words) => {
|
|
315
|
+
for (let i = 0; i < words.length; i++) {
|
|
316
|
+
words[i] = expansions.get(words[i]!) ?? words[i]!
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Replaces the leading word that `expansions` lists, in a name of two or more words.
|
|
323
|
+
*
|
|
324
|
+
* The leading type is expanded and kept, because dropping it merges distinct streets
|
|
325
|
+
* that share a name: `Calle Mayor` and `Plaza Mayor` can share a municipio.
|
|
326
|
+
*/
|
|
327
|
+
function expandLeadingWord(expansions: ReadonlyMap<string, string>): (words: string[]) => void {
|
|
328
|
+
return (words) => {
|
|
329
|
+
if (words.length > 1) {
|
|
330
|
+
words[0] = expansions.get(words[0]!) ?? words[0]!
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Writes a word that ends in `str` with the full street word `full` in its place.
|
|
337
|
+
*/
|
|
338
|
+
function expandStreetSuffix(full: string): (words: string[]) => void {
|
|
339
|
+
return (words) => {
|
|
340
|
+
for (let i = 0; i < words.length; i++) {
|
|
341
|
+
const word = words[i]!
|
|
280
342
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
284
|
-
tokens[i] = FR_STREET_ABBREV.get(tokens[i]!) ?? tokens[i]!
|
|
343
|
+
if (word.endsWith("str") && !word.endsWith(full)) {
|
|
344
|
+
words[i] = word.replace(/str$/, full)
|
|
285
345
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const t = tokens[i]!
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
290
349
|
|
|
291
|
-
|
|
292
|
-
|
|
350
|
+
/**
|
|
351
|
+
* The rules every locale has unless its row states another.
|
|
352
|
+
*/
|
|
353
|
+
const SHARED_KEY_RULES: StreetKeyRules = {
|
|
354
|
+
streetKey: (street) => wordStreetKey(street),
|
|
355
|
+
surfaceRoute: null,
|
|
356
|
+
englishRespellings: false,
|
|
357
|
+
localityKey: normalizeLocalityForKey,
|
|
358
|
+
localityKeys: "full",
|
|
359
|
+
arrondissementAtBaseCity: false,
|
|
360
|
+
localityFromRegionAndSubregion: false,
|
|
361
|
+
houseNumberKey: (number) => number.trim().toLowerCase(),
|
|
362
|
+
houseNumberBase: null,
|
|
363
|
+
houseNumberRepetition: null,
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* The rules of each street locale, keyed by the spelling an artifact manifest records.
|
|
368
|
+
*
|
|
369
|
+
* A spelling is therefore renamed only with its artifacts rebuilt.
|
|
370
|
+
*
|
|
371
|
+
* - `es`, `fr`, `de`, `it`, `nl`, `pl` and `id` are ISO 639-1 language codes.
|
|
372
|
+
* - `vn` is Vietnamese, spelled with the country's code where the language's is `vi`.
|
|
373
|
+
* - `zh` is Han script, and the one database under it is the Taiwanese register's.
|
|
374
|
+
* - `en` and `us` build the same street key.
|
|
375
|
+
* `us` is the row of a database built without the surface route and with abbreviated
|
|
376
|
+
* locality keys, as the United States databases are.
|
|
377
|
+
* - `und` has the shared rules only, for a country whose official languages select no one row.
|
|
378
|
+
*/
|
|
379
|
+
const STREET_KEY_RULES: Readonly<Record<string, StreetKeyRules>> = {
|
|
380
|
+
us: { ...SHARED_KEY_RULES, streetKey: normalizeStreetForKey, englishRespellings: true, localityKeys: "abbreviated" },
|
|
381
|
+
en: {
|
|
382
|
+
...SHARED_KEY_RULES,
|
|
383
|
+
streetKey: normalizeStreetForKey,
|
|
384
|
+
// The route reads the surface and never the province, so a bilingual Canadian extract keys each street one way.
|
|
385
|
+
surfaceRoute: { pattern: FRENCH_LEAD_TYPE, locale: "fr" },
|
|
386
|
+
englishRespellings: true,
|
|
387
|
+
},
|
|
388
|
+
es: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandLeadingWord(ES_STREET_TYPE_ABBREV)) },
|
|
389
|
+
fr: {
|
|
390
|
+
...SHARED_KEY_RULES,
|
|
391
|
+
streetKey: (street) => wordStreetKey(street, expandEveryWord(FR_STREET_ABBREV)),
|
|
392
|
+
arrondissementAtBaseCity: true,
|
|
393
|
+
// BAN writes `3 bis` across most of France and `3 b` in Paris, and a query may write either joined.
|
|
394
|
+
houseNumberRepetition: HOUSE_NUMBER_REPETITION_INDEXES,
|
|
395
|
+
},
|
|
396
|
+
de: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandStreetSuffix("strasse")) },
|
|
397
|
+
it: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandLeadingWord(IT_STREET_TYPE_ABBREV)) },
|
|
398
|
+
nl: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandStreetSuffix("straat")) },
|
|
399
|
+
pl: {
|
|
400
|
+
...SHARED_KEY_RULES,
|
|
401
|
+
streetKey: (street) =>
|
|
402
|
+
wordStreetKey(street, (words) => {
|
|
403
|
+
for (let i = 0; i < words.length; i++) {
|
|
404
|
+
words[i] = words[i]!.replaceAll("ł", "l")
|
|
293
405
|
}
|
|
294
|
-
}
|
|
295
|
-
break
|
|
296
|
-
case "it":
|
|
297
|
-
// The leading type is expanded and kept, unlike `pl`, because dropping it
|
|
298
|
-
// merges distinct streets that share a name.
|
|
299
|
-
if (tokens.length > 1) {
|
|
300
|
-
tokens[0] = IT_STREET_TYPE_ABBREV.get(tokens[0]!) ?? tokens[0]!
|
|
301
|
-
}
|
|
302
|
-
break
|
|
303
|
-
case "es":
|
|
304
|
-
// Keep the leading type, as `it` does and more strongly, because `Calle Mayor`
|
|
305
|
-
// and `Plaza Mayor` can share a municipio.
|
|
306
|
-
if (tokens.length > 1) {
|
|
307
|
-
tokens[0] = ES_STREET_TYPE_ABBREV.get(tokens[0]!) ?? tokens[0]!
|
|
308
|
-
}
|
|
309
|
-
break
|
|
310
|
-
case "nl":
|
|
311
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
312
|
-
const t = tokens[i]!
|
|
313
406
|
|
|
314
|
-
if (
|
|
315
|
-
|
|
407
|
+
if (words.length > 1 && PL_LEADING_TYPE.has(words[0]!)) {
|
|
408
|
+
words.shift()
|
|
316
409
|
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
410
|
+
}),
|
|
411
|
+
},
|
|
412
|
+
vn: {
|
|
413
|
+
...SHARED_KEY_RULES,
|
|
414
|
+
streetKey: (street) =>
|
|
415
|
+
wordStreetKey(street, (words) => {
|
|
416
|
+
for (let i = 0; i < words.length; i++) {
|
|
417
|
+
words[i] = words[i]!.replaceAll("đ", "d").replaceAll("ð", "d")
|
|
418
|
+
}
|
|
419
|
+
}),
|
|
420
|
+
},
|
|
421
|
+
id: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandEveryWord(ID_STREET_ABBREV)) },
|
|
422
|
+
zh: {
|
|
423
|
+
...SHARED_KEY_RULES,
|
|
424
|
+
// A Han street name has no spaces and no type-word abbreviations.
|
|
425
|
+
streetKey: (street) => foldHan(street) as StreetKey,
|
|
426
|
+
localityKey: (locality) => foldHan(locality) as NameKey,
|
|
427
|
+
localityFromRegionAndSubregion: true,
|
|
428
|
+
// A Taiwanese house number ends in 號 and may be written in full-width digits.
|
|
429
|
+
houseNumberKey: (number) =>
|
|
430
|
+
foldHan(number)
|
|
431
|
+
.replace(/^(\d+)號([之附]\d+)$/u, "$1$2")
|
|
432
|
+
.replace(/號$/u, ""),
|
|
433
|
+
// 之 and 附 join a sub-number to a base number, and the Taiwanese register stores the base.
|
|
434
|
+
houseNumberBase: /^(\d+)(?:[之附]\d+)+$/u,
|
|
435
|
+
},
|
|
436
|
+
und: SHARED_KEY_RULES,
|
|
437
|
+
}
|
|
323
438
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
335
|
-
tokens[i] = tokens[i]!.replaceAll("đ", "d").replaceAll("ð", "d")
|
|
336
|
-
}
|
|
337
|
-
break
|
|
439
|
+
/**
|
|
440
|
+
* The street locale a spelling names, for a spelling read from an artifact manifest or a command line.
|
|
441
|
+
*
|
|
442
|
+
* @throws For a spelling {@link STREET_KEY_RULES} has no row for.
|
|
443
|
+
*/
|
|
444
|
+
export function parseStreetLocale(spelling: string): StreetLocale {
|
|
445
|
+
if (!Object.hasOwn(STREET_KEY_RULES, spelling)) {
|
|
446
|
+
throw new Error(
|
|
447
|
+
`"${spelling}" is no street locale. The street locales are ${Object.keys(STREET_KEY_RULES).join(", ")}.`
|
|
448
|
+
)
|
|
338
449
|
}
|
|
339
450
|
|
|
340
|
-
return
|
|
451
|
+
return spelling as StreetLocale
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Every street locale, in the order {@link STREET_KEY_RULES} lists them.
|
|
456
|
+
*/
|
|
457
|
+
export const STREET_LOCALES: readonly StreetLocale[] = Object.keys(STREET_KEY_RULES).map(parseStreetLocale)
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* The rules a street locale builds and probes keys under.
|
|
461
|
+
*/
|
|
462
|
+
export function streetKeyRulesOf(locale: StreetLocale): StreetKeyRules {
|
|
463
|
+
return STREET_KEY_RULES[locale]!
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Builds a street name's address-point key under the given locale.
|
|
468
|
+
* The extract builder and the probe must both call it.
|
|
469
|
+
*/
|
|
470
|
+
export function normalizeStreetForKeyLocale(street: string, locale: StreetLocale): StreetKey {
|
|
471
|
+
return streetKeyRulesOf(locale).streetKey(street)
|
|
341
472
|
}
|
|
342
473
|
|
|
343
474
|
/**
|
|
@@ -390,39 +521,29 @@ export function withArabicLetterVariantsFolded(key: NameKey): NameKey {
|
|
|
390
521
|
}
|
|
391
522
|
|
|
392
523
|
/**
|
|
393
|
-
*
|
|
394
|
-
* and {@link normalizeLocalityForKey} otherwise.
|
|
524
|
+
* Builds a locality name's {@link NameKey} under the given locale.
|
|
395
525
|
*
|
|
396
|
-
* The Han rule
|
|
526
|
+
* The Han rule is a row's own, so the columns of every other locale keep their keys.
|
|
397
527
|
*/
|
|
398
528
|
export function normalizeLocalityForKeyLocale(locality: string, locale: StreetLocale): NameKey {
|
|
399
|
-
return locale
|
|
529
|
+
return streetKeyRulesOf(locale).localityKey(locality)
|
|
400
530
|
}
|
|
401
531
|
|
|
402
532
|
/**
|
|
403
|
-
*
|
|
404
|
-
* and dropping the trailing 號 for `zh`.
|
|
533
|
+
* Builds a house number's address-point key under the given locale.
|
|
405
534
|
*/
|
|
406
535
|
export function normalizeHouseNumberForKey(number: string, locale: StreetLocale): string {
|
|
407
|
-
|
|
408
|
-
return foldHan(number)
|
|
409
|
-
.replace(/^(\d+)號([之附]\d+)$/u, "$1$2")
|
|
410
|
-
.replace(/號$/u, "")
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
return number.trim().toLowerCase()
|
|
536
|
+
return streetKeyRulesOf(locale).houseNumberKey(number)
|
|
414
537
|
}
|
|
415
538
|
|
|
416
|
-
const FRENCH_LEAD_TYPE =
|
|
417
|
-
/^(?:rue|ruelle|av|ave|avenue|boul|bd|boulevard|ch|che|chemin|all[ée]e|imp|impasse|mont[ée]e|c[ôo]te|pl|place|prom|promenade|rang|rte|route|autoroute|carr[eé]|croissant|terrasse|sentier)(?=[\s.-]|$)/i
|
|
418
|
-
|
|
419
539
|
/**
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
* so bilingual Canadian extracts fold consistently.
|
|
540
|
+
* The locale a street's key is built under: the one `base`'s surface route sends the street to,
|
|
541
|
+
* or `base` when the row has no route or the street doesn't match it.
|
|
423
542
|
*/
|
|
424
543
|
export function streetLocaleForSurface(street: string, base: StreetLocale): StreetLocale {
|
|
425
|
-
|
|
544
|
+
const route = streetKeyRulesOf(base).surfaceRoute
|
|
545
|
+
|
|
546
|
+
return route?.pattern.test(street.trimStart()) ? parseStreetLocale(route.locale) : base
|
|
426
547
|
}
|
|
427
548
|
|
|
428
549
|
/**
|
|
@@ -515,14 +636,53 @@ function ordinalOf(n: number): string {
|
|
|
515
636
|
}
|
|
516
637
|
|
|
517
638
|
/**
|
|
518
|
-
*
|
|
519
|
-
|
|
639
|
+
* The directionals as a street key writes them: `north`, `northeast` and so on.
|
|
640
|
+
*/
|
|
641
|
+
const KEY_DIRECTIONALS: readonly string[] = [
|
|
642
|
+
...new Set([...AbbreviationToDirectional.values()].map((name) => name.toLowerCase().replaceAll(" ", ""))),
|
|
643
|
+
]
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* The keys a street key could be stored under if its writer and the register disagree
|
|
647
|
+
* on one directional: the key's base name without a leading or trailing directional,
|
|
648
|
+
* and the base with each directional before or after it.
|
|
649
|
+
* The key itself is left out.
|
|
650
|
+
*
|
|
651
|
+
* Returns an empty list when the base has fewer than two words,
|
|
652
|
+
* so `northwest highway` never relaxes to `highway`.
|
|
653
|
+
*/
|
|
654
|
+
export function directionalRelaxedKeys(key: StreetKey): StreetKey[] {
|
|
655
|
+
const words = key.split(" ")
|
|
656
|
+
|
|
657
|
+
if (words.length && KEY_DIRECTIONALS.includes(words[0]!)) {
|
|
658
|
+
words.shift()
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
if (words.length && KEY_DIRECTIONALS.includes(words.at(-1)!)) {
|
|
662
|
+
words.pop()
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (words.length < 2) return []
|
|
666
|
+
|
|
667
|
+
const base = words.join(" ")
|
|
668
|
+
const forms = [
|
|
669
|
+
base,
|
|
670
|
+
...KEY_DIRECTIONALS.flatMap((directional) => [`${directional} ${base}`, `${base} ${directional}`]),
|
|
671
|
+
]
|
|
672
|
+
|
|
673
|
+
return forms.filter((form) => form !== key) as StreetKey[]
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Lists the lookup keys to probe for a street span, most literal first, adding the
|
|
678
|
+
* English respellings for a locale whose rules probe them.
|
|
520
679
|
*/
|
|
521
|
-
export function streetKeyVariants(street: string, locale: StreetLocale
|
|
522
|
-
const
|
|
680
|
+
export function streetKeyVariants(street: string, locale: StreetLocale): StreetKey[] {
|
|
681
|
+
const rules = streetKeyRulesOf(locale)
|
|
682
|
+
const primary = rules.streetKey(street)
|
|
523
683
|
const variants: StreetKey[] = primary ? [primary] : []
|
|
524
684
|
|
|
525
|
-
if (!primary ||
|
|
685
|
+
if (!primary || !rules.englishRespellings) return variants
|
|
526
686
|
|
|
527
687
|
const tokens = primary.split(" ")
|
|
528
688
|
const last = tokens.at(-1)
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
import { type Kysely, sql } from "kysely"
|
|
21
21
|
|
|
22
|
-
import type { RouteKey } from "#street/normalize"
|
|
22
|
+
import type { RouteKey } from "#labels/street/normalize"
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* One tiger street-segment edge: a `(from_hn, to_hn)` house-number range on one `side`
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* A read clusters on the written name, so a range reader fetches one run of pages for each lookup.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { normalizeStreetForKey } from "#street/normalize"
|
|
14
|
+
import { normalizeStreetForKey } from "#labels/street/normalize"
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* One merged street: road links with one name, joined through a shared node.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
export * from "#labels/street/centroid"
|
|
5
|
+
export * from "#labels/street/centroid/schema"
|
|
6
|
+
export * from "#labels/street/morphology/fst/builder"
|
|
7
|
+
export * from "#labels/street/morphology/fst/loader"
|
|
8
|
+
export * from "#labels/street/locale"
|
|
9
|
+
export * from "#labels/street/name-lookup"
|
|
10
|
+
export * from "#labels/street/normalize"
|
|
11
|
+
export * from "#labels/street/segment-schema"
|
package/lib/landmark/rows.ts
CHANGED