@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
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* @file Pass 2 of the candidate build: explode `place_search.alt_names` into distinct alias rows.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { isOverturePartID } from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
8
9
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
9
10
|
import { tableExists } from "@mailwoman/sqlite/introspection"
|
|
10
11
|
|
|
11
12
|
import type { PlaceAttrs, StageRow } from "#candidate/place-attrs"
|
|
12
13
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
13
14
|
import { ALIAS_SEPARATOR } from "#fts"
|
|
15
|
+
import { type NameKey, normalizeLocalityForKey, withoutApostropheLikeMarks } from "#labels/street/normalize"
|
|
14
16
|
import type { WOFDatabase } from "#schema"
|
|
15
|
-
import { type NameKey, normalizeLocalityForKey, withoutApostropheLikeMarks } from "#street/normalize"
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* The official name of every current region, keyed `${country id}\0${name key}` →
|
|
@@ -22,14 +23,19 @@ import { type NameKey, normalizeLocalityForKey, withoutApostropheLikeMarks } fro
|
|
|
22
23
|
*
|
|
23
24
|
* The positive evidence behind the alias refusal below: a name is refused from a region's
|
|
24
25
|
* bag only when another region of the same country holds it as its official name.
|
|
26
|
+
*
|
|
27
|
+
* `rest` leaves out the regions of the Overture Divisions part and `all` holds every region.
|
|
28
|
+
* The gazetteer is a Collective Database whose Overture part is ODbL, so a region outside that part
|
|
29
|
+
* reads `rest`, and an Overture division's official name never refuses a WOF or GeoNames region's alias.
|
|
25
30
|
*/
|
|
26
31
|
function officialNameHoldersByRegion(
|
|
27
32
|
src: DatabaseClient<WOFDatabase>,
|
|
28
33
|
ccID: (code: string | null) => number
|
|
29
|
-
): Map<string, number> {
|
|
30
|
-
const
|
|
34
|
+
): { rest: Map<string, number>; all: Map<string, number> } {
|
|
35
|
+
const rest = new Map<string, number>()
|
|
36
|
+
const all = new Map<string, number>()
|
|
31
37
|
|
|
32
|
-
if (!tableExists(src, "names")) return
|
|
38
|
+
if (!tableExists(src, "names")) return { rest, all }
|
|
33
39
|
|
|
34
40
|
for (const r of src
|
|
35
41
|
.prepare(
|
|
@@ -41,11 +47,18 @@ function officialNameHoldersByRegion(
|
|
|
41
47
|
const k = normalizeLocalityForKey(String(r.name ?? ""))
|
|
42
48
|
|
|
43
49
|
if (k) {
|
|
44
|
-
|
|
50
|
+
const key = `${ccID(r.country as string | null)}\0${k}`
|
|
51
|
+
const id = Number(r.id)
|
|
52
|
+
|
|
53
|
+
all.set(key, id)
|
|
54
|
+
|
|
55
|
+
if (!isOverturePartID(id)) {
|
|
56
|
+
rest.set(key, id)
|
|
57
|
+
}
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
|
|
48
|
-
return
|
|
61
|
+
return { rest, all }
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
/**
|
|
@@ -95,7 +108,7 @@ export function explodeAliasBags(
|
|
|
95
108
|
const official =
|
|
96
109
|
typeof opts.regionPlacetypeID === "number" && opts.ccID
|
|
97
110
|
? officialNameHoldersByRegion(src, opts.ccID)
|
|
98
|
-
: new Map<string, number>()
|
|
111
|
+
: { rest: new Map<string, number>(), all: new Map<string, number>() }
|
|
99
112
|
|
|
100
113
|
out.exec("BEGIN")
|
|
101
114
|
|
|
@@ -108,10 +121,11 @@ export function explodeAliasBags(
|
|
|
108
121
|
const seen = new Set<string>([a.pkey])
|
|
109
122
|
const markFree = new Set<string>()
|
|
110
123
|
const isRegion = a.ptid === opts.regionPlacetypeID
|
|
124
|
+
const holders = isOverturePartID(id) ? official.all : official.rest
|
|
111
125
|
|
|
112
126
|
const refused = (k: string): boolean => {
|
|
113
127
|
if (!isRegion) return false
|
|
114
|
-
const holder =
|
|
128
|
+
const holder = holders.get(`${a.cid}\0${k}`)
|
|
115
129
|
|
|
116
130
|
return typeof holder === "number" && holder !== id
|
|
117
131
|
}
|
|
@@ -76,7 +76,7 @@ import { sql, type Kysely } from "kysely"
|
|
|
76
76
|
// parameter is invariant, so the DDL functions must take the full database type their caller holds.
|
|
77
77
|
// Erased at runtime.
|
|
78
78
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
79
|
-
import type { NameKey } from "#street/normalize"
|
|
79
|
+
import type { NameKey } from "#labels/street/normalize"
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* The deepest chain the sidecar stores per place.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @file Pass 3b of the candidate build — the containment sidecar (closure rows + interval labels).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { isOverturePartID } from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
8
9
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
9
10
|
|
|
10
11
|
import { placetypeDepth } from "#ancestry"
|
|
@@ -77,7 +78,15 @@ export async function buildAncestorsSidecar(ctx: {
|
|
|
77
78
|
ancestorRows++
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
// The gazetteer is a Collective Database whose Overture Divisions part is ODbL.
|
|
82
|
+
// The interval tree links a place only to a parent of its own part, so an Overture division
|
|
83
|
+
// under a WOF record leaves that record's labels as they are without the Overture divisions.
|
|
84
|
+
// The closure rows above keep every edge, and containment across the parts
|
|
85
|
+
// reads them instead of the labels.
|
|
86
|
+
const childOverture = isOverturePartID(childID)
|
|
87
|
+
const canonical = edges.find((edge) => isOverturePartID(edge.aid) === childOverture)?.aid
|
|
88
|
+
|
|
89
|
+
if (typeof canonical !== "number") return
|
|
81
90
|
|
|
82
91
|
canonicalParentOf.set(childID, canonical)
|
|
83
92
|
|
|
@@ -138,8 +147,10 @@ export async function buildAncestorsSidecar(ctx: {
|
|
|
138
147
|
|
|
139
148
|
const roots = [...forest].filter((id) => !canonicalParentOf.has(id))
|
|
140
149
|
|
|
150
|
+
// The Overture part's trees are numbered after every other tree, so the other parts' labels
|
|
151
|
+
// are the labels a build without the Overture divisions gives them.
|
|
141
152
|
// oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass built
|
|
142
|
-
roots.sort((a, b) => a - b)
|
|
153
|
+
roots.sort((a, b) => Number(isOverturePartID(a)) - Number(isOverturePartID(b)) || a - b)
|
|
143
154
|
|
|
144
155
|
let counter = 0
|
|
145
156
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { bareAdminName } from "@mailwoman/codex/country/bare-admin-names"
|
|
9
9
|
|
|
10
10
|
import type { PlaceAttrs, StageRow } from "#candidate/place-attrs"
|
|
11
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
11
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Stages an alias row under the bare form of every place name a country writes with an admin-unit suffix.
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* keeps the coordinate radius from promoting a capital's same-name neighbors (`capitals.ts`).
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { tryParsingJSON } from "@mailwoman/core/json"
|
|
17
|
+
import { tryParsingJSON } from "@mailwoman/core/values/json"
|
|
18
18
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
19
19
|
import type { Kysely } from "kysely"
|
|
20
20
|
|
|
21
|
-
import type { CapitalPoint } from "#capitals"
|
|
21
|
+
import type { CapitalPoint } from "#candidate/capitals"
|
|
22
22
|
import { hasTable } from "#sqlite-utils"
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -47,7 +47,7 @@ export interface CapitalTable {
|
|
|
47
47
|
/**
|
|
48
48
|
* Create the table on a build in progress.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
50
|
+
* The function is async because Kysely's schema builder is asynchronous.
|
|
51
51
|
* Called from the candidate build's DDL phase alongside the other typed builders.
|
|
52
52
|
*/
|
|
53
53
|
export async function createCapitalTable<DB extends { capital: CapitalTable }>(db: Kysely<DB>): Promise<void> {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import { haversine } from "@mailwoman/spatial/geometries/point/distance"
|
|
22
22
|
|
|
23
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
23
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Capital status of one candidate: national capital, admin-1 seat, or neither.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { enumerateCountryDisplayNames } from "@mailwoman/codex/country"
|
|
5
5
|
|
|
6
6
|
import type { PlaceAttrs, StageRow } from "#candidate/place-attrs"
|
|
7
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
7
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Stages each country name that `Intl.DisplayNames` renders in the codex display-name
|
|
@@ -8,8 +8,8 @@ import type { PathBuilderLike } from "path-ts"
|
|
|
8
8
|
import { CANDIDATE_ANCESTOR_COLUMNS, CANDIDATE_ANCESTOR_TABLE } from "#candidate/ancestors/schema"
|
|
9
9
|
import type { PlaceAttrs, StageRow } from "#candidate/place-attrs"
|
|
10
10
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
11
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
11
12
|
import type { WOFDatabase } from "#schema"
|
|
12
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
13
13
|
|
|
14
14
|
function extractRegionAncestry(pc: DatabaseClient<WOFDatabase>, attrs: Map<number, PlaceAttrs>): Map<number, number> {
|
|
15
15
|
const regionOf = new Map<number, number>()
|
|
@@ -41,7 +41,7 @@ function extractRegionAncestry(pc: DatabaseClient<WOFDatabase>, attrs: Map<numbe
|
|
|
41
41
|
* the row also gets that region's scope and the region's ancestor chain.
|
|
42
42
|
* The stored ancestors then agree with the row's scope.
|
|
43
43
|
*/
|
|
44
|
-
export function
|
|
44
|
+
export function stageExtractRows(ctx: {
|
|
45
45
|
out: DatabaseClient<CandidateDatabase>
|
|
46
46
|
extractPath: PathBuilderLike
|
|
47
47
|
extractPlacetype: "postalcode" | "locality"
|
|
@@ -77,11 +77,14 @@ export function foldExtract(ctx: {
|
|
|
77
77
|
|
|
78
78
|
out.exec("BEGIN")
|
|
79
79
|
|
|
80
|
+
// A deprecated record is one its source withdrew as wrong, and it stays out whatever point it holds.
|
|
81
|
+
// A record that only ceased (`is_current = 0`) stays in: a terminated postcode still
|
|
82
|
+
// appears in written addresses, and the extract keeps its last point.
|
|
80
83
|
for (const r of pc
|
|
81
84
|
.prepare(
|
|
82
85
|
`SELECT id, name, country, latitude, longitude,
|
|
83
86
|
min_latitude AS mnlat, min_longitude AS mnlon, max_latitude AS mxlat, max_longitude AS mxlon
|
|
84
|
-
FROM spr WHERE placetype = ? AND latitude != 0 AND longitude != 0`
|
|
87
|
+
FROM spr WHERE placetype = ? AND latitude != 0 AND longitude != 0 AND is_deprecated = 0`
|
|
85
88
|
)
|
|
86
89
|
.iterate(extractPlacetype)) {
|
|
87
90
|
const name = String(r.name ?? "")
|
|
@@ -164,7 +167,7 @@ export function foldExtract(ctx: {
|
|
|
164
167
|
|
|
165
168
|
out.exec("COMMIT")
|
|
166
169
|
} else {
|
|
167
|
-
progress("postcode-aliases", `${extractPath} has no \`names\` table — no delivery-city aliases to
|
|
170
|
+
progress("postcode-aliases", `${extractPath} has no \`names\` table — no delivery-city aliases to add`)
|
|
168
171
|
}
|
|
169
172
|
|
|
170
173
|
return { primaries, aliases, scoped, ancestorRows }
|
|
@@ -35,12 +35,14 @@
|
|
|
35
35
|
* at the position population assigned it.
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
+
import { isOverturePartID } from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
38
39
|
import { haversine } from "@mailwoman/spatial/geometries/point/distance"
|
|
39
40
|
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
40
41
|
import type { PathBuilderLike } from "path-ts"
|
|
41
42
|
|
|
42
43
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
43
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
44
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
45
|
+
import { loadPopulationEstimates, type PlacePopulationEstimateDatabase } from "#schema/place-importance"
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* How far apart two artifacts may put the same place's centroid and still be read as the same place.
|
|
@@ -64,6 +66,10 @@ interface ScoredPlace {
|
|
|
64
66
|
lat: number
|
|
65
67
|
lon: number
|
|
66
68
|
importance: number
|
|
69
|
+
/**
|
|
70
|
+
* Whether the scored place is a row of the Overture Divisions part.
|
|
71
|
+
*/
|
|
72
|
+
overture: boolean
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
/**
|
|
@@ -86,6 +92,11 @@ export interface ImportanceIndexStats {
|
|
|
86
92
|
* (non-Latin punctuation-only names, blanks).
|
|
87
93
|
*/
|
|
88
94
|
unkeyable: number
|
|
95
|
+
/**
|
|
96
|
+
* Population estimates read from `place_population_estimate`, or null
|
|
97
|
+
* when the loader wasn't asked for them.
|
|
98
|
+
*/
|
|
99
|
+
estimates: number | null
|
|
89
100
|
}
|
|
90
101
|
|
|
91
102
|
/**
|
|
@@ -120,10 +131,36 @@ export class ImportanceIndex {
|
|
|
120
131
|
* It doesn't mean the radius is too tight.
|
|
121
132
|
*/
|
|
122
133
|
refused = 0
|
|
134
|
+
/**
|
|
135
|
+
* Places {@link estimatedPopulation} returned an estimate for.
|
|
136
|
+
*/
|
|
137
|
+
estimated = 0
|
|
123
138
|
|
|
124
|
-
|
|
139
|
+
readonly #estimates: ReadonlyMap<number, number>
|
|
140
|
+
|
|
141
|
+
constructor(
|
|
142
|
+
groups: Map<string, ScoredPlace[]>,
|
|
143
|
+
stats: ImportanceIndexStats,
|
|
144
|
+
estimates: ReadonlyMap<number, number> = new Map()
|
|
145
|
+
) {
|
|
125
146
|
this.#groups = groups
|
|
126
147
|
this.stats = stats
|
|
148
|
+
this.#estimates = estimates
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The ranking population the importance build estimated for the place with WOF
|
|
153
|
+
* id `id`, or undefined when it holds none.
|
|
154
|
+
* Ask only for a place without a measured population.
|
|
155
|
+
*/
|
|
156
|
+
estimatedPopulation(id: number): number | undefined {
|
|
157
|
+
const estimate = this.#estimates.get(id)
|
|
158
|
+
|
|
159
|
+
if (typeof estimate === "number") {
|
|
160
|
+
this.estimated++
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return estimate
|
|
127
164
|
}
|
|
128
165
|
|
|
129
166
|
/**
|
|
@@ -136,8 +173,20 @@ export class ImportanceIndex {
|
|
|
136
173
|
*
|
|
137
174
|
* The source column already contains a population-derived fallback where one exists.
|
|
138
175
|
* A second fallback would make an absence indistinguishable from a measurement.
|
|
176
|
+
*
|
|
177
|
+
* The gazetteer is a Collective Database whose Overture Divisions part is ODbL.
|
|
178
|
+
* A row outside that part (`overtureRow` false) reads only scores of places outside it,
|
|
179
|
+
* so an Overture division's Wikidata-joined score never reaches a WOF or GeoNames row.
|
|
180
|
+
* An Overture row may read any score.
|
|
139
181
|
*/
|
|
140
|
-
find(
|
|
182
|
+
find(
|
|
183
|
+
name: string,
|
|
184
|
+
country: string | null,
|
|
185
|
+
placetype: string | null,
|
|
186
|
+
lat: number,
|
|
187
|
+
lon: number,
|
|
188
|
+
overtureRow = false
|
|
189
|
+
): number | null {
|
|
141
190
|
const nameKey = normalizeLocalityForKey(name)
|
|
142
191
|
|
|
143
192
|
if (!nameKey) return null
|
|
@@ -148,8 +197,13 @@ export class ImportanceIndex {
|
|
|
148
197
|
|
|
149
198
|
let best: ScoredPlace | null = null
|
|
150
199
|
let bestKm = Infinity
|
|
200
|
+
let eligible = false
|
|
151
201
|
|
|
152
202
|
for (const place of group) {
|
|
203
|
+
if (place.overture && !overtureRow) continue
|
|
204
|
+
|
|
205
|
+
eligible = true
|
|
206
|
+
|
|
153
207
|
const km = haversine(lat, lon, place.lat, place.lon)
|
|
154
208
|
|
|
155
209
|
if (km < bestKm) {
|
|
@@ -158,6 +212,9 @@ export class ImportanceIndex {
|
|
|
158
212
|
}
|
|
159
213
|
}
|
|
160
214
|
|
|
215
|
+
// A row outside the Overture part reads a group of only Overture scores as an absent group.
|
|
216
|
+
if (!eligible) return null
|
|
217
|
+
|
|
161
218
|
if (!best || bestKm > IMPORTANCE_JOIN_RADIUS_KM) {
|
|
162
219
|
this.refused++
|
|
163
220
|
|
|
@@ -183,9 +240,19 @@ export class ImportanceIndex {
|
|
|
183
240
|
*
|
|
184
241
|
* The whole table is held in memory on purpose, because the build probes it once for every place
|
|
185
242
|
* and the alternative is a prepared statement per place against a multi-gigabyte database.
|
|
243
|
+
*
|
|
244
|
+
* With `populationEstimates`, it also reads `place_population_estimate`, keyed by WOF id
|
|
245
|
+
* because the importance database is a copy of the admin database the candidate build reads.
|
|
246
|
+
*
|
|
247
|
+
* @throws With `populationEstimates`, when the database holds no estimates table.
|
|
186
248
|
*/
|
|
187
|
-
export function loadImportanceIndex(
|
|
188
|
-
|
|
249
|
+
export function loadImportanceIndex(
|
|
250
|
+
databasePath: PathBuilderLike,
|
|
251
|
+
options: { populationEstimates?: boolean } = {}
|
|
252
|
+
): ImportanceIndex {
|
|
253
|
+
using db = new DatabaseClient<CandidateDatabase & PlacePopulationEstimateDatabase>(databasePath, {
|
|
254
|
+
readOnly: true,
|
|
255
|
+
})
|
|
189
256
|
|
|
190
257
|
const groups = new Map<string, ScoredPlace[]>()
|
|
191
258
|
let places = 0
|
|
@@ -193,7 +260,7 @@ export function loadImportanceIndex(databasePath: PathBuilderLike): ImportanceIn
|
|
|
193
260
|
|
|
194
261
|
for (const row of db
|
|
195
262
|
.prepare(
|
|
196
|
-
`SELECT s.name AS name, s.country AS country, s.placetype AS placetype,
|
|
263
|
+
`SELECT s.id AS id, s.name AS name, s.country AS country, s.placetype AS placetype,
|
|
197
264
|
s.latitude AS latitude, s.longitude AS longitude, i.importance AS importance
|
|
198
265
|
FROM place_importance i JOIN spr s ON s.id = i.id
|
|
199
266
|
WHERE s.is_current != 0 AND s.is_deprecated = 0`
|
|
@@ -218,10 +285,21 @@ export function loadImportanceIndex(databasePath: PathBuilderLike): ImportanceIn
|
|
|
218
285
|
groups.set(key, group)
|
|
219
286
|
}
|
|
220
287
|
|
|
221
|
-
group.push({
|
|
288
|
+
group.push({
|
|
289
|
+
lat: Number(row.latitude),
|
|
290
|
+
lon: Number(row.longitude),
|
|
291
|
+
importance,
|
|
292
|
+
overture: isOverturePartID(Number(row.id)),
|
|
293
|
+
})
|
|
222
294
|
|
|
223
295
|
places++
|
|
224
296
|
}
|
|
225
297
|
|
|
226
|
-
|
|
298
|
+
const estimates = options.populationEstimates ? loadPopulationEstimates(db) : null
|
|
299
|
+
|
|
300
|
+
return new ImportanceIndex(
|
|
301
|
+
groups,
|
|
302
|
+
{ places, keys: groups.size, unkeyable, estimates: estimates ? estimates.size : null },
|
|
303
|
+
estimates ?? undefined
|
|
304
|
+
)
|
|
227
305
|
}
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
13
13
|
|
|
14
14
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
15
|
+
import { type NameKey, withArabicLetterVariantsFolded } from "#labels/street/normalize"
|
|
15
16
|
import { hasTable } from "#sqlite-utils"
|
|
16
|
-
import { type NameKey, withArabicLetterVariantsFolded } from "#street/normalize"
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The table that lists the folds applied to the artifact's `name_key` column, one row per fold.
|
package/lib/candidate/lookup.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
3
|
|
|
4
|
-
import { expandPlacetypeFilter } from "@mailwoman/codex/placetype-map"
|
|
4
|
+
import { expandPlacetypeFilter } from "@mailwoman/codex/labels/placetype-map"
|
|
5
5
|
import type { VariantAliasExemption } from "@mailwoman/core/geocode"
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type Ancestor,
|
|
8
|
+
type GazetteerArtifactCoverage,
|
|
9
|
+
populationScoreUnmeasured,
|
|
10
|
+
referentialFromPopulation,
|
|
11
|
+
} from "@mailwoman/core/resolver"
|
|
7
12
|
import { allRows } from "@mailwoman/core/utils"
|
|
8
13
|
import { jaroWinkler, levenshteinSimilarity } from "@mailwoman/match/comparators"
|
|
9
14
|
import { partitionByContainment } from "@mailwoman/resolver"
|
|
@@ -18,17 +23,20 @@ import {
|
|
|
18
23
|
type CandidateAncestorTable,
|
|
19
24
|
type IntervalLabel,
|
|
20
25
|
} from "#candidate/ancestors/schema"
|
|
26
|
+
import { readGazetteerCoverageManifest } from "#candidate/coverage-manifest"
|
|
21
27
|
import { CANDIDATE_FTS_TABLE } from "#candidate/fts"
|
|
22
28
|
import { candidateQueryKeyFold } from "#candidate/key-fold"
|
|
23
29
|
import type { CandidateDatabase, CandidateTable, CountryCodeTable, PlacetypeCodeTable } from "#candidate/schema"
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import { REGION_CLASS_PLACETYPES, regionQualifierProbeKeys } from "#region
|
|
30
|
+
import {
|
|
31
|
+
POSTAL_CITY_CANDIDATE_TABLE,
|
|
32
|
+
type PostalCityCandidateTable,
|
|
33
|
+
} from "#labels/locality/postal-city/candidate-schema"
|
|
34
|
+
import { REGION_CLASS_PLACETYPES, regionQualifierProbeKeys } from "#labels/region"
|
|
35
|
+
import { type NameKey, normalizeLocalityForKey, stripLocalityQualifier } from "#labels/street/normalize"
|
|
36
|
+
import type { FindPlaceQuery, PlaceCandidate, PlaceLookup, WOFPlacetype } from "#lookup/types"
|
|
37
|
+
import { rankByPrimaryPreference, type RankedRow, regionAliasMargin, RERANK_FETCH } from "#ranking/primary-preference"
|
|
38
|
+
import { applyProximityRerank } from "#ranking/proximity-rerank"
|
|
29
39
|
import { hasColumn, hasTable } from "#sqlite-utils"
|
|
30
|
-
import { type NameKey, normalizeLocalityForKey, stripLocalityQualifier } from "#street/normalize"
|
|
31
|
-
import type { FindPlaceQuery, PlaceCandidate, PlaceLookup, WOFPlacetype } from "#types"
|
|
32
40
|
|
|
33
41
|
/**
|
|
34
42
|
* Where a {@link WOFCandidateTableLookup} reads from
|
|
@@ -134,6 +142,8 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
134
142
|
readonly #intervalCache = new Map<number, IntervalLabel | null>()
|
|
135
143
|
|
|
136
144
|
readonly #qualifierProbe: ReturnType<DatabaseClient["prepare"]> | undefined
|
|
145
|
+
|
|
146
|
+
#placeProbe: ReturnType<DatabaseClient["prepare"]> | undefined
|
|
137
147
|
/**
|
|
138
148
|
* The folds the artifact recorded for its `name_key` column, applied to every query key.
|
|
139
149
|
*/
|
|
@@ -665,58 +675,79 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
665
675
|
rows = this.#applyContainment(rows, new Set([query.parentQualifierID]), containmentOptions)
|
|
666
676
|
}
|
|
667
677
|
|
|
668
|
-
const candidates = rows.map((row)
|
|
669
|
-
const hasBbox = row.min_lat != null && row.max_lat != null && row.min_lon != null && row.max_lon != null
|
|
670
|
-
const parent = this.#ancestorLineage(Number(row.spr_id))[0]
|
|
671
|
-
const hasPopulation = row.population !== null && row.population > 0
|
|
678
|
+
const candidates = rows.map((row) => this.#toCandidate(row, regionScopeMiss))
|
|
672
679
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
placetype: (this.#idToPlacetype.get(Number(row.placetype_id)) ?? "") as WOFPlacetype,
|
|
680
|
+
if (query.bias && query.bias.length) {
|
|
681
|
+
applyProximityRerank(candidates, query.bias)
|
|
682
|
+
}
|
|
677
683
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
lon: Number(row.longitude),
|
|
684
|
+
return candidates
|
|
685
|
+
}
|
|
681
686
|
|
|
682
|
-
|
|
687
|
+
/**
|
|
688
|
+
* One place by its `spr_id`, read from its primary-name row, or null when the table holds no row for it.
|
|
689
|
+
*/
|
|
690
|
+
place(id: number): PlaceCandidate | null {
|
|
691
|
+
if (!Number.isInteger(id)) return null
|
|
683
692
|
|
|
684
|
-
|
|
685
|
-
|
|
693
|
+
this.#placeProbe ??= this.database.prepare(
|
|
694
|
+
"SELECT spr_id, name, country_id, placetype_id, latitude, longitude, min_lat, min_lon, max_lat, max_lon, neg_rank, is_primary, population" +
|
|
695
|
+
`${this.#importanceSelect} FROM candidate WHERE spr_id = ? ORDER BY is_primary DESC LIMIT 1`
|
|
696
|
+
)
|
|
686
697
|
|
|
687
|
-
|
|
698
|
+
const row = this.#placeProbe.get(id) as CandidateRow | undefined
|
|
688
699
|
|
|
689
|
-
|
|
700
|
+
return row ? this.#toCandidate({ ...row, effectiveNegRank: row.neg_rank, demoted: false }, false) : null
|
|
701
|
+
}
|
|
690
702
|
|
|
691
|
-
|
|
703
|
+
#toCandidate(row: RankedRow<CandidateRow>, regionScopeMiss: boolean): PlaceCandidate {
|
|
704
|
+
const hasBbox = row.min_lat != null && row.max_lat != null && row.min_lon != null && row.max_lon != null
|
|
705
|
+
const parent = this.#ancestorLineage(Number(row.spr_id))[0]
|
|
706
|
+
const hasPopulation = row.population !== null && row.population > 0
|
|
692
707
|
|
|
693
|
-
|
|
708
|
+
return {
|
|
709
|
+
id: Number(row.spr_id),
|
|
710
|
+
name: String(row.name ?? ""),
|
|
711
|
+
placetype: (this.#idToPlacetype.get(Number(row.placetype_id)) ?? "") as WOFPlacetype,
|
|
694
712
|
|
|
695
|
-
|
|
713
|
+
country: this.#idToCountry.get(Number(row.country_id)) ?? "",
|
|
714
|
+
lat: Number(row.latitude),
|
|
715
|
+
lon: Number(row.longitude),
|
|
696
716
|
|
|
697
|
-
|
|
717
|
+
parent_id: parent ? Number(parent.id) : null,
|
|
698
718
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
719
|
+
score: -Number(row.neg_rank),
|
|
720
|
+
// `neg_rank` is -log10(population + 1), so a place without a population ranks at
|
|
721
|
+
// 0 unmeasured, unless the build ranked it by a population estimate.
|
|
722
|
+
scoreUnmeasured: populationScoreUnmeasured(row.population, Number(row.neg_rank)),
|
|
723
|
+
distanceKm: null,
|
|
702
724
|
|
|
703
|
-
|
|
704
|
-
bbox: hasBbox
|
|
705
|
-
? {
|
|
706
|
-
minLat: Number(row.min_lat),
|
|
707
|
-
maxLat: Number(row.max_lat),
|
|
708
|
-
minLon: Number(row.min_lon),
|
|
709
|
-
maxLon: Number(row.max_lon),
|
|
710
|
-
}
|
|
711
|
-
: null,
|
|
712
|
-
mismatch: null,
|
|
713
|
-
}
|
|
714
|
-
})
|
|
725
|
+
prominence: -Number(row.effectiveNegRank),
|
|
715
726
|
|
|
716
|
-
|
|
717
|
-
applyProximityRerank(candidates, query.bias)
|
|
718
|
-
}
|
|
727
|
+
exactMatch: !row.demoted && !row.fuzzy,
|
|
719
728
|
|
|
720
|
-
|
|
729
|
+
regionScopeMiss: regionScopeMiss ? true : null,
|
|
730
|
+
|
|
731
|
+
containedByQualifier: row.containedByQualifier ?? null,
|
|
732
|
+
|
|
733
|
+
variantAliasExempted: row.variantExempted ? true : null,
|
|
734
|
+
|
|
735
|
+
matchedAlias: row.is_primary === 0 ? true : null,
|
|
736
|
+
|
|
737
|
+
population: hasPopulation ? row.population : null,
|
|
738
|
+
referential: hasPopulation ? referentialFromPopulation(row.population) : null,
|
|
739
|
+
encyclopedic: null,
|
|
740
|
+
|
|
741
|
+
importance: typeof row.importance === "number" && Number.isFinite(row.importance) ? row.importance : null,
|
|
742
|
+
bbox: hasBbox
|
|
743
|
+
? {
|
|
744
|
+
minLat: Number(row.min_lat),
|
|
745
|
+
maxLat: Number(row.max_lat),
|
|
746
|
+
minLon: Number(row.min_lon),
|
|
747
|
+
maxLon: Number(row.max_lon),
|
|
748
|
+
}
|
|
749
|
+
: null,
|
|
750
|
+
mismatch: null,
|
|
751
|
+
}
|
|
721
752
|
}
|
|
722
753
|
}
|
|
@@ -12,8 +12,8 @@ import { tableExists } from "@mailwoman/sqlite/introspection"
|
|
|
12
12
|
import { isOwnNameVariant } from "#candidate/own-name"
|
|
13
13
|
import type { PlaceAttrs } from "#candidate/place-attrs"
|
|
14
14
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
15
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
15
16
|
import type { WOFDatabase } from "#schema"
|
|
16
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Key-count threshold for the gloss anomaly detector.
|
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
* alias row when a populated place holds the same key by a real name.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { GEONAMES_ID_BASE, OVERTURE_ID_BASE } from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
9
10
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
10
11
|
import { tableExists } from "@mailwoman/sqlite/introspection"
|
|
11
12
|
|
|
12
13
|
import type { PlaceAttrs } from "#candidate/place-attrs"
|
|
13
14
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
15
|
+
import { normalizeLocalityForKey, withoutApostropheLikeMarks } from "#labels/street/normalize"
|
|
14
16
|
import type { WOFDatabase } from "#schema"
|
|
15
|
-
import { normalizeLocalityForKey, withoutApostropheLikeMarks } from "#street/normalize"
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* The WOF name kinds that name a place without being its name: a colloquial name
|
|
@@ -112,10 +113,16 @@ export function refuseNicknamesOfNamesakes(
|
|
|
112
113
|
out.exec("CREATE INDEX temp.nickname_key_by_key ON nickname_key (name_key)")
|
|
113
114
|
out.exec("CREATE TEMP TABLE namesake_key (name_key TEXT PRIMARY KEY) WITHOUT ROWID")
|
|
114
115
|
|
|
116
|
+
// An Overture division is never a namesake.
|
|
117
|
+
// The gazetteer is a Collective Database whose Overture Divisions part is ODbL, and a WOF
|
|
118
|
+
// or GeoNames alias refused because of a division's row would be that part altering the rest.
|
|
119
|
+
// The Overture step writes no nickname kind on a division, so no Overture
|
|
120
|
+
// row holds a nickname to refuse either.
|
|
115
121
|
out.exec(
|
|
116
122
|
`INSERT OR IGNORE INTO namesake_key
|
|
117
123
|
SELECT cs.name_key FROM cand_stage cs
|
|
118
124
|
WHERE cs.population > 0
|
|
125
|
+
AND NOT (cs.spr_id >= ${OVERTURE_ID_BASE} AND cs.spr_id < ${GEONAMES_ID_BASE})
|
|
119
126
|
AND cs.name_key IN (SELECT name_key FROM nickname_key)
|
|
120
127
|
AND NOT EXISTS (SELECT 1 FROM nickname_key nk WHERE nk.spr_id = cs.spr_id AND nk.name_key = cs.name_key)`
|
|
121
128
|
)
|