@mailwoman/resolver-wof-sqlite 11.2.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/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/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} +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 +242 -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 +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/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} +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/{street → labels/street}/normalize.d.ts +85 -27
- package/out/labels/street/normalize.d.ts.map +1 -0
- package/out/{street → labels/street}/normalize.js +162 -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.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
package/lib/geonames/aliases.ts
CHANGED
|
@@ -4,26 +4,30 @@
|
|
|
4
4
|
import { isOfficialLanguage } from "@mailwoman/codex/country"
|
|
5
5
|
import { readUnquotedTSV } from "@mailwoman/core/fs/delimited"
|
|
6
6
|
import { pathExists } from "@mailwoman/core/fs/readers/stat"
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
GEONAMES_ID_BASE,
|
|
9
|
+
GEONAMES_POSTAL_ID_BASE,
|
|
10
|
+
geonamesPlaceID,
|
|
11
|
+
} from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
8
12
|
import type { DatabaseClient, StatementSync } from "@mailwoman/sqlite/client"
|
|
9
13
|
import { type PathBuilderLike, resolvePathBuilder } from "path-ts"
|
|
10
14
|
|
|
11
15
|
import type { WOFDatabase } from "#schema"
|
|
12
16
|
|
|
13
|
-
const
|
|
17
|
+
const GEONAMES_OWNED_TABLES = ["spr", "names", "place_population", "ancestors"] as const
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
|
-
* Deletes every row the GeoNames alias
|
|
20
|
+
* Deletes every row the GeoNames alias step owns, with ids in
|
|
17
21
|
* `[GEONAMES_ID_BASE, GEONAMES_POSTAL_ID_BASE)`, and returns the count removed per table.
|
|
18
22
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
23
|
+
* Without this purge, a rerun would keep the previous run's rows, with their names,
|
|
24
|
+
* ancestors and populations, beside the rows it writes.
|
|
21
25
|
* The upper bound leaves the postal and postcode id ranges above it untouched.
|
|
22
26
|
*/
|
|
23
27
|
export function purgeGeonamesAliasRange<DB>(db: DatabaseClient<DB>): Record<string, number> {
|
|
24
28
|
const removed: Record<string, number> = {}
|
|
25
29
|
|
|
26
|
-
for (const table of
|
|
30
|
+
for (const table of GEONAMES_OWNED_TABLES) {
|
|
27
31
|
const result = db
|
|
28
32
|
.prepare(`DELETE FROM ${table} WHERE id >= ? AND id < ?`)
|
|
29
33
|
.run(GEONAMES_ID_BASE, GEONAMES_POSTAL_ID_BASE)
|
|
@@ -58,19 +62,19 @@ export interface GeonamesIngestProgress {
|
|
|
58
62
|
/**
|
|
59
63
|
* The number of alternate names that the alias filter rejected.
|
|
60
64
|
*
|
|
61
|
-
* It distinguishes a sparse source from aliases that the
|
|
65
|
+
* It distinguishes a sparse source from aliases that the ingest discarded.
|
|
62
66
|
*/
|
|
63
67
|
aliasesRefused: number | null
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* The number of populated places that matched an existing record and added their
|
|
67
|
-
* names to it, or null when the
|
|
71
|
+
* names to it, or null when the ingest had no matcher.
|
|
68
72
|
*/
|
|
69
73
|
matched?: number | null
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
/**
|
|
73
|
-
* Formats a GeoNames
|
|
77
|
+
* Formats a GeoNames ingest progress event as one log line.
|
|
74
78
|
*/
|
|
75
79
|
export function formatGeonamesIngestProgress(event: GeonamesIngestProgress, missingFile?: PathBuilderLike): string {
|
|
76
80
|
if (event.skipped) {
|
|
@@ -145,9 +149,9 @@ async function parseAlternateNamesV2(
|
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
/**
|
|
148
|
-
* A GeoNames place the
|
|
152
|
+
* A GeoNames place the ingest is about to write.
|
|
149
153
|
*/
|
|
150
|
-
export interface
|
|
154
|
+
export interface GeonamesPlace {
|
|
151
155
|
geonamesID: number
|
|
152
156
|
name: string
|
|
153
157
|
placetype: "country" | "region" | "locality"
|
|
@@ -157,47 +161,47 @@ export interface GeonamesFoldPlace {
|
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
/**
|
|
160
|
-
* The record a GeoNames place matched in the database
|
|
164
|
+
* The record a GeoNames place matched in the database the places are added to.
|
|
161
165
|
*/
|
|
162
|
-
export interface
|
|
166
|
+
export interface GeonamesPlaceMatch {
|
|
163
167
|
id: number
|
|
164
168
|
placetype: string
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
/**
|
|
168
|
-
* Matches GeoNames places against the records already in the database
|
|
172
|
+
* Matches GeoNames places against the records already in the database the places are added to.
|
|
169
173
|
*/
|
|
170
|
-
export interface
|
|
171
|
-
match(place:
|
|
174
|
+
export interface GeonamesPlaceMatcher {
|
|
175
|
+
match(place: GeonamesPlace): GeonamesPlaceMatch | null
|
|
172
176
|
/**
|
|
173
177
|
* Answers whether the matched record lacks a name, recording it so the name is written once.
|
|
174
178
|
*/
|
|
175
|
-
claimName(match:
|
|
176
|
-
onGap(place:
|
|
179
|
+
claimName(match: GeonamesPlaceMatch, country: string, name: string): boolean
|
|
180
|
+
onGap(place: GeonamesPlace & { id: number }): void
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
/**
|
|
180
|
-
*
|
|
181
|
-
* and links each region
|
|
184
|
+
* Adds one country's GeoNames `A`-class rows, its country and its ADM1 regions,
|
|
185
|
+
* and links each region this step wrote to the country.
|
|
182
186
|
*
|
|
183
187
|
* A row that matches an existing record writes no row and adds its name to that record,
|
|
184
188
|
* and its id is the existing record's.
|
|
185
|
-
* Only regions
|
|
189
|
+
* Only regions this step wrote are re-parented, so an existing region keeps its own parent.
|
|
186
190
|
*/
|
|
187
|
-
function
|
|
191
|
+
function addAdminRows(
|
|
188
192
|
statements: { db: DatabaseClient<WOFDatabase>; spr: StatementSync; names: StatementSync; ancestors: StatementSync },
|
|
189
193
|
input: {
|
|
190
194
|
rows: readonly string[][]
|
|
191
195
|
country: string
|
|
192
196
|
clean: (s: string) => string | null
|
|
193
|
-
existing:
|
|
194
|
-
claim: (match:
|
|
197
|
+
existing: GeonamesPlaceMatcher | undefined
|
|
198
|
+
claim: (match: GeonamesPlaceMatch, name: string) => void
|
|
195
199
|
}
|
|
196
200
|
): { countryID: number; adminMap: Map<string, number> } {
|
|
197
201
|
const { rows, country: cc, clean, existing, claim } = input
|
|
198
202
|
let countryID = -1
|
|
199
203
|
const adminMap = new Map<string, number>()
|
|
200
|
-
// The regions this
|
|
204
|
+
// The regions this step wrote, as opposed to existing records a region matched.
|
|
201
205
|
const writtenRegions = new Set<number>()
|
|
202
206
|
|
|
203
207
|
for (const f of rows) {
|
|
@@ -206,7 +210,7 @@ function foldAdminRows(
|
|
|
206
210
|
if (!aname) continue
|
|
207
211
|
const lat = Number(f[4]) || 0
|
|
208
212
|
const lon = Number(f[5]) || 0
|
|
209
|
-
const placetype:
|
|
213
|
+
const placetype: GeonamesPlace["placetype"] = f[7]?.startsWith("PCL") ? "country" : "region"
|
|
210
214
|
|
|
211
215
|
if (placetype === "country" && countryID >= 0) continue
|
|
212
216
|
|
|
@@ -219,7 +223,7 @@ function foldAdminRows(
|
|
|
219
223
|
claim(matched, aname)
|
|
220
224
|
}
|
|
221
225
|
|
|
222
|
-
const rid = matched?.id ??
|
|
226
|
+
const rid = matched?.id ?? geonamesPlaceID(place.geonamesID)
|
|
223
227
|
|
|
224
228
|
if (!matched) {
|
|
225
229
|
statements.spr.run(rid, -1, aname, placetype, cc, lat, lon, lat, lon, lat, lon, 1, 0, 0, 0, 0, 0)
|
|
@@ -250,8 +254,8 @@ function foldAdminRows(
|
|
|
250
254
|
}
|
|
251
255
|
|
|
252
256
|
/**
|
|
253
|
-
* Purges the
|
|
254
|
-
* alternate names for `countries` to `db`.
|
|
257
|
+
* Purges the GeoNames alias id range, then adds GeoNames `P`-class places
|
|
258
|
+
* and their alternate names for `countries` to `db`.
|
|
255
259
|
* It returns the number of places ingested.
|
|
256
260
|
*
|
|
257
261
|
* The caller must then rebuild `place_search` with `buildPlaceSearchFTS(db, { drop: true })`
|
|
@@ -272,7 +276,7 @@ export async function ingestGeonamesAliases(
|
|
|
272
276
|
* A GeoNames place that matches one adds its names to that record and writes no row.
|
|
273
277
|
* A place that matches none is written and reported to `onGap`.
|
|
274
278
|
*/
|
|
275
|
-
existing?:
|
|
279
|
+
existing?: GeonamesPlaceMatcher
|
|
276
280
|
}
|
|
277
281
|
): Promise<number> {
|
|
278
282
|
const LATIN_NAME = /^[\p{Script=Latin}\p{M}\s\-'.]{2,60}$/u
|
|
@@ -364,14 +368,14 @@ export async function ingestGeonamesAliases(
|
|
|
364
368
|
/**
|
|
365
369
|
* Writes a place's name onto the existing record it matched, once.
|
|
366
370
|
*/
|
|
367
|
-
const claim = (match:
|
|
371
|
+
const claim = (match: GeonamesPlaceMatch, name: string, language = "", privateuse = "", official = 0) => {
|
|
368
372
|
if (opts?.existing?.claimName(match, cc, name)) {
|
|
369
373
|
namesInsert.run(match.id, name, match.placetype, cc, language, privateuse, official, 0)
|
|
370
374
|
}
|
|
371
375
|
}
|
|
372
376
|
|
|
373
377
|
const { countryID, adminMap } = addAdmin
|
|
374
|
-
?
|
|
378
|
+
? addAdminRows(
|
|
375
379
|
{ db, spr: sprInsert, names: namesInsert, ancestors: ancestorInsert },
|
|
376
380
|
{ rows: adminRows, country: cc, clean, existing: opts?.existing, claim }
|
|
377
381
|
)
|
|
@@ -423,7 +427,7 @@ export async function ingestGeonamesAliases(
|
|
|
423
427
|
continue
|
|
424
428
|
}
|
|
425
429
|
|
|
426
|
-
const nid =
|
|
430
|
+
const nid = geonamesPlaceID(place.geonamesID)
|
|
427
431
|
|
|
428
432
|
opts?.existing?.onGap({ ...place, id: nid })
|
|
429
433
|
|
package/lib/geonames/postal.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Adds GeoNames postcode rows to a WOF or unified postcode extract as first-class
|
|
6
6
|
* `postalcode` places for countries whose WOF postalcode repos do not exist.
|
|
7
7
|
*
|
|
8
8
|
* Two laws are enforced here in code rather than in a runbook.
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Their average puts the code somewhere no address is.
|
|
19
19
|
* The medoid is the member point nearest the group's mean.
|
|
20
20
|
*
|
|
21
|
-
* `build-unified-wof --geonames-postal-countries`, standalone
|
|
21
|
+
* `build-unified-wof --geonames-postal-countries`, standalone ingests and the `mailwoman
|
|
22
22
|
* gazetteer` commands share one implementation. The GeoNames postal dump is
|
|
23
23
|
* `download.geonames.org/export/zip/<CC>.zip` → `<CC>.txt`, a headerless TSV of country,
|
|
24
24
|
* postcode, place, admin1, code1, admin2, code2, admin3, code3, lat, lon and accuracy.
|
|
@@ -209,7 +209,7 @@ export interface GeonamesPostalIngestResult {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
|
-
*
|
|
212
|
+
* Add GeoNames postcodes for `countries` to an open unified/postcode ingest DB: one `spr` row
|
|
213
213
|
* per distinct normalized postcode (placetype `postalcode`, medoid centroid, degenerate bbox),
|
|
214
214
|
* the normalized form as `name`, and the display form as an extra `names` row when it differs.
|
|
215
215
|
*
|
package/lib/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
3
|
|
|
4
|
-
export type { FindPlaceQuery, PlaceCandidate, PlaceLookup, WOFPlacetype } from "#types"
|
|
4
|
+
export type { FindPlaceQuery, PlaceCandidate, PlaceLookup, WOFPlacetype } from "#lookup/types"
|
|
5
5
|
|
|
6
6
|
export type {
|
|
7
7
|
AncestorsTable,
|
|
@@ -16,7 +16,7 @@ export type {
|
|
|
16
16
|
} from "#schema"
|
|
17
17
|
|
|
18
18
|
export { WOFSQLitePlaceLookup, type WOFSQLitePlaceLookupOpts } from "#lookup"
|
|
19
|
-
export { type RankingWeights } from "#ranking
|
|
19
|
+
export { type RankingWeights } from "#ranking/weights"
|
|
20
20
|
|
|
21
21
|
export {
|
|
22
22
|
CANDIDATE_ANCESTOR_COLUMNS,
|
|
@@ -53,10 +53,10 @@ export {
|
|
|
53
53
|
createCountryCoverageTable,
|
|
54
54
|
readGazetteerCoverageManifest,
|
|
55
55
|
writeGazetteerCoverageManifest,
|
|
56
|
-
} from "#coverage-manifest
|
|
56
|
+
} from "#candidate/coverage-manifest"
|
|
57
57
|
|
|
58
|
-
export type { CountryBBoxTable, CountryCoverageTable, GazetteerCoverageDatabase } from "#coverage-manifest
|
|
59
|
-
export { SQLiteStreetNameLookup, type SQLiteStreetNameLookupOpts } from "#street/name-lookup"
|
|
58
|
+
export type { CountryBBoxTable, CountryCoverageTable, GazetteerCoverageDatabase } from "#candidate/coverage-manifest"
|
|
59
|
+
export { SQLiteStreetNameLookup, type SQLiteStreetNameLookupOpts } from "#labels/street/name-lookup"
|
|
60
60
|
|
|
61
61
|
export { type GeonamesIngestProgress, ingestGeonamesAliases, purgeGeonamesAliasRange } from "#geonames/aliases"
|
|
62
62
|
|
|
@@ -67,17 +67,20 @@ export {
|
|
|
67
67
|
WOFPostalCityAliasLookup,
|
|
68
68
|
type PostalCityAlias,
|
|
69
69
|
type WOFPostalCityAliasLookupOpts,
|
|
70
|
-
} from "#postal
|
|
70
|
+
} from "#labels/locality/postal-city/alias/lookup"
|
|
71
71
|
|
|
72
|
-
export type { PostalCityAliasDatabase, PostalCityAliasTable } from "#postal
|
|
72
|
+
export type { PostalCityAliasDatabase, PostalCityAliasTable } from "#labels/locality/postal-city/alias/schema"
|
|
73
73
|
|
|
74
74
|
export {
|
|
75
75
|
POSTAL_CITY_CANDIDATE_COLUMNS,
|
|
76
76
|
POSTAL_CITY_CANDIDATE_TABLE,
|
|
77
77
|
createPostalCityCandidateTable,
|
|
78
|
-
} from "#postal
|
|
78
|
+
} from "#labels/locality/postal-city/candidate-schema"
|
|
79
79
|
|
|
80
|
-
export type {
|
|
80
|
+
export type {
|
|
81
|
+
PostalCityCandidateDatabase,
|
|
82
|
+
PostalCityCandidateTable,
|
|
83
|
+
} from "#labels/locality/postal-city/candidate-schema"
|
|
81
84
|
|
|
82
85
|
export {
|
|
83
86
|
ADDRESS_CONVENTION_TABLE,
|
|
@@ -95,7 +98,7 @@ export {
|
|
|
95
98
|
|
|
96
99
|
export { SqliteConventionSource } from "#sqlite/convention-source"
|
|
97
100
|
|
|
98
|
-
export { WOFPostcodeLookup } from "#postcode-point
|
|
101
|
+
export { WOFPostcodeLookup } from "#lookup/postcode-point"
|
|
99
102
|
|
|
100
103
|
export {
|
|
101
104
|
PLACE_BBOX_TABLE,
|
|
@@ -115,28 +118,28 @@ export {
|
|
|
115
118
|
type ReverseGeocodeOpts,
|
|
116
119
|
type ReverseGeocodeResult,
|
|
117
120
|
type WOFReverseGeocoderOpts,
|
|
118
|
-
} from "#reverse"
|
|
121
|
+
} from "#lookup/reverse"
|
|
119
122
|
|
|
120
123
|
export { AddressPointInterpolator } from "#address/point/interpolation"
|
|
121
124
|
export { AddressPointSqliteLookup } from "#address/point"
|
|
122
125
|
export { openAddressLayerLookup } from "#address/keys/open"
|
|
123
|
-
export { readLatestAddressLayerManifest } from "#address/keys/layout"
|
|
126
|
+
export { readLatestAddressLayerManifest, readLatestAddressLayerManifests } from "#address/keys/layout"
|
|
124
127
|
|
|
125
128
|
export {
|
|
126
129
|
STREET_CENTROID_COLUMNS,
|
|
127
130
|
createStreetCentroidIndexes,
|
|
128
131
|
createStreetCentroidTable,
|
|
129
|
-
} from "#street/centroid/schema"
|
|
132
|
+
} from "#labels/street/centroid/schema"
|
|
130
133
|
|
|
131
|
-
export type { StreetCentroidDatabase, StreetCentroidTable } from "#street/centroid/schema"
|
|
132
|
-
export { StreetCentroidSqliteLookup } from "#street/centroid"
|
|
134
|
+
export type { StreetCentroidDatabase, StreetCentroidTable } from "#labels/street/centroid/schema"
|
|
135
|
+
export { StreetCentroidSqliteLookup } from "#labels/street/centroid"
|
|
133
136
|
|
|
134
137
|
export {
|
|
135
138
|
StreetInterpolator,
|
|
136
139
|
type InterpolatedHit,
|
|
137
140
|
type InterpolationMethod,
|
|
138
141
|
type InterpolationQuery,
|
|
139
|
-
} from "#interpolation"
|
|
142
|
+
} from "#labels/street/interpolation"
|
|
140
143
|
|
|
141
144
|
export {
|
|
142
145
|
deriveSchemaName,
|
|
@@ -144,4 +147,4 @@ export {
|
|
|
144
147
|
resolveExtracts,
|
|
145
148
|
type ResolvedExtract,
|
|
146
149
|
type ExtractConfig,
|
|
147
|
-
} from "#extracts"
|
|
150
|
+
} from "#lookup/extracts"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
import { SQLiteLookup, type SQLiteLookupOptions } from "@mailwoman/sqlite/lookup"
|
|
21
21
|
|
|
22
|
-
import type { PostalCityAliasDatabase } from "#postal
|
|
22
|
+
import type { PostalCityAliasDatabase } from "#labels/locality/postal-city/alias/schema"
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Where a {@link WOFPostalCityAliasLookup} reads from: a `postal-city-alias-<cc>.db` built by
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
export * from "#labels/locality/postal-city/alias/lookup"
|
|
5
|
+
export * from "#labels/locality/postal-city/alias/schema"
|
|
6
|
+
export * from "#labels/locality/postal-city/candidate-schema"
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
* The keys a parsed region qualifier is compared under: its own key,
|
|
6
|
+
* its subdivision's names and its county-prefix variants.
|
|
7
|
+
*
|
|
5
8
|
* Both consumers use this expansion to compare parsed region qualifiers with stored keys.
|
|
6
9
|
*
|
|
7
|
-
* Admin-coherence verdicts (`mailwoman/admin-coherence.ts`) fold a qualifier
|
|
10
|
+
* Admin-coherence verdicts (`mailwoman/geocode/result/admin-coherence.ts`) fold a qualifier
|
|
8
11
|
* and the winner's ancestry to decide `confirmed` or `contradicted`.
|
|
9
12
|
* The candidate backend's admin-containment re-rank (`candidate-lookup.ts`)
|
|
10
13
|
* uses the same fold to find region-class rows.
|
|
@@ -17,7 +20,7 @@
|
|
|
17
20
|
|
|
18
21
|
import { matchSubdivision, matchSubdivisionIn } from "@mailwoman/codex/country"
|
|
19
22
|
|
|
20
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
23
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* The ancestry placetypes that answer for a parsed `region` qualifier,
|
|
@@ -10,8 +10,7 @@ import { haversine } from "@mailwoman/spatial/geometries/point/distance"
|
|
|
10
10
|
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
11
11
|
import type { PathBuilderLike } from "path-ts"
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import type { StreetCentroidDatabase } from "#street/centroid/schema"
|
|
13
|
+
import type { StreetCentroidDatabase } from "#labels/street/centroid/schema"
|
|
15
14
|
import {
|
|
16
15
|
normalizeLocalityForKey,
|
|
17
16
|
normalizeStreetForKeyLocale,
|
|
@@ -20,7 +19,8 @@ import {
|
|
|
20
19
|
streetLocaleForSurface,
|
|
21
20
|
type StreetLocale,
|
|
22
21
|
stripArrondissement,
|
|
23
|
-
} from "#street/normalize"
|
|
22
|
+
} from "#labels/street/normalize"
|
|
23
|
+
import { hasTable, prepareGet, type PreparedGet } from "#sqlite-utils"
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* The weighted centroid, extent and provenance an aggregate probe returns;
|
|
@@ -65,12 +65,12 @@ export class StreetCentroidSqliteLookup implements StreetCentroidLookup {
|
|
|
65
65
|
readonly #byLocality: PreparedGet<[locality: NameKey, street: StreetKey], AggRow> | undefined
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* The
|
|
69
|
-
* A mismatch
|
|
68
|
+
* @param opts.streetLocale The street locale the extract was built under.
|
|
69
|
+
* A mismatch makes every key miss.
|
|
70
70
|
*/
|
|
71
|
-
constructor(dbPath: PathBuilderLike, opts: { streetLocale
|
|
71
|
+
constructor(dbPath: PathBuilderLike, opts: { streetLocale: StreetLocale }) {
|
|
72
72
|
this.#db = new DatabaseClient<StreetCentroidDatabase>(dbPath, { readOnly: true })
|
|
73
|
-
this.#locale = opts.streetLocale
|
|
73
|
+
this.#locale = opts.streetLocale
|
|
74
74
|
|
|
75
75
|
// An extract without a `street_centroid` table makes every lookup miss.
|
|
76
76
|
if (hasTable(this.#db, "street_centroid")) {
|
|
@@ -7,15 +7,23 @@
|
|
|
7
7
|
* and linear interpolation along the segment polyline.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { parseJSONStrict } from "@mailwoman/core/json"
|
|
11
10
|
import type { InterpolationLookup } from "@mailwoman/core/resolver"
|
|
11
|
+
import { parseJSONStrict } from "@mailwoman/core/values/json"
|
|
12
12
|
import { haversine } from "@mailwoman/spatial/geometries/point/distance"
|
|
13
13
|
import { clampFraction, pointAlong } from "@mailwoman/spatial/polyline"
|
|
14
14
|
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
15
15
|
|
|
16
|
+
import { streetLocaleForCountry } from "#labels/street/locale"
|
|
17
|
+
import { canonicalizeRouteKey, type RouteKey, streetKeyVariants } from "#labels/street/normalize"
|
|
18
|
+
import type { StreetSegmentDatabase } from "#labels/street/segment-schema"
|
|
16
19
|
import { hasTable, prepareAll, type PreparedAll } from "#sqlite-utils"
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
// country-branch: the segment databases are built from TIGER, the United States' street network.
|
|
22
|
+
// A street locale passed by the provider that opens a database would replace the constant.
|
|
23
|
+
/**
|
|
24
|
+
* The street locale the segment databases' keys are built under.
|
|
25
|
+
*/
|
|
26
|
+
const SEGMENT_STREET_LOCALE = streetLocaleForCountry("US")
|
|
19
27
|
|
|
20
28
|
/**
|
|
21
29
|
* How an interpolated answer was computed, `address_point` for bracketed neighbor points
|
|
@@ -208,7 +216,7 @@ export class StreetInterpolator<
|
|
|
208
216
|
const n = Number(numberRaw)
|
|
209
217
|
|
|
210
218
|
// A variant advances the ladder when it produces no answer rather than merely no rows.
|
|
211
|
-
for (const variant of streetKeyVariants(query.street)) {
|
|
219
|
+
for (const variant of streetKeyVariants(query.street, SEGMENT_STREET_LOCALE)) {
|
|
212
220
|
const streetNorm = canonicalizeRouteKey(variant)
|
|
213
221
|
|
|
214
222
|
// A ZIP that scopes to no candidate is a miss rather than a statewide guess.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The street locale every country's address keys are folded under, for builders and readers alike.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { OFFICIAL_LANGUAGES } from "@mailwoman/codex/country/official-languages"
|
|
9
|
+
|
|
10
|
+
import { parseStreetLocale, type StreetLocale } from "#labels/street/normalize"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A table from a language or country code to the street locale each row spells.
|
|
14
|
+
*
|
|
15
|
+
* A row that spells no street locale stops the module from loading.
|
|
16
|
+
*/
|
|
17
|
+
function streetLocaleTable(
|
|
18
|
+
rows: ReadonlyArray<readonly [code: string, spelling: string]>
|
|
19
|
+
): ReadonlyMap<string, StreetLocale> {
|
|
20
|
+
return new Map(rows.map(([code, spelling]) => [code, parseStreetLocale(spelling)]))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The locale whose rules fold streets written in each language, keyed by the two-letter
|
|
25
|
+
* ISO 639-1 code `OFFICIAL_LANGUAGES` lists first among a language's spellings.
|
|
26
|
+
*/
|
|
27
|
+
const STREET_LOCALE_BY_LANGUAGE = streetLocaleTable([
|
|
28
|
+
["en", "en"],
|
|
29
|
+
["es", "es"],
|
|
30
|
+
["fr", "fr"],
|
|
31
|
+
["de", "de"],
|
|
32
|
+
["it", "it"],
|
|
33
|
+
["nl", "nl"],
|
|
34
|
+
["pl", "pl"],
|
|
35
|
+
["vi", "vn"],
|
|
36
|
+
["id", "id"],
|
|
37
|
+
["zh", "zh"],
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The locale of a country whose official languages select no one row of rules.
|
|
42
|
+
*/
|
|
43
|
+
const UNDETERMINED_STREET_LOCALE = parseStreetLocale("und")
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Countries whose built address databases fold under a locale their official languages don't select.
|
|
47
|
+
*
|
|
48
|
+
* Each row records how that country's databases were keyed, since a built database records no street locale.
|
|
49
|
+
*
|
|
50
|
+
* Canada's official languages span two locales.
|
|
51
|
+
* Its OSM extract folds under `en`, and `streetLocaleForSurface` routes a street
|
|
52
|
+
* that opens with a French type word to `fr`.
|
|
53
|
+
*
|
|
54
|
+
* The United States' state databases and address layer fold under `us`.
|
|
55
|
+
* Their builders key every street under the English fold, so the reader leaves a
|
|
56
|
+
* street such as `Promenade Blvd` to that fold too.
|
|
57
|
+
*/
|
|
58
|
+
const STREET_LOCALE_EXCEPTIONS = streetLocaleTable([
|
|
59
|
+
["CA", "en"],
|
|
60
|
+
["US", "us"],
|
|
61
|
+
])
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The locale a country's streets fold under: its exception when it has one, else the one locale
|
|
65
|
+
* its official languages have rules in, else `und`, the shared fold with no language's abbreviations.
|
|
66
|
+
*
|
|
67
|
+
* The answer covers every ISO 3166-1 country, so a builder and a reader that
|
|
68
|
+
* both call this fold one street to one key.
|
|
69
|
+
* It is the one place a country is mapped to a street locale: every builder,
|
|
70
|
+
* reader and artifact manifest reads it.
|
|
71
|
+
*
|
|
72
|
+
* A country whose official languages span several locales folds under `und`
|
|
73
|
+
* until its built databases name one in {@link STREET_LOCALE_EXCEPTIONS}.
|
|
74
|
+
*/
|
|
75
|
+
export function streetLocaleForCountry(countryCode: string): StreetLocale {
|
|
76
|
+
const country = countryCode.trim().toUpperCase()
|
|
77
|
+
const exception = STREET_LOCALE_EXCEPTIONS.get(country)
|
|
78
|
+
|
|
79
|
+
if (exception) return exception
|
|
80
|
+
|
|
81
|
+
const locales = new Set<StreetLocale>()
|
|
82
|
+
|
|
83
|
+
for (const language of OFFICIAL_LANGUAGES[country]?.official ?? []) {
|
|
84
|
+
const locale = STREET_LOCALE_BY_LANGUAGE.get(language)
|
|
85
|
+
|
|
86
|
+
if (locale) {
|
|
87
|
+
locales.add(locale)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return locales.size === 1 ? [...locales][0]! : UNDETERMINED_STREET_LOCALE
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Creates the street-locale lookup for one source's built databases.
|
|
96
|
+
*
|
|
97
|
+
* `localeFor` answers {@link streetLocaleForCountry} for a country in `countries`
|
|
98
|
+
* and throws for any other, since that source has built no database there to key a query for.
|
|
99
|
+
* Every source therefore keys a country's streets under one locale.
|
|
100
|
+
*/
|
|
101
|
+
export function createStreetLocaleRegistry(
|
|
102
|
+
countries: readonly string[],
|
|
103
|
+
label: string
|
|
104
|
+
): { localeFor: (countryCode: string) => StreetLocale; supported: () => string[] } {
|
|
105
|
+
const built = new Set(countries.map((country) => country.toLowerCase()))
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
localeFor: (countryCode) => {
|
|
109
|
+
if (!built.has(countryCode.toLowerCase())) {
|
|
110
|
+
throw new Error(`No database is registered for country "${countryCode}". ${label}`)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return streetLocaleForCountry(countryCode)
|
|
114
|
+
},
|
|
115
|
+
supported: () => [...built],
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -29,8 +29,8 @@ import type { PathBuilder, PathBuilderLike } from "path-ts"
|
|
|
29
29
|
import type { FSTMatcher } from "#fst/matcher"
|
|
30
30
|
import { deserializeFST, readFSTProvenance } from "#fst/serialize"
|
|
31
31
|
import type { FSTProvenance } from "#fst/types"
|
|
32
|
+
import { buildStreetMorphologyFST } from "#labels/street/morphology/fst/builder"
|
|
32
33
|
import { wofDatabasePath } from "#paths"
|
|
33
|
-
import { buildStreetMorphologyFST } from "#street/morphology/fst/builder"
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* The sealed artifact's canonical filename, identical in the data-root staging dir
|
|
@@ -55,6 +55,8 @@ export class SQLiteStreetNameLookup extends SQLiteLookup<WOFDatabase> implements
|
|
|
55
55
|
|
|
56
56
|
constructor(dbPath: PathBuilderLike, opts: SQLiteStreetNameLookupOpts = {}) {
|
|
57
57
|
super({ databasePath: dbPath })
|
|
58
|
+
// country-branch: the default instance is the BAN street-centroid extract, a table of French streets.
|
|
59
|
+
// The countries recorded in the extract's manifest would replace the default.
|
|
58
60
|
this.countries = new Set([...(opts.countries ?? ["FR"])].map((c) => c.toUpperCase()))
|
|
59
61
|
const table = opts.table ?? "street_centroid"
|
|
60
62
|
|