@mailwoman/resolver-wof-sqlite 11.1.0 → 11.3.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 +5 -5
- 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 +4 -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/ancestry/backfill.ts +13 -43
- package/lib/build/candidate.ts +171 -35
- package/lib/build/slim.ts +4 -1
- package/lib/build/sources.ts +50 -0
- package/lib/candidate/alias-bags.ts +74 -20
- 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 +90 -11
- package/lib/candidate/key-fold.ts +132 -0
- package/lib/candidate/lookup.ts +101 -60
- package/lib/candidate/name-roles.ts +1 -1
- package/lib/candidate/nickname-namesakes.ts +147 -0
- 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/binary-matcher.ts +26 -41
- package/lib/fst/builder.ts +8 -6
- package/lib/fst/deserialize-web.ts +1 -1
- package/lib/fst/format.ts +144 -7
- package/lib/fst/freshness.ts +2 -2
- package/lib/fst/serialize.ts +93 -64
- package/lib/fts/query.ts +1 -1
- package/lib/{search-fetch.ts → fts/search-fetch.ts} +2 -2
- package/lib/geonames/aliases.ts +42 -45
- 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} +12 -4
- 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 +284 -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} +45 -2
- package/lib/schema/importance-source.ts +210 -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 +1 -1
- package/out/address/number-forms.d.ts.map +1 -1
- package/out/address/number-forms.js +4 -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/ancestry/backfill.d.ts +14 -9
- package/out/ancestry/backfill.d.ts.map +1 -1
- package/out/ancestry/backfill.js +4 -42
- package/out/ancestry/backfill.js.map +1 -1
- package/out/build/candidate.d.ts +46 -1
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +82 -31
- 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 +8 -3
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +63 -17
- 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 +57 -11
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/key-fold.d.ts +55 -0
- package/out/candidate/key-fold.d.ts.map +1 -0
- package/out/candidate/key-fold.js +80 -0
- package/out/candidate/key-fold.js.map +1 -0
- package/out/candidate/lookup.d.ts +5 -1
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +80 -54
- 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 +28 -0
- package/out/candidate/nickname-namesakes.d.ts.map +1 -0
- package/out/candidate/nickname-namesakes.js +109 -0
- package/out/candidate/nickname-namesakes.js.map +1 -0
- 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/binary-matcher.d.ts.map +1 -1
- package/out/fst/binary-matcher.js +9 -30
- package/out/fst/binary-matcher.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/format.d.ts +60 -9
- package/out/fst/format.d.ts.map +1 -1
- package/out/fst/format.js +97 -6
- package/out/fst/format.js.map +1 -1
- package/out/fst/freshness.js +2 -2
- package/out/fst/freshness.js.map +1 -1
- package/out/fst/serialize.d.ts.map +1 -1
- package/out/fst/serialize.js +67 -55
- 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 +20 -24
- 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} +10 -8
- 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 +188 -0
- package/out/labels/street/normalize.d.ts.map +1 -0
- package/out/{street → labels/street}/normalize.js +200 -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/{primary-preference.d.ts → ranking/primary-preference.d.ts} +20 -1
- package/out/ranking/primary-preference.d.ts.map +1 -0
- package/out/{primary-preference.js → ranking/primary-preference.js} +35 -1
- 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 +90 -0
- package/out/schema/importance-source.d.ts.map +1 -0
- package/out/schema/importance-source.js +133 -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/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 -111
- 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/{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/{proximity-rerank.d.ts → ranking/proximity-rerank.d.ts} +0 -0
- /package/out/{proximity-rerank.js → ranking/proximity-rerank.js} +0 -0
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
import { AbbreviationToDirectional, US_STREET_SUFFIX_LOOKUP } from "@mailwoman/codex/us"
|
|
5
5
|
import type { Tagged } from "type-fest"
|
|
6
6
|
|
|
7
|
-
import { streetLocaleForCountry } from "#street/locale"
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
* A place name folded by {@link normalizeLocalityForKey}, minted only by calling the fold.
|
|
11
9
|
*/
|
|
@@ -142,58 +140,20 @@ export function normalizeStreetForKey(street: string): StreetKey {
|
|
|
142
140
|
}
|
|
143
141
|
|
|
144
142
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
*
|
|
143
|
+
* The name of one row of {@link STREET_KEY_RULES}, the rules a database's street,
|
|
144
|
+
* locality and house-number keys are built under.
|
|
145
|
+
*
|
|
146
|
+
* Two functions produce one: `streetLocaleForCountry` in `#labels/street/locale`, for a country,
|
|
147
|
+
* and {@link parseStreetLocale}, for a spelling an artifact manifest records or a command line passes.
|
|
148
|
+
* A string literal is therefore refused where a street locale is expected,
|
|
149
|
+
* and code reads a locale's behavior from its row with {@link streetKeyRulesOf}.
|
|
152
150
|
*/
|
|
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[]
|
|
151
|
+
export type StreetLocale = Tagged<string, "StreetLocale">
|
|
167
152
|
|
|
168
153
|
function foldHan(input: string): string {
|
|
169
154
|
return input.normalize("NFKC").replaceAll("臺", "台").replaceAll(/\s+/g, "").toLowerCase()
|
|
170
155
|
}
|
|
171
156
|
|
|
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
157
|
const FR_STREET_ABBREV = new Map<string, string>([
|
|
198
158
|
["av", "avenue"],
|
|
199
159
|
["ave", "avenue"],
|
|
@@ -261,83 +221,241 @@ const ID_STREET_ABBREV = new Map<string, string>([
|
|
|
261
221
|
["gg", "gang"],
|
|
262
222
|
])
|
|
263
223
|
|
|
224
|
+
const FRENCH_LEAD_TYPE =
|
|
225
|
+
/^(?: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
|
|
226
|
+
|
|
264
227
|
/**
|
|
265
|
-
*
|
|
266
|
-
*
|
|
228
|
+
* The rules one street locale builds and probes keys under.
|
|
229
|
+
*
|
|
230
|
+
* A builder and a reader of one database read the same row, so they agree on every key.
|
|
267
231
|
*/
|
|
268
|
-
export
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
232
|
+
export interface StreetKeyRules {
|
|
233
|
+
/**
|
|
234
|
+
* Builds the key a street name is stored and probed under.
|
|
235
|
+
*/
|
|
236
|
+
streetKey: (street: string) => StreetKey
|
|
237
|
+
/**
|
|
238
|
+
* The streets keyed under another locale's rules: a street whose surface matches
|
|
239
|
+
* `pattern` is keyed under the row that `locale` spells.
|
|
240
|
+
*
|
|
241
|
+
* `null` keys every street under this row.
|
|
242
|
+
*/
|
|
243
|
+
surfaceRoute: { pattern: RegExp; locale: string } | null
|
|
244
|
+
/**
|
|
245
|
+
* Whether a reader also probes the English respellings of a street: a doubled type word, a numbered
|
|
246
|
+
* street with and without its ordinal suffix, `Saint` for `St`, and a numbered route's designators.
|
|
247
|
+
*/
|
|
248
|
+
englishRespellings: boolean
|
|
249
|
+
/**
|
|
250
|
+
* Builds the key a locality name is stored and probed under.
|
|
251
|
+
*/
|
|
252
|
+
localityKey: (locality: string) => NameKey
|
|
253
|
+
/**
|
|
254
|
+
* Whether the stored locality keys are abbreviated or replaced by a parent place.
|
|
255
|
+
*
|
|
256
|
+
* A reader then lets a row's locality select a row and never reject one.
|
|
257
|
+
*/
|
|
258
|
+
localityKeys: "abbreviated" | "full"
|
|
259
|
+
/**
|
|
260
|
+
* Whether a reader strips a trailing arrondissement designator from a query's locality key,
|
|
261
|
+
* because the builder keyed each arrondissement at its base city.
|
|
262
|
+
*/
|
|
263
|
+
arrondissementAtBaseCity: boolean
|
|
264
|
+
/**
|
|
265
|
+
* Whether the stored locality key is the parse's `region` and `subregion` written together,
|
|
266
|
+
* for a register whose rows state neither postcode nor locality.
|
|
267
|
+
*/
|
|
268
|
+
localityFromRegionAndSubregion: boolean
|
|
269
|
+
/**
|
|
270
|
+
* Builds the key a house number is stored and probed under.
|
|
271
|
+
*/
|
|
272
|
+
houseNumberKey: (number: string) => string
|
|
273
|
+
/**
|
|
274
|
+
* Matches a house number written as a base number with joined sub-numbers, and captures the base.
|
|
275
|
+
* A reader probes the base after the written number misses.
|
|
276
|
+
*
|
|
277
|
+
* `null` when the locale writes no such number.
|
|
278
|
+
*/
|
|
279
|
+
houseNumberBase: RegExp | null
|
|
280
|
+
}
|
|
272
281
|
|
|
273
|
-
|
|
282
|
+
/**
|
|
283
|
+
* The key of a street written in space-separated words: case folded, accents removed,
|
|
284
|
+
* `ß` written `ss`, hyphens read as spaces, and the words then passed to `rewrite`.
|
|
285
|
+
*/
|
|
286
|
+
function wordStreetKey(street: string, rewrite?: (words: string[]) => void): StreetKey {
|
|
287
|
+
const words = fold(street)
|
|
274
288
|
.replaceAll("ß", "ss")
|
|
275
289
|
.replaceAll("-", " ")
|
|
276
290
|
.split(/\s+/)
|
|
277
291
|
.filter((value) => value.length)
|
|
278
292
|
|
|
279
|
-
if (!
|
|
293
|
+
if (!words.length) return "" as StreetKey
|
|
294
|
+
|
|
295
|
+
rewrite?.(words)
|
|
296
|
+
|
|
297
|
+
return words.join(" ") as StreetKey
|
|
298
|
+
}
|
|
280
299
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Replaces every word that `expansions` lists.
|
|
302
|
+
*/
|
|
303
|
+
function expandEveryWord(expansions: ReadonlyMap<string, string>): (words: string[]) => void {
|
|
304
|
+
return (words) => {
|
|
305
|
+
for (let i = 0; i < words.length; i++) {
|
|
306
|
+
words[i] = expansions.get(words[i]!) ?? words[i]!
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Replaces the leading word that `expansions` lists, in a name of two or more words.
|
|
313
|
+
*
|
|
314
|
+
* The leading type is expanded and kept, because dropping it merges distinct streets
|
|
315
|
+
* that share a name: `Calle Mayor` and `Plaza Mayor` can share a municipio.
|
|
316
|
+
*/
|
|
317
|
+
function expandLeadingWord(expansions: ReadonlyMap<string, string>): (words: string[]) => void {
|
|
318
|
+
return (words) => {
|
|
319
|
+
if (words.length > 1) {
|
|
320
|
+
words[0] = expansions.get(words[0]!) ?? words[0]!
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Writes a word that ends in `str` with the full street word `full` in its place.
|
|
327
|
+
*/
|
|
328
|
+
function expandStreetSuffix(full: string): (words: string[]) => void {
|
|
329
|
+
return (words) => {
|
|
330
|
+
for (let i = 0; i < words.length; i++) {
|
|
331
|
+
const word = words[i]!
|
|
332
|
+
|
|
333
|
+
if (word.endsWith("str") && !word.endsWith(full)) {
|
|
334
|
+
words[i] = word.replace(/str$/, full)
|
|
285
335
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* The rules every locale has unless its row states another.
|
|
342
|
+
*/
|
|
343
|
+
const SHARED_KEY_RULES: StreetKeyRules = {
|
|
344
|
+
streetKey: (street) => wordStreetKey(street),
|
|
345
|
+
surfaceRoute: null,
|
|
346
|
+
englishRespellings: false,
|
|
347
|
+
localityKey: normalizeLocalityForKey,
|
|
348
|
+
localityKeys: "full",
|
|
349
|
+
arrondissementAtBaseCity: false,
|
|
350
|
+
localityFromRegionAndSubregion: false,
|
|
351
|
+
houseNumberKey: (number) => number.trim().toLowerCase(),
|
|
352
|
+
houseNumberBase: null,
|
|
353
|
+
}
|
|
290
354
|
|
|
291
|
-
|
|
292
|
-
|
|
355
|
+
/**
|
|
356
|
+
* The rules of each street locale, keyed by the spelling an artifact manifest records.
|
|
357
|
+
*
|
|
358
|
+
* A spelling is therefore renamed only with its artifacts rebuilt.
|
|
359
|
+
*
|
|
360
|
+
* - `es`, `fr`, `de`, `it`, `nl`, `pl` and `id` are ISO 639-1 language codes.
|
|
361
|
+
* - `vn` is Vietnamese, spelled with the country's code where the language's is `vi`.
|
|
362
|
+
* - `zh` is Han script, and the one database under it is the Taiwanese register's.
|
|
363
|
+
* - `en` and `us` build the same street key.
|
|
364
|
+
* `us` is the row of a database built without the surface route and with abbreviated
|
|
365
|
+
* locality keys, as the United States databases are.
|
|
366
|
+
* - `und` has the shared rules only, for a country whose official languages select no one row.
|
|
367
|
+
*/
|
|
368
|
+
const STREET_KEY_RULES: Readonly<Record<string, StreetKeyRules>> = {
|
|
369
|
+
us: { ...SHARED_KEY_RULES, streetKey: normalizeStreetForKey, englishRespellings: true, localityKeys: "abbreviated" },
|
|
370
|
+
en: {
|
|
371
|
+
...SHARED_KEY_RULES,
|
|
372
|
+
streetKey: normalizeStreetForKey,
|
|
373
|
+
// The route reads the surface and never the province, so a bilingual Canadian extract keys each street one way.
|
|
374
|
+
surfaceRoute: { pattern: FRENCH_LEAD_TYPE, locale: "fr" },
|
|
375
|
+
englishRespellings: true,
|
|
376
|
+
},
|
|
377
|
+
es: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandLeadingWord(ES_STREET_TYPE_ABBREV)) },
|
|
378
|
+
fr: {
|
|
379
|
+
...SHARED_KEY_RULES,
|
|
380
|
+
streetKey: (street) => wordStreetKey(street, expandEveryWord(FR_STREET_ABBREV)),
|
|
381
|
+
arrondissementAtBaseCity: true,
|
|
382
|
+
},
|
|
383
|
+
de: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandStreetSuffix("strasse")) },
|
|
384
|
+
it: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandLeadingWord(IT_STREET_TYPE_ABBREV)) },
|
|
385
|
+
nl: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandStreetSuffix("straat")) },
|
|
386
|
+
pl: {
|
|
387
|
+
...SHARED_KEY_RULES,
|
|
388
|
+
streetKey: (street) =>
|
|
389
|
+
wordStreetKey(street, (words) => {
|
|
390
|
+
for (let i = 0; i < words.length; i++) {
|
|
391
|
+
words[i] = words[i]!.replaceAll("ł", "l")
|
|
293
392
|
}
|
|
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
393
|
|
|
314
|
-
if (
|
|
315
|
-
|
|
394
|
+
if (words.length > 1 && PL_LEADING_TYPE.has(words[0]!)) {
|
|
395
|
+
words.shift()
|
|
316
396
|
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
397
|
+
}),
|
|
398
|
+
},
|
|
399
|
+
vn: {
|
|
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("đ", "d").replaceAll("ð", "d")
|
|
405
|
+
}
|
|
406
|
+
}),
|
|
407
|
+
},
|
|
408
|
+
id: { ...SHARED_KEY_RULES, streetKey: (street) => wordStreetKey(street, expandEveryWord(ID_STREET_ABBREV)) },
|
|
409
|
+
zh: {
|
|
410
|
+
...SHARED_KEY_RULES,
|
|
411
|
+
// A Han street name has no spaces and no type-word abbreviations.
|
|
412
|
+
streetKey: (street) => foldHan(street) as StreetKey,
|
|
413
|
+
localityKey: (locality) => foldHan(locality) as NameKey,
|
|
414
|
+
localityFromRegionAndSubregion: true,
|
|
415
|
+
// A Taiwanese house number ends in 號 and may be written in full-width digits.
|
|
416
|
+
houseNumberKey: (number) =>
|
|
417
|
+
foldHan(number)
|
|
418
|
+
.replace(/^(\d+)號([之附]\d+)$/u, "$1$2")
|
|
419
|
+
.replace(/號$/u, ""),
|
|
420
|
+
// 之 and 附 join a sub-number to a base number, and the Taiwanese register stores the base.
|
|
421
|
+
houseNumberBase: /^(\d+)(?:[之附]\d+)+$/u,
|
|
422
|
+
},
|
|
423
|
+
und: SHARED_KEY_RULES,
|
|
424
|
+
}
|
|
323
425
|
|
|
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
|
|
426
|
+
/**
|
|
427
|
+
* The street locale a spelling names, for a spelling read from an artifact manifest or a command line.
|
|
428
|
+
*
|
|
429
|
+
* @throws For a spelling {@link STREET_KEY_RULES} has no row for.
|
|
430
|
+
*/
|
|
431
|
+
export function parseStreetLocale(spelling: string): StreetLocale {
|
|
432
|
+
if (!Object.hasOwn(STREET_KEY_RULES, spelling)) {
|
|
433
|
+
throw new Error(
|
|
434
|
+
`"${spelling}" is no street locale. The street locales are ${Object.keys(STREET_KEY_RULES).join(", ")}.`
|
|
435
|
+
)
|
|
338
436
|
}
|
|
339
437
|
|
|
340
|
-
return
|
|
438
|
+
return spelling as StreetLocale
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Every street locale, in the order {@link STREET_KEY_RULES} lists them.
|
|
443
|
+
*/
|
|
444
|
+
export const STREET_LOCALES: readonly StreetLocale[] = Object.keys(STREET_KEY_RULES).map(parseStreetLocale)
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The rules a street locale builds and probes keys under.
|
|
448
|
+
*/
|
|
449
|
+
export function streetKeyRulesOf(locale: StreetLocale): StreetKeyRules {
|
|
450
|
+
return STREET_KEY_RULES[locale]!
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Builds a street name's address-point key under the given locale.
|
|
455
|
+
* The extract builder and the probe must both call it.
|
|
456
|
+
*/
|
|
457
|
+
export function normalizeStreetForKeyLocale(street: string, locale: StreetLocale): StreetKey {
|
|
458
|
+
return streetKeyRulesOf(locale).streetKey(street)
|
|
341
459
|
}
|
|
342
460
|
|
|
343
461
|
/**
|
|
@@ -348,39 +466,71 @@ export function normalizeLocalityForKey(locality: string): NameKey {
|
|
|
348
466
|
}
|
|
349
467
|
|
|
350
468
|
/**
|
|
351
|
-
*
|
|
352
|
-
* and {@link normalizeLocalityForKey} otherwise.
|
|
469
|
+
* Apostrophe-like marks that romanized names contain and {@link normalizeLocalityForKey} keeps.
|
|
353
470
|
*
|
|
354
|
-
* The
|
|
471
|
+
* The set holds the Hawaiian, Tongan and Uzbek ʻokina (U+02BB), the modifier
|
|
472
|
+
* apostrophe (U+02BC), the reversed comma above (U+02BD), the prime (U+02B9),
|
|
473
|
+
* the ʾalif and ʿayn half rings (U+02BE, U+02BF), and the left quotation mark (U+2018)
|
|
474
|
+
* and backtick (U+0060) that romanized Arabic, Persian and Pashto names write for ʿayn.
|
|
475
|
+
* A writer typing in ASCII leaves them out or types `'`, which the key drops.
|
|
355
476
|
*/
|
|
356
|
-
|
|
357
|
-
|
|
477
|
+
const APOSTROPHE_LIKE_MARKS = /[ʹʻ-ʿ‘`]/gu
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* The key with every apostrophe-like mark removed, so `Hawaiʻi` and `` `Ajman ``
|
|
481
|
+
* are also found as `hawaii` and `ajman`.
|
|
482
|
+
*
|
|
483
|
+
* The candidate build stages it as one more alias of the place.
|
|
484
|
+
* The query-side key is unchanged, so a query written with the mark still matches the source spelling.
|
|
485
|
+
*/
|
|
486
|
+
export function withoutApostropheLikeMarks(key: NameKey): NameKey {
|
|
487
|
+
return key.replaceAll(APOSTROPHE_LIKE_MARKS, "").replaceAll(/\s+/g, " ").trim() as NameKey
|
|
358
488
|
}
|
|
359
489
|
|
|
360
490
|
/**
|
|
361
|
-
*
|
|
362
|
-
*
|
|
491
|
+
* The tatweel (U+0640), the short-vowel and shadda marks (U+064B–U+065F) and the superscript
|
|
492
|
+
* alef (U+0670), with the hamza and madda that NFKD splits off `أ`, `إ`, `آ`, `ؤ` and `ئ`.
|
|
363
493
|
*/
|
|
364
|
-
|
|
365
|
-
if (locale === "zh") {
|
|
366
|
-
return foldHan(number)
|
|
367
|
-
.replace(/^(\d+)號([之附]\d+)$/u, "$1$2")
|
|
368
|
-
.replace(/號$/u, "")
|
|
369
|
-
}
|
|
494
|
+
const ARABIC_MARKS = /[ـً-ٰٟ]/gu
|
|
370
495
|
|
|
371
|
-
|
|
496
|
+
/**
|
|
497
|
+
* The key with the Arabic letters that writers interchange folded together, so `الاسماعيليه`
|
|
498
|
+
* and `الإسماعيلية`, or `الوادى الجديد` and `الوادي الجديد`, meet at one key.
|
|
499
|
+
*
|
|
500
|
+
* It removes {@link ARABIC_MARKS}, which leaves a hamza-carrying alef as a bare `ا`,
|
|
501
|
+
* and writes `ى` (alef maqsura) as `ي` (yeh) and `ة` (taa marbuta) as `ه` (heh).
|
|
502
|
+
* {@link normalizeLocalityForKey} doesn't apply it, so the columns keyed by that fold are unchanged.
|
|
503
|
+
* A candidate build applies it to `name_key` only under the `arabic-letter-variants` key fold
|
|
504
|
+
* (`#candidate/key-fold`), which the artifact records so its reader folds query keys too.
|
|
505
|
+
*/
|
|
506
|
+
export function withArabicLetterVariantsFolded(key: NameKey): NameKey {
|
|
507
|
+
return key.normalize("NFKD").replaceAll(ARABIC_MARKS, "").replaceAll("ى", "ي").replaceAll("ة", "ه") as NameKey
|
|
372
508
|
}
|
|
373
509
|
|
|
374
|
-
|
|
375
|
-
|
|
510
|
+
/**
|
|
511
|
+
* Builds a locality name's {@link NameKey} under the given locale.
|
|
512
|
+
*
|
|
513
|
+
* The Han rule is a row's own, so the columns of every other locale keep their keys.
|
|
514
|
+
*/
|
|
515
|
+
export function normalizeLocalityForKeyLocale(locality: string, locale: StreetLocale): NameKey {
|
|
516
|
+
return streetKeyRulesOf(locale).localityKey(locality)
|
|
517
|
+
}
|
|
376
518
|
|
|
377
519
|
/**
|
|
378
|
-
*
|
|
379
|
-
|
|
380
|
-
|
|
520
|
+
* Builds a house number's address-point key under the given locale.
|
|
521
|
+
*/
|
|
522
|
+
export function normalizeHouseNumberForKey(number: string, locale: StreetLocale): string {
|
|
523
|
+
return streetKeyRulesOf(locale).houseNumberKey(number)
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* The locale a street's key is built under: the one `base`'s surface route sends the street to,
|
|
528
|
+
* or `base` when the row has no route or the street doesn't match it.
|
|
381
529
|
*/
|
|
382
530
|
export function streetLocaleForSurface(street: string, base: StreetLocale): StreetLocale {
|
|
383
|
-
|
|
531
|
+
const route = streetKeyRulesOf(base).surfaceRoute
|
|
532
|
+
|
|
533
|
+
return route?.pattern.test(street.trimStart()) ? parseStreetLocale(route.locale) : base
|
|
384
534
|
}
|
|
385
535
|
|
|
386
536
|
/**
|
|
@@ -473,14 +623,15 @@ function ordinalOf(n: number): string {
|
|
|
473
623
|
}
|
|
474
624
|
|
|
475
625
|
/**
|
|
476
|
-
* Lists the lookup keys to probe for a street span, most literal first, adding
|
|
477
|
-
*
|
|
626
|
+
* Lists the lookup keys to probe for a street span, most literal first, adding the
|
|
627
|
+
* English respellings for a locale whose rules probe them.
|
|
478
628
|
*/
|
|
479
|
-
export function streetKeyVariants(street: string, locale: StreetLocale
|
|
480
|
-
const
|
|
629
|
+
export function streetKeyVariants(street: string, locale: StreetLocale): StreetKey[] {
|
|
630
|
+
const rules = streetKeyRulesOf(locale)
|
|
631
|
+
const primary = rules.streetKey(street)
|
|
481
632
|
const variants: StreetKey[] = primary ? [primary] : []
|
|
482
633
|
|
|
483
|
-
if (!primary ||
|
|
634
|
+
if (!primary || !rules.englishRespellings) return variants
|
|
484
635
|
|
|
485
636
|
const tokens = primary.split(" ")
|
|
486
637
|
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