@mailwoman/resolver-wof-sqlite 11.0.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/lib/address/duplicate.ts +133 -0
- package/lib/address/keys/attribution.ts +119 -0
- package/lib/address/keys/build.ts +768 -0
- package/lib/address/keys/layout.ts +166 -0
- package/lib/address/keys/local-runner.ts +18 -0
- package/lib/address/keys/lookup.ts +205 -0
- package/lib/address/keys/open.ts +33 -0
- package/lib/address/keys/point-lookup.ts +130 -0
- package/lib/address/keys/postcode.ts +27 -0
- package/lib/address/keys/schema.ts +264 -0
- package/lib/address/number-forms.ts +61 -0
- package/lib/address/point/interpolation.ts +28 -23
- package/lib/address/point/schema.ts +2 -5
- package/lib/address/point/spine-schema.ts +4 -4
- package/lib/address/point.ts +12 -79
- package/lib/address/record.ts +155 -0
- package/lib/address/stack.ts +20 -0
- package/lib/address/subdivision-bounds.ts +81 -0
- package/lib/address.ts +2 -5
- package/lib/ancestry/backfill.ts +18 -47
- package/lib/ancestry.ts +10 -10
- package/lib/build/candidate.ts +44 -48
- package/lib/build/population-corrections.ts +4 -4
- package/lib/build/slim.ts +3 -6
- package/lib/candidate/alias-bags.ts +58 -18
- package/lib/candidate/ancestors/schema.ts +63 -43
- package/lib/candidate/ancestors/sidecar.ts +3 -3
- package/lib/candidate/bare-admin-names.ts +3 -3
- package/lib/candidate/country-display-names.ts +2 -5
- package/lib/candidate/extract-fold.ts +2 -5
- package/lib/candidate/fts.ts +5 -5
- package/lib/candidate/importance.ts +30 -24
- package/lib/candidate/key-fold.ts +132 -0
- package/lib/candidate/lookup.ts +25 -18
- package/lib/candidate/name-roles.ts +4 -4
- package/lib/candidate/nickname-namesakes.ts +140 -0
- package/lib/candidate/own-name.ts +12 -10
- package/lib/candidate/place-attrs.ts +4 -4
- package/lib/candidate/schema.ts +2 -5
- package/lib/candidate/scoring.ts +3 -6
- package/lib/capital-schema.ts +11 -10
- package/lib/capitals.ts +15 -12
- package/lib/convention/schema.ts +7 -7
- package/lib/convention.ts +3 -3
- package/lib/coverage-manifest-schema.ts +4 -4
- package/lib/env.ts +7 -6
- package/lib/exact-match.ts +6 -7
- package/lib/extracts.ts +11 -9
- package/lib/fst/autocomplete.ts +19 -15
- package/lib/fst/binary-matcher.ts +36 -50
- package/lib/fst/builder.ts +32 -11
- package/lib/fst/deserialize-web.ts +9 -8
- package/lib/fst/format.ts +153 -14
- package/lib/fst/freshness.ts +3 -4
- package/lib/fst/matcher.ts +6 -6
- package/lib/fst/serialize.ts +94 -69
- package/lib/fst/types.ts +4 -4
- package/lib/fst.ts +2 -5
- package/lib/fts/query.ts +3 -4
- package/lib/fts.ts +2 -5
- package/lib/geonames/aliases.ts +189 -46
- package/lib/geonames/postal.ts +17 -15
- package/lib/geonames.ts +2 -5
- package/lib/importance-source.ts +210 -0
- package/lib/index.ts +4 -5
- package/lib/interpolation.ts +7 -6
- package/lib/landmark/rows.ts +5 -5
- package/lib/landmark.ts +6 -6
- package/lib/lookup.ts +8 -8
- package/lib/name-score.ts +7 -6
- package/lib/nsul/lookup.ts +19 -15
- package/lib/nsul/schema.ts +4 -5
- package/lib/nsul.ts +2 -5
- package/lib/paths.ts +7 -7
- package/lib/place-importance-schema.ts +5 -8
- package/lib/poi/lookup.ts +11 -10
- package/lib/poi/schema.ts +16 -10
- package/lib/poi.ts +2 -5
- package/lib/polygon-schema.ts +10 -9
- package/lib/postal/city/alias/lookup.ts +14 -13
- package/lib/postal/city/alias/schema.ts +12 -12
- package/lib/postal/city/candidate-schema.ts +15 -12
- package/lib/postal.ts +2 -5
- package/lib/postcode-point-lookup.ts +2 -5
- package/lib/primary-preference.ts +42 -7
- package/lib/proximity-rerank.ts +23 -19
- package/lib/ranking-weights.ts +8 -7
- package/lib/region-keys.ts +15 -14
- package/lib/reverse.ts +16 -17
- package/lib/schema.ts +20 -6
- package/lib/search-fetch.ts +15 -11
- package/lib/sqlite/convention-source.ts +2 -5
- package/lib/sqlite/utils.ts +4 -4
- package/lib/street/centroid/schema.ts +6 -6
- package/lib/street/centroid.ts +3 -3
- package/lib/street/locale.ts +64 -0
- package/lib/street/morphology/fst/builder.ts +21 -19
- package/lib/street/morphology/fst/loader.ts +15 -13
- package/lib/street/name-lookup.ts +15 -14
- package/lib/street/normalize.ts +62 -17
- package/lib/street/segment-schema.ts +16 -14
- package/lib/street/table.ts +276 -0
- package/lib/street.ts +3 -5
- package/lib/types.ts +3 -6
- package/lib/unified-schema.ts +31 -9
- package/lib/uprn/existence.ts +10 -10
- package/lib/uprn/lookup.ts +7 -8
- package/lib/uprn/schema.ts +5 -5
- package/lib/uprn.ts +2 -5
- package/lib/weights-overlay-linker.ts +5 -8
- package/out/address/duplicate.d.ts +74 -0
- package/out/address/duplicate.d.ts.map +1 -0
- package/out/address/duplicate.js +79 -0
- package/out/address/duplicate.js.map +1 -0
- package/out/address/keys/attribution.d.ts +56 -0
- package/out/address/keys/attribution.d.ts.map +1 -0
- package/out/address/keys/attribution.js +64 -0
- package/out/address/keys/attribution.js.map +1 -0
- package/out/address/keys/build.d.ts +154 -0
- package/out/address/keys/build.d.ts.map +1 -0
- package/out/address/keys/build.js +423 -0
- package/out/address/keys/build.js.map +1 -0
- package/out/address/keys/layout.d.ts +92 -0
- package/out/address/keys/layout.d.ts.map +1 -0
- package/out/address/keys/layout.js +87 -0
- package/out/address/keys/layout.js.map +1 -0
- package/out/address/keys/local-runner.d.ts +9 -0
- package/out/address/keys/local-runner.d.ts.map +1 -0
- package/out/address/keys/local-runner.js +13 -0
- package/out/address/keys/local-runner.js.map +1 -0
- package/out/address/keys/lookup.d.ts +80 -0
- package/out/address/keys/lookup.d.ts.map +1 -0
- package/out/address/keys/lookup.js +104 -0
- package/out/address/keys/lookup.js.map +1 -0
- package/out/address/keys/open.d.ts +10 -0
- package/out/address/keys/open.d.ts.map +1 -0
- package/out/address/keys/open.js +28 -0
- package/out/address/keys/open.js.map +1 -0
- package/out/address/keys/point-lookup.d.ts +25 -0
- package/out/address/keys/point-lookup.d.ts.map +1 -0
- package/out/address/keys/point-lookup.js +100 -0
- package/out/address/keys/point-lookup.js.map +1 -0
- package/out/address/keys/postcode.d.ts +9 -0
- package/out/address/keys/postcode.d.ts.map +1 -0
- package/out/address/keys/postcode.js +25 -0
- package/out/address/keys/postcode.js.map +1 -0
- package/out/address/keys/schema.d.ts +156 -0
- package/out/address/keys/schema.d.ts.map +1 -0
- package/out/address/keys/schema.js +119 -0
- package/out/address/keys/schema.js.map +1 -0
- package/out/address/number-forms.d.ts +19 -0
- package/out/address/number-forms.d.ts.map +1 -0
- package/out/address/number-forms.js +50 -0
- package/out/address/number-forms.js.map +1 -0
- package/out/address/point/interpolation.d.ts +24 -22
- package/out/address/point/interpolation.d.ts.map +1 -1
- package/out/address/point/interpolation.js +3 -31
- package/out/address/point/interpolation.js.map +1 -1
- package/out/address/point/schema.d.ts +0 -5
- package/out/address/point/schema.d.ts.map +1 -1
- package/out/address/point/schema.js +2 -5
- package/out/address/point/schema.js.map +1 -1
- package/out/address/point/spine-schema.d.ts +1 -4
- package/out/address/point/spine-schema.d.ts.map +1 -1
- package/out/address/point/spine-schema.js +3 -4
- package/out/address/point/spine-schema.js.map +1 -1
- package/out/address/point.d.ts +0 -3
- package/out/address/point.d.ts.map +1 -1
- package/out/address/point.js +12 -71
- package/out/address/point.js.map +1 -1
- package/out/address/record.d.ts +125 -0
- package/out/address/record.d.ts.map +1 -0
- package/out/address/record.js +49 -0
- package/out/address/record.js.map +1 -0
- package/out/address/stack.d.ts +14 -0
- package/out/address/stack.d.ts.map +1 -0
- package/out/address/stack.js +19 -0
- package/out/address/stack.js.map +1 -0
- package/out/address/subdivision-bounds.d.ts +32 -0
- package/out/address/subdivision-bounds.d.ts.map +1 -0
- package/out/address/subdivision-bounds.js +48 -0
- package/out/address/subdivision-bounds.js.map +1 -0
- package/out/address.d.ts +0 -5
- package/out/address.d.ts.map +1 -1
- package/out/address.js +2 -5
- package/out/address.js.map +1 -1
- package/out/ancestry/backfill.d.ts +11 -13
- package/out/ancestry/backfill.d.ts.map +1 -1
- package/out/ancestry/backfill.js +6 -44
- package/out/ancestry/backfill.js.map +1 -1
- package/out/ancestry.d.ts +0 -14
- package/out/ancestry.d.ts.map +1 -1
- package/out/ancestry.js +9 -10
- package/out/ancestry.js.map +1 -1
- package/out/build/candidate.d.ts +20 -22
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +16 -28
- package/out/build/candidate.js.map +1 -1
- package/out/build/population-corrections.d.ts +1 -4
- package/out/build/population-corrections.d.ts.map +1 -1
- package/out/build/population-corrections.js +2 -19
- package/out/build/population-corrections.js.map +1 -1
- package/out/build/slim.d.ts +0 -5
- package/out/build/slim.d.ts.map +1 -1
- package/out/build/slim.js +3 -6
- package/out/build/slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +9 -4
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +46 -19
- package/out/candidate/alias-bags.js.map +1 -1
- package/out/candidate/ancestors/schema.d.ts +60 -43
- package/out/candidate/ancestors/schema.d.ts.map +1 -1
- package/out/candidate/ancestors/schema.js +62 -43
- package/out/candidate/ancestors/schema.js.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 +2 -6
- package/out/candidate/ancestors/sidecar.js.map +1 -1
- package/out/candidate/bare-admin-names.d.ts +0 -6
- package/out/candidate/bare-admin-names.d.ts.map +1 -1
- package/out/candidate/bare-admin-names.js +2 -3
- package/out/candidate/bare-admin-names.js.map +1 -1
- package/out/candidate/country-display-names.d.ts +0 -5
- package/out/candidate/country-display-names.d.ts.map +1 -1
- package/out/candidate/country-display-names.js +2 -5
- package/out/candidate/country-display-names.js.map +1 -1
- package/out/candidate/extract-fold.d.ts +0 -5
- package/out/candidate/extract-fold.d.ts.map +1 -1
- package/out/candidate/extract-fold.js +2 -5
- package/out/candidate/extract-fold.js.map +1 -1
- package/out/candidate/fts.d.ts +2 -5
- package/out/candidate/fts.d.ts.map +1 -1
- package/out/candidate/fts.js +2 -7
- package/out/candidate/fts.js.map +1 -1
- package/out/candidate/importance.d.ts +3 -33
- package/out/candidate/importance.d.ts.map +1 -1
- package/out/candidate/importance.js +29 -24
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/key-fold.d.ts +55 -0
- package/out/candidate/key-fold.d.ts.map +1 -0
- package/out/candidate/key-fold.js +80 -0
- package/out/candidate/key-fold.js.map +1 -0
- package/out/candidate/lookup.d.ts +0 -5
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +24 -17
- package/out/candidate/lookup.js.map +1 -1
- package/out/candidate/name-roles.d.ts +0 -6
- package/out/candidate/name-roles.d.ts.map +1 -1
- package/out/candidate/name-roles.js +3 -4
- package/out/candidate/name-roles.js.map +1 -1
- package/out/candidate/nickname-namesakes.d.ts +32 -0
- package/out/candidate/nickname-namesakes.d.ts.map +1 -0
- package/out/candidate/nickname-namesakes.js +98 -0
- package/out/candidate/nickname-namesakes.js.map +1 -0
- package/out/candidate/own-name.d.ts +0 -18
- package/out/candidate/own-name.d.ts.map +1 -1
- package/out/candidate/own-name.js +11 -10
- package/out/candidate/own-name.js.map +1 -1
- package/out/candidate/place-attrs.d.ts +1 -4
- package/out/candidate/place-attrs.d.ts.map +1 -1
- package/out/candidate/place-attrs.js +2 -12
- package/out/candidate/place-attrs.js.map +1 -1
- package/out/candidate/schema.d.ts +0 -5
- package/out/candidate/schema.d.ts.map +1 -1
- package/out/candidate/schema.js +2 -5
- package/out/candidate/schema.js.map +1 -1
- package/out/candidate/scoring.d.ts +0 -5
- package/out/candidate/scoring.d.ts.map +1 -1
- package/out/candidate/scoring.js +3 -6
- package/out/candidate/scoring.js.map +1 -1
- package/out/capital-schema.d.ts +0 -14
- package/out/capital-schema.d.ts.map +1 -1
- package/out/capital-schema.js +10 -10
- package/out/capital-schema.js.map +1 -1
- package/out/capitals.d.ts +0 -16
- package/out/capitals.d.ts.map +1 -1
- package/out/capitals.js +14 -12
- package/out/capitals.js.map +1 -1
- package/out/convention/schema.d.ts +4 -7
- package/out/convention/schema.d.ts.map +1 -1
- package/out/convention/schema.js +2 -10
- package/out/convention/schema.js.map +1 -1
- package/out/convention.d.ts +0 -3
- package/out/convention.d.ts.map +1 -1
- package/out/convention.js +2 -8
- package/out/convention.js.map +1 -1
- package/out/coverage-manifest-schema.d.ts +1 -4
- package/out/coverage-manifest-schema.d.ts.map +1 -1
- package/out/coverage-manifest-schema.js +2 -3
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/env.d.ts +0 -8
- package/out/env.d.ts.map +1 -1
- package/out/env.js +6 -6
- package/out/env.js.map +1 -1
- package/out/exact-match.d.ts +2 -6
- package/out/exact-match.d.ts.map +1 -1
- package/out/exact-match.js +3 -9
- package/out/exact-match.js.map +1 -1
- package/out/extracts.d.ts +8 -9
- package/out/extracts.d.ts.map +1 -1
- package/out/extracts.js +9 -8
- package/out/extracts.js.map +1 -1
- package/out/fst/autocomplete.d.ts +1 -19
- package/out/fst/autocomplete.d.ts.map +1 -1
- package/out/fst/autocomplete.js +2 -18
- package/out/fst/autocomplete.js.map +1 -1
- package/out/fst/binary-matcher.d.ts +6 -8
- package/out/fst/binary-matcher.d.ts.map +1 -1
- package/out/fst/binary-matcher.js +12 -43
- package/out/fst/binary-matcher.js.map +1 -1
- package/out/fst/builder.d.ts +0 -12
- package/out/fst/builder.d.ts.map +1 -1
- package/out/fst/builder.js +23 -11
- package/out/fst/builder.js.map +1 -1
- package/out/fst/deserialize-web.d.ts +1 -12
- package/out/fst/deserialize-web.d.ts.map +1 -1
- package/out/fst/deserialize-web.js +8 -8
- package/out/fst/deserialize-web.js.map +1 -1
- package/out/fst/format.d.ts +66 -16
- package/out/fst/format.d.ts.map +1 -1
- package/out/fst/format.js +100 -16
- package/out/fst/format.js.map +1 -1
- package/out/fst/freshness.d.ts +0 -7
- package/out/fst/freshness.d.ts.map +1 -1
- package/out/fst/freshness.js +2 -4
- package/out/fst/freshness.js.map +1 -1
- package/out/fst/matcher.d.ts +3 -6
- package/out/fst/matcher.d.ts.map +1 -1
- package/out/fst/matcher.js +2 -9
- package/out/fst/matcher.js.map +1 -1
- package/out/fst/serialize.d.ts +0 -23
- package/out/fst/serialize.d.ts.map +1 -1
- package/out/fst/serialize.js +68 -60
- package/out/fst/serialize.js.map +1 -1
- package/out/fst/types.d.ts +1 -4
- package/out/fst/types.d.ts.map +1 -1
- package/out/fst/types.js +2 -6
- package/out/fst/types.js.map +1 -1
- package/out/fst.d.ts +0 -5
- package/out/fst.d.ts.map +1 -1
- package/out/fst.js +2 -5
- package/out/fst.js.map +1 -1
- package/out/fts/query.d.ts +0 -4
- package/out/fts/query.d.ts.map +1 -1
- package/out/fts/query.js +2 -7
- package/out/fts/query.js.map +1 -1
- package/out/fts.d.ts +0 -5
- package/out/fts.d.ts.map +1 -1
- package/out/fts.js +2 -5
- package/out/fts.js.map +1 -1
- package/out/geonames/aliases.d.ts +43 -5
- package/out/geonames/aliases.d.ts.map +1 -1
- package/out/geonames/aliases.js +108 -44
- package/out/geonames/aliases.js.map +1 -1
- package/out/geonames/postal.d.ts +1 -25
- package/out/geonames/postal.d.ts.map +1 -1
- package/out/geonames/postal.js +15 -14
- package/out/geonames/postal.js.map +1 -1
- package/out/geonames.d.ts +0 -5
- package/out/geonames.d.ts.map +1 -1
- package/out/geonames.js +2 -5
- package/out/geonames.js.map +1 -1
- package/out/importance-source.d.ts +90 -0
- package/out/importance-source.d.ts.map +1 -0
- package/out/importance-source.js +133 -0
- package/out/importance-source.js.map +1 -0
- package/out/index.d.ts +2 -5
- package/out/index.d.ts.map +1 -1
- package/out/index.js +4 -5
- package/out/index.js.map +1 -1
- package/out/interpolation.d.ts +0 -7
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +6 -6
- package/out/interpolation.js.map +1 -1
- package/out/landmark/rows.d.ts +2 -5
- package/out/landmark/rows.d.ts.map +1 -1
- package/out/landmark/rows.js +2 -8
- package/out/landmark/rows.js.map +1 -1
- package/out/landmark.d.ts +3 -6
- package/out/landmark.d.ts.map +1 -1
- package/out/landmark.js +2 -8
- package/out/landmark.js.map +1 -1
- package/out/lookup.d.ts +0 -7
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +7 -8
- package/out/lookup.js.map +1 -1
- package/out/name-score.d.ts +4 -6
- package/out/name-score.d.ts.map +1 -1
- package/out/name-score.js +6 -6
- package/out/name-score.js.map +1 -1
- package/out/nsul/lookup.d.ts +16 -15
- package/out/nsul/lookup.d.ts.map +1 -1
- package/out/nsul/lookup.js +2 -25
- package/out/nsul/lookup.js.map +1 -1
- package/out/nsul/schema.d.ts +1 -5
- package/out/nsul/schema.d.ts.map +1 -1
- package/out/nsul/schema.js +3 -8
- package/out/nsul/schema.js.map +1 -1
- package/out/nsul.d.ts +0 -5
- package/out/nsul.d.ts.map +1 -1
- package/out/nsul.js +2 -5
- package/out/nsul.js.map +1 -1
- package/out/paths.d.ts +1 -13
- package/out/paths.d.ts.map +1 -1
- package/out/paths.js +6 -7
- package/out/paths.js.map +1 -1
- package/out/place-importance-schema.d.ts +3 -8
- package/out/place-importance-schema.d.ts.map +1 -1
- package/out/place-importance-schema.js +3 -6
- package/out/place-importance-schema.js.map +1 -1
- package/out/poi/lookup.d.ts +0 -13
- package/out/poi/lookup.d.ts.map +1 -1
- package/out/poi/lookup.js +10 -10
- package/out/poi/lookup.js.map +1 -1
- package/out/poi/schema.d.ts +13 -10
- package/out/poi/schema.d.ts.map +1 -1
- package/out/poi/schema.js +2 -13
- package/out/poi/schema.js.map +1 -1
- package/out/poi.d.ts +0 -5
- package/out/poi.d.ts.map +1 -1
- package/out/poi.js +2 -5
- package/out/poi.js.map +1 -1
- package/out/polygon-schema.d.ts +7 -9
- package/out/polygon-schema.d.ts.map +1 -1
- package/out/polygon-schema.js +2 -12
- package/out/polygon-schema.js.map +1 -1
- package/out/postal/city/alias/lookup.d.ts +11 -13
- package/out/postal/city/alias/lookup.d.ts.map +1 -1
- package/out/postal/city/alias/lookup.js +13 -13
- package/out/postal/city/alias/lookup.js.map +1 -1
- package/out/postal/city/alias/schema.d.ts +9 -12
- package/out/postal/city/alias/schema.d.ts.map +1 -1
- package/out/postal/city/alias/schema.js +2 -17
- package/out/postal/city/alias/schema.js.map +1 -1
- package/out/postal/city/candidate-schema.d.ts +12 -12
- package/out/postal/city/candidate-schema.d.ts.map +1 -1
- package/out/postal/city/candidate-schema.js +14 -12
- package/out/postal/city/candidate-schema.js.map +1 -1
- package/out/postal.d.ts +0 -5
- package/out/postal.d.ts.map +1 -1
- package/out/postal.js +2 -5
- package/out/postal.js.map +1 -1
- package/out/postcode-point-lookup.d.ts +0 -5
- package/out/postcode-point-lookup.d.ts.map +1 -1
- package/out/postcode-point-lookup.js +2 -5
- package/out/postcode-point-lookup.js.map +1 -1
- package/out/primary-preference.d.ts +20 -6
- package/out/primary-preference.d.ts.map +1 -1
- package/out/primary-preference.js +33 -6
- package/out/primary-preference.js.map +1 -1
- package/out/proximity-rerank.d.ts +2 -26
- package/out/proximity-rerank.d.ts.map +1 -1
- package/out/proximity-rerank.js +22 -19
- package/out/proximity-rerank.js.map +1 -1
- package/out/ranking-weights.d.ts +5 -7
- package/out/ranking-weights.d.ts.map +1 -1
- package/out/ranking-weights.js +2 -9
- package/out/ranking-weights.js.map +1 -1
- package/out/region-keys.d.ts +0 -15
- package/out/region-keys.d.ts.map +1 -1
- package/out/region-keys.js +14 -14
- package/out/region-keys.js.map +1 -1
- package/out/reverse.d.ts +1 -24
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +14 -16
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +17 -6
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +2 -15
- package/out/schema.js.map +1 -1
- package/out/search-fetch.d.ts +0 -13
- package/out/search-fetch.d.ts.map +1 -1
- package/out/search-fetch.js +14 -11
- package/out/search-fetch.js.map +1 -1
- package/out/sqlite/convention-source.d.ts +0 -5
- package/out/sqlite/convention-source.d.ts.map +1 -1
- package/out/sqlite/convention-source.js +2 -5
- package/out/sqlite/convention-source.js.map +1 -1
- package/out/sqlite/utils.d.ts +1 -7
- package/out/sqlite/utils.d.ts.map +1 -1
- package/out/sqlite/utils.js +3 -4
- package/out/sqlite/utils.js.map +1 -1
- package/out/street/centroid/schema.d.ts +3 -6
- package/out/street/centroid/schema.d.ts.map +1 -1
- package/out/street/centroid/schema.js +2 -7
- package/out/street/centroid/schema.js.map +1 -1
- package/out/street/centroid.d.ts +0 -3
- package/out/street/centroid.d.ts.map +1 -1
- package/out/street/centroid.js +2 -6
- package/out/street/centroid.js.map +1 -1
- package/out/street/locale.d.ts +12 -0
- package/out/street/locale.d.ts.map +1 -0
- package/out/street/locale.js +54 -0
- package/out/street/locale.js.map +1 -0
- package/out/street/morphology/fst/builder.d.ts +1 -26
- package/out/street/morphology/fst/builder.d.ts.map +1 -1
- package/out/street/morphology/fst/builder.js +19 -18
- package/out/street/morphology/fst/builder.js.map +1 -1
- package/out/street/morphology/fst/loader.d.ts +0 -20
- package/out/street/morphology/fst/loader.d.ts.map +1 -1
- package/out/street/morphology/fst/loader.js +14 -13
- package/out/street/morphology/fst/loader.js.map +1 -1
- package/out/street/name-lookup.d.ts +11 -13
- package/out/street/name-lookup.d.ts.map +1 -1
- package/out/street/name-lookup.js +14 -14
- package/out/street/name-lookup.js.map +1 -1
- package/out/street/normalize.d.ts +29 -12
- package/out/street/normalize.d.ts.map +1 -1
- package/out/street/normalize.js +53 -13
- package/out/street/normalize.js.map +1 -1
- package/out/street/segment-schema.d.ts +11 -12
- package/out/street/segment-schema.d.ts.map +1 -1
- package/out/street/segment-schema.js +13 -12
- package/out/street/segment-schema.js.map +1 -1
- package/out/street/table.d.ts +154 -0
- package/out/street/table.d.ts.map +1 -0
- package/out/street/table.js +122 -0
- package/out/street/table.js.map +1 -0
- package/out/street.d.ts +1 -5
- package/out/street.d.ts.map +1 -1
- package/out/street.js +3 -5
- package/out/street.js.map +1 -1
- package/out/types.d.ts +1 -6
- package/out/types.d.ts.map +1 -1
- package/out/types.js +2 -5
- package/out/types.js.map +1 -1
- package/out/unified-schema.d.ts +18 -7
- package/out/unified-schema.d.ts.map +1 -1
- package/out/unified-schema.js +14 -10
- package/out/unified-schema.js.map +1 -1
- package/out/uprn/existence.d.ts +7 -10
- package/out/uprn/existence.d.ts.map +1 -1
- package/out/uprn/existence.js +9 -10
- package/out/uprn/existence.js.map +1 -1
- package/out/uprn/lookup.d.ts +1 -8
- package/out/uprn/lookup.d.ts.map +1 -1
- package/out/uprn/lookup.js +6 -8
- package/out/uprn/lookup.js.map +1 -1
- package/out/uprn/schema.d.ts +2 -5
- package/out/uprn/schema.d.ts.map +1 -1
- package/out/uprn/schema.js +2 -7
- package/out/uprn/schema.js.map +1 -1
- package/out/uprn.d.ts +0 -5
- package/out/uprn.d.ts.map +1 -1
- package/out/uprn.js +2 -5
- package/out/uprn.js.map +1 -1
- package/out/weights-overlay-linker.d.ts +3 -8
- package/out/weights-overlay-linker.d.ts.map +1 -1
- package/out/weights-overlay-linker.js +5 -8
- package/out/weights-overlay-linker.js.map +1 -1
- package/package.json +12 -12
- package/lib/currency-backfill.ts +0 -289
- package/out/currency-backfill.d.ts +0 -68
- package/out/currency-backfill.d.ts.map +0 -1
- package/out/currency-backfill.js +0 -169
- package/out/currency-backfill.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
5
|
* @file Pass 2 of the candidate build: explode `place_search.alt_names` into distinct alias rows.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ import type { PlaceAttrs, StageRow } from "#candidate/place-attrs"
|
|
|
12
12
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
13
13
|
import { ALIAS_SEPARATOR } from "#fts"
|
|
14
14
|
import type { WOFDatabase } from "#schema"
|
|
15
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
15
|
+
import { type NameKey, normalizeLocalityForKey, withoutApostropheLikeMarks } from "#street/normalize"
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The official name of every current region, keyed `${country id}\0${name key}` →
|
|
@@ -52,9 +52,16 @@ function officialNameHoldersByRegion(
|
|
|
52
52
|
* Pass 2: explode each place's `place_search.alt_names` bag into distinct-key alias rows
|
|
53
53
|
* (`is_primary = 0`), and count each place's distinct staged keys with the primary included.
|
|
54
54
|
*
|
|
55
|
-
* With `regionPlacetypeID` and `ccID` given, a region's alias that
|
|
55
|
+
* With `regionPlacetypeID` and `ccID` given, a region's alias that's another same-country region's
|
|
56
56
|
* official name is refused and counted rather than staged (see {@link officialNameHoldersByRegion}).
|
|
57
57
|
* Without them the pass stages every alias.
|
|
58
|
+
*
|
|
59
|
+
* Each key holding an apostrophe-like mark, the primary's included, also stages
|
|
60
|
+
* its mark-free form ({@link withoutApostropheLikeMarks}).
|
|
61
|
+
* The count excludes those forms.
|
|
62
|
+
*
|
|
63
|
+
* The gloss detector compares the count with its threshold, and a mark-free form
|
|
64
|
+
* spells a name the count already includes.
|
|
58
65
|
*/
|
|
59
66
|
export function explodeAliasBags(
|
|
60
67
|
src: DatabaseClient<WOFDatabase>,
|
|
@@ -72,9 +79,16 @@ export function explodeAliasBags(
|
|
|
72
79
|
*/
|
|
73
80
|
bareName?: (countryID: number, alias: string) => string | null
|
|
74
81
|
} = {}
|
|
75
|
-
): {
|
|
82
|
+
): {
|
|
83
|
+
nAlias: number
|
|
84
|
+
nBare: number
|
|
85
|
+
nMarkFree: number
|
|
86
|
+
keyCounts: Map<number, number>
|
|
87
|
+
regionOfficialRefused: number
|
|
88
|
+
} {
|
|
76
89
|
let nAlias = 0
|
|
77
90
|
let nBare = 0
|
|
91
|
+
let nMarkFree = 0
|
|
78
92
|
let regionOfficialRefused = 0
|
|
79
93
|
const keyCounts = new Map<number, number>()
|
|
80
94
|
|
|
@@ -90,14 +104,35 @@ export function explodeAliasBags(
|
|
|
90
104
|
const a = attrs.get(id)
|
|
91
105
|
const alt = r.alt_names as string | null
|
|
92
106
|
|
|
93
|
-
if (!a
|
|
107
|
+
if (!a) continue
|
|
94
108
|
const seen = new Set<string>([a.pkey])
|
|
109
|
+
const markFree = new Set<string>()
|
|
95
110
|
const isRegion = a.ptid === opts.regionPlacetypeID
|
|
96
111
|
|
|
112
|
+
const refused = (k: string): boolean => {
|
|
113
|
+
if (!isRegion) return false
|
|
114
|
+
const holder = official.get(`${a.cid}\0${k}`)
|
|
115
|
+
|
|
116
|
+
return typeof holder === "number" && holder !== id
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Returns 1 when it staged a row, so the caller adds the result to the count.
|
|
120
|
+
const stageMarkFree = (k: NameKey): number => {
|
|
121
|
+
const free = withoutApostropheLikeMarks(k)
|
|
122
|
+
|
|
123
|
+
if (!free || free === k || seen.has(free) || markFree.has(free) || refused(free)) return 0
|
|
124
|
+
markFree.add(free)
|
|
125
|
+
stageRow(free, a, id, 0)
|
|
126
|
+
|
|
127
|
+
return 1
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
nMarkFree += stageMarkFree(a.pkey as NameKey)
|
|
131
|
+
|
|
97
132
|
// The writer space-pads each separator and appends a trailing one, so every piece
|
|
98
133
|
// includes surrounding whitespace and the last one is empty.
|
|
99
134
|
// `normalizeLocalityForKey` folds both away.
|
|
100
|
-
for (const piece of alt
|
|
135
|
+
for (const piece of alt?.split(ALIAS_SEPARATOR) ?? []) {
|
|
101
136
|
const bare = opts.bareName?.(a.cid, piece.trim())
|
|
102
137
|
const keys = [normalizeLocalityForKey(piece), bare ? normalizeLocalityForKey(bare) : ""]
|
|
103
138
|
|
|
@@ -105,30 +140,35 @@ export function explodeAliasBags(
|
|
|
105
140
|
if (!k || seen.has(k)) continue
|
|
106
141
|
seen.add(k)
|
|
107
142
|
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (typeof holder === "number" && holder !== id) {
|
|
112
|
-
regionOfficialRefused++
|
|
143
|
+
if (refused(k)) {
|
|
144
|
+
regionOfficialRefused++
|
|
113
145
|
|
|
114
|
-
|
|
115
|
-
}
|
|
146
|
+
continue
|
|
116
147
|
}
|
|
117
148
|
|
|
118
|
-
|
|
149
|
+
// A mark-free form staged earlier now arrives as a name of its own, so it counts as one.
|
|
150
|
+
if (markFree.delete(k)) {
|
|
151
|
+
nMarkFree--
|
|
152
|
+
} else {
|
|
153
|
+
stageRow(k, a, id, 0)
|
|
154
|
+
}
|
|
119
155
|
|
|
120
156
|
if (position) {
|
|
121
157
|
nBare++
|
|
122
158
|
} else {
|
|
123
159
|
nAlias++
|
|
124
160
|
}
|
|
161
|
+
|
|
162
|
+
nMarkFree += stageMarkFree(k as NameKey)
|
|
125
163
|
}
|
|
126
164
|
}
|
|
127
165
|
|
|
128
|
-
|
|
166
|
+
if (alt) {
|
|
167
|
+
keyCounts.set(id, seen.size)
|
|
168
|
+
}
|
|
129
169
|
}
|
|
130
170
|
|
|
131
171
|
out.exec("COMMIT")
|
|
132
172
|
|
|
133
|
-
return { nAlias, nBare, keyCounts, regionOfficialRefused }
|
|
173
|
+
return { nAlias, nBare, nMarkFree, keyCounts, regionOfficialRefused }
|
|
134
174
|
}
|
|
@@ -1,53 +1,73 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
* Typed schema for the candidate gazetteer's ancestors sidecar
|
|
6
|
+
* (`candidate_ancestor` + `candidate_interval`) — the containment lineage the candidate
|
|
7
|
+
* table itself cannot answer, built into the same `candidate.db` by `build-candidate.ts`
|
|
8
|
+
* and read by {@link WOFCandidateTableLookup.ancestors}.
|
|
5
9
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* into the same `candidate.db` by `build-candidate.ts` and read by
|
|
9
|
-
* {@link WOFCandidateTableLookup.ancestors}.
|
|
10
|
+
* The sidecar stores denormalized closure rows.
|
|
11
|
+
* Each row represents one (place, ancestor) edge.
|
|
10
12
|
*
|
|
11
|
-
* The
|
|
12
|
-
*
|
|
13
|
+
* The row includes the parent's placetype, display name and folded key.
|
|
14
|
+
* The two consumers determine this layout:
|
|
13
15
|
*
|
|
14
16
|
* 1. The admin-coherence check needs the winner's chain as (placetype, name) pairs in one probe.
|
|
15
|
-
* A fixed-slot `[id.8]` chain returns ids.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
17
|
+
* A fixed-slot `[id.8]` chain returns ids.
|
|
18
|
+
* Each id would then need a name lookup, but the artifact has no per-id table.
|
|
19
|
+
* That design requires up to 8 indirections.
|
|
20
|
+
* The closure row requires none.
|
|
21
|
+
* 2. The account layer needs every candidate under a `name_key` enumerable with its chain
|
|
22
|
+
* from one artifact probe ("present-but-outranked, discriminated by containment").
|
|
23
|
+
* That's the candidate probe (contiguous) followed by one `spr_id`-clustered
|
|
24
|
+
* closure probe per candidate — each a handful of adjacent pages.
|
|
25
|
+
*
|
|
26
|
+
* The artifact is read over HTTP byte ranges.
|
|
27
|
+
* A join to a dimension table scatters page fetches.
|
|
28
|
+
*
|
|
29
|
+
* A `without rowid` B-tree clustered on `(spr_id, depth)` keeps a whole chain in 1–2 pages.
|
|
30
|
+
* The builder repeats parent strings to avoid joins during reads.
|
|
31
|
+
*
|
|
32
|
+
* `depth` is 1 for the nearest ancestor (deepest containment tier) and increases outward to the country.
|
|
33
|
+
* This matches the nearest-first order that `ancestry.ts` serves for the FTS backend.
|
|
34
|
+
*
|
|
35
|
+
* Both backends' `ancestors()` results therefore use the same order.
|
|
36
|
+
* The order within a place is deterministic: containment depth descending (`placetypeDepth`),
|
|
37
|
+
* then ancestor id ascending, capped at {@link MAX_ANCESTOR_DEPTH}.
|
|
38
|
+
*
|
|
39
|
+
* `parent_name_key` is the shared {@link normalizeLocalityForKey} fold.
|
|
40
|
+
* It's the same fold `candidate.name_key` is built with, so a chain entry
|
|
41
|
+
* and a candidate key compare under one normalizer.
|
|
42
|
+
*
|
|
43
|
+
* `candidate_interval` stores pre/post-order labels over the canonical-parent forest.
|
|
44
|
+
* The builder assigns them during construction.
|
|
45
|
+
*
|
|
46
|
+
* The predicate `a.pre <= d.pre and d.post <= a.post` tests whether `a` contains `d` in O(1) time.
|
|
47
|
+
* It needs no chain scan or tier information.
|
|
48
|
+
*
|
|
49
|
+
* Descendants of `a` occupy the contiguous range `pre between a.pre and a.post`.
|
|
50
|
+
* Interval labels add relabeling work to updates.
|
|
51
|
+
*
|
|
52
|
+
* This database is sealed and read-only, so the builder can regenerate all labels together.
|
|
53
|
+
*
|
|
54
|
+
* WOF places can have multiple parents because boundaries can be ambiguous
|
|
55
|
+
* or participate in multiple hierarchies.
|
|
56
|
+
* `candidate_ancestor` stores every parent.
|
|
57
|
+
*
|
|
58
|
+
* Its closure rows hold the complete containment record.
|
|
59
|
+
* One interval pair encodes only a tree.
|
|
60
|
+
*
|
|
61
|
+
* The interval forest therefore links each place to one canonical parent:
|
|
62
|
+
* the depth-1 edge with the finest containment tier and lowest ancestor id.
|
|
63
|
+
* This follows the same MIN-based stability convention as the candidate table's `region_id` stamp.
|
|
64
|
+
*
|
|
65
|
+
* A containment query about another hierarchy must consult the closure rows.
|
|
66
|
+
* The interval result answers only whether a place is contained along the canonical hierarchy.
|
|
47
67
|
*
|
|
48
68
|
* absence semantics (meaning-of-zero): a place with no `candidate_interval` row has no recorded
|
|
49
|
-
* ancestry in the source (extract-fed postcodes and localities, isolated places, cycle-skipped
|
|
50
|
-
*
|
|
69
|
+
* ancestry in the source (extract-fed postcodes and localities, isolated places, cycle-skipped rows).
|
|
70
|
+
* Absence is unverifiable, never a containment verdict.
|
|
51
71
|
*/
|
|
52
72
|
|
|
53
73
|
import { sql, type Kysely } from "kysely"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
5
|
* @file Pass 3b of the candidate build — the containment sidecar (closure rows + interval labels).
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
5
|
* @file A candidate build pass that keys each admin place under its bare name as well as its full one.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
6
3
|
|
|
7
4
|
import { enumerateCountryDisplayNames } from "@mailwoman/codex/country"
|
|
8
5
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
6
3
|
|
|
7
4
|
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
8
5
|
import { tableExists } from "@mailwoman/sqlite/introspection"
|
package/lib/candidate/fts.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* FTS5-trigram fuzzy index over the candidate gazetteer's normalized `name_key`; raw SQL on purpose, since Kysely cannot express `create virtual table … using fts5`.
|
|
5
|
+
* FTS5-trigram fuzzy index over the candidate gazetteer's normalized `name_key`;
|
|
6
|
+
* raw SQL on purpose, since Kysely cannot express `create virtual table … using fts5`.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
@@ -1,32 +1,38 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
* The score side of the candidate build: load a WOF admin database's `place_importance`
|
|
6
|
+
* into a lookup the candidate builder probes per place, so every candidate row can
|
|
7
|
+
* include the toponym-fame prior a bare city name is decided on.
|
|
8
|
+
*
|
|
9
|
+
* The join key is `(name_key, country, placetype)`, the same {@link normalizeLocalityForKey}
|
|
10
|
+
* the candidate build uses for its probe key, so the two sides fold identically.
|
|
11
|
+
* The score source is the importance build the candidate build matched to its
|
|
12
|
+
* admin database by md5 (`importance-source.ts`).
|
|
5
13
|
*
|
|
6
|
-
* The
|
|
7
|
-
*
|
|
8
|
-
* toponym-fame prior a bare city name is decided on.
|
|
14
|
+
* The join stays on the name key rather than the id, the join every candidate build has used,
|
|
15
|
+
* so matching the two files changes which scores are read and leaves the join unchanged.
|
|
9
16
|
*
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
* here, because the score source (`admin-global-priority-importance.db`) and the candidate build's
|
|
13
|
-
* admin source are different snapshots whose ids disagree. An id join silently drops rows and
|
|
14
|
-
* leaves the ranking inert on the queries the prior exists for.
|
|
17
|
+
* The key by itself isn't enough.
|
|
18
|
+
* `(warwick, US, locality)` covers eleven different places.
|
|
15
19
|
*
|
|
16
|
-
* The key by itself is not enough. `(warwick, US, locality)` covers eleven different places.
|
|
17
20
|
* The group's maximum would give every Warwick in America the fame of Warwick, Rhode Island.
|
|
18
21
|
* The join picks the nearest centroid when it falls within {@link IMPORTANCE_JOIN_RADIUS_KM}.
|
|
19
|
-
* Two artifacts describing the same settlement put its centroid
|
|
20
|
-
* in almost the same place. Two towns with the same name in one country do not.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* Two artifacts describing the same settlement put its centroid in almost the same place.
|
|
24
|
+
* Two towns with the same name in one country do not.
|
|
25
|
+
*
|
|
26
|
+
* `place_importance.importance` lands in the column verbatim, the pre-split conflation that's
|
|
27
|
+
* encyclopedia-derived where the concordance matched and a population-derived proxy everywhere else.
|
|
28
|
+
* See {@link CandidateTable.importance} for why the split `encyclopedic`
|
|
29
|
+
* channel isn't what's written here.
|
|
30
|
+
*
|
|
31
|
+
* A place with no match gets NULL.
|
|
32
|
+
* NULL means the place's fame is unmeasured.
|
|
26
33
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* population assigned it.
|
|
34
|
+
* The consumer (`resolver/toponym-prior.ts`) leaves an unmeasured candidate
|
|
35
|
+
* at the position population assigned it.
|
|
30
36
|
*/
|
|
31
37
|
|
|
32
38
|
import { haversine } from "@mailwoman/spatial/geometries/point/distance"
|
|
@@ -43,7 +49,7 @@ import { normalizeLocalityForKey } from "#street/normalize"
|
|
|
43
49
|
* The nearest-centroid distances separate into a mode where the two snapshots agree
|
|
44
50
|
* and a background rate of two different towns wearing one name in one country.
|
|
45
51
|
*
|
|
46
|
-
* The background rate
|
|
52
|
+
* The background rate doesn't decay with distance.
|
|
47
53
|
* Ten kilometers separates the two populations.
|
|
48
54
|
*
|
|
49
55
|
* That distance matches the join's purpose.
|
|
@@ -111,7 +117,7 @@ export class ImportanceIndex {
|
|
|
111
117
|
* Compare this number across rebuilds.
|
|
112
118
|
* A jump means the score source and the admin source have drifted apart
|
|
113
119
|
* and the join is being asked to guess.
|
|
114
|
-
* It
|
|
120
|
+
* It doesn't mean the radius is too tight.
|
|
115
121
|
*/
|
|
116
122
|
refused = 0
|
|
117
123
|
|
|
@@ -122,7 +128,7 @@ export class ImportanceIndex {
|
|
|
122
128
|
|
|
123
129
|
/**
|
|
124
130
|
* The importance of the scored place nearest `(lat, lon)` sharing `name`'s folded key, `country`
|
|
125
|
-
* and `placetype`, or null when there
|
|
131
|
+
* and `placetype`, or null when there's no such place within {@link IMPORTANCE_JOIN_RADIUS_KM}.
|
|
126
132
|
*
|
|
127
133
|
* Null is unmeasured.
|
|
128
134
|
* Keep the value null.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file Extra folds a `candidate.db` applies to every `name_key`, recorded in the artifact so its reader
|
|
6
|
+
* folds each query key the same way.
|
|
7
|
+
*
|
|
8
|
+
* A fold changes which keys exist, so the build and the reader must agree on it. The build applies it
|
|
9
|
+
* as a post-pass over the materialized `candidate` table, and the reader reads the recorded folds once.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
13
|
+
|
|
14
|
+
import type { CandidateDatabase } from "#candidate/schema"
|
|
15
|
+
import { hasTable } from "#sqlite-utils"
|
|
16
|
+
import { type NameKey, withArabicLetterVariantsFolded } from "#street/normalize"
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The table that lists the folds applied to the artifact's `name_key` column, one row per fold.
|
|
20
|
+
* An artifact without it applies none.
|
|
21
|
+
*/
|
|
22
|
+
export const CANDIDATE_KEY_FOLD_TABLE = "candidate_key_fold"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The folds a candidate build can apply on top of `normalizeLocalityForKey`.
|
|
26
|
+
*/
|
|
27
|
+
export const CandidateKeyFold = {
|
|
28
|
+
/**
|
|
29
|
+
* {@link withArabicLetterVariantsFolded}: hamza, madda and vowel marks dropped,
|
|
30
|
+
* `ى` written `ي`, `ة` written `ه`.
|
|
31
|
+
*/
|
|
32
|
+
ArabicLetterVariants: "arabic-letter-variants",
|
|
33
|
+
} as const
|
|
34
|
+
|
|
35
|
+
export type CandidateKeyFold = (typeof CandidateKeyFold)[keyof typeof CandidateKeyFold]
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The key function of each fold, and the GLOB that selects the keys it can change.
|
|
39
|
+
*/
|
|
40
|
+
const FOLDS: Readonly<Record<CandidateKeyFold, { fold: (key: NameKey) => NameKey; glob: string }>> = {
|
|
41
|
+
[CandidateKeyFold.ArabicLetterVariants]: { fold: withArabicLetterVariantsFolded, glob: "*[-ۿ]*" },
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The counts {@link applyCandidateKeyFold} reports.
|
|
46
|
+
*/
|
|
47
|
+
export interface CandidateKeyFoldResult {
|
|
48
|
+
/**
|
|
49
|
+
* Rows whose key the fold changed.
|
|
50
|
+
*/
|
|
51
|
+
rekeyed: number
|
|
52
|
+
/**
|
|
53
|
+
* Rekeyed rows dropped because the folded key already held the same place under the same scope.
|
|
54
|
+
*/
|
|
55
|
+
merged: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Rewrites every `candidate.name_key` the fold changes and records the fold
|
|
60
|
+
* in {@link CANDIDATE_KEY_FOLD_TABLE}.
|
|
61
|
+
*
|
|
62
|
+
* A row whose folded key already exists for the same place, scope, placetype and rank is merged into it.
|
|
63
|
+
* It runs on a writable copy or inside a build, never on a published artifact.
|
|
64
|
+
*/
|
|
65
|
+
export async function applyCandidateKeyFold(
|
|
66
|
+
db: DatabaseClient<CandidateDatabase>,
|
|
67
|
+
foldName: CandidateKeyFold
|
|
68
|
+
): Promise<CandidateKeyFoldResult> {
|
|
69
|
+
const { fold, glob } = FOLDS[foldName]
|
|
70
|
+
const sqlName = `mw_key_fold_${foldName.replaceAll("-", "_")}`
|
|
71
|
+
|
|
72
|
+
db.function(sqlName, { deterministic: true }, (key) => fold(String(key) as NameKey))
|
|
73
|
+
|
|
74
|
+
const changed = `name_key GLOB '${glob}' AND ${sqlName}(name_key) <> name_key`
|
|
75
|
+
const { n: rekeyed } = db.prepare(`SELECT count(*) AS n FROM candidate WHERE ${changed}`).get() as { n: number }
|
|
76
|
+
|
|
77
|
+
db.exec("BEGIN")
|
|
78
|
+
|
|
79
|
+
const inserted = db
|
|
80
|
+
.prepare(
|
|
81
|
+
"INSERT OR IGNORE INTO candidate SELECT " +
|
|
82
|
+
`${sqlName}(name_key), country_id, region_id, placetype_id, neg_rank, spr_id, name, latitude, longitude, ` +
|
|
83
|
+
"min_lat, min_lon, max_lat, max_lon, population, is_primary, importance, name_role " +
|
|
84
|
+
`FROM candidate WHERE ${changed}`
|
|
85
|
+
)
|
|
86
|
+
.run()
|
|
87
|
+
|
|
88
|
+
db.prepare(`DELETE FROM candidate WHERE ${changed}`).run()
|
|
89
|
+
|
|
90
|
+
await db.schema
|
|
91
|
+
.createTable(CANDIDATE_KEY_FOLD_TABLE)
|
|
92
|
+
.ifNotExists()
|
|
93
|
+
.addColumn("fold", "text", (c) => c.primaryKey())
|
|
94
|
+
.execute()
|
|
95
|
+
|
|
96
|
+
db.prepare(`INSERT OR IGNORE INTO ${CANDIDATE_KEY_FOLD_TABLE} (fold) VALUES (?)`).run(foldName)
|
|
97
|
+
db.exec("COMMIT")
|
|
98
|
+
|
|
99
|
+
return { rekeyed, merged: rekeyed - Number(inserted.changes) }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The query-key function an artifact's recorded folds call for: identity when it records none.
|
|
104
|
+
*
|
|
105
|
+
* A fold name the reader doesn't know raises, because a key that misses that
|
|
106
|
+
* fold would miss every row the fold rewrote.
|
|
107
|
+
*/
|
|
108
|
+
export function candidateQueryKeyFold(db: DatabaseClient<CandidateDatabase>): (key: NameKey) => NameKey {
|
|
109
|
+
if (!hasTable(db, CANDIDATE_KEY_FOLD_TABLE)) return (key) => key
|
|
110
|
+
|
|
111
|
+
const names = (
|
|
112
|
+
db.prepare(`SELECT fold FROM ${CANDIDATE_KEY_FOLD_TABLE} ORDER BY fold`).all() as { fold: string }[]
|
|
113
|
+
).map((row) => row.fold)
|
|
114
|
+
|
|
115
|
+
const folds = names.map((name) => {
|
|
116
|
+
const known = FOLDS[name as CandidateKeyFold]
|
|
117
|
+
|
|
118
|
+
if (!known) throw new Error(`candidate.db records the key fold ${name}, which this reader doesn't implement`)
|
|
119
|
+
|
|
120
|
+
return known.fold
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
return (key) => {
|
|
124
|
+
let folded = key
|
|
125
|
+
|
|
126
|
+
for (const fold of folds) {
|
|
127
|
+
folded = fold(folded)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return folded
|
|
131
|
+
}
|
|
132
|
+
}
|
package/lib/candidate/lookup.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
6
3
|
|
|
7
4
|
import { expandPlacetypeFilter } from "@mailwoman/codex/placetype-map"
|
|
8
5
|
import type { VariantAliasExemption } from "@mailwoman/core/geocode"
|
|
@@ -22,10 +19,11 @@ import {
|
|
|
22
19
|
type IntervalLabel,
|
|
23
20
|
} from "#candidate/ancestors/schema"
|
|
24
21
|
import { CANDIDATE_FTS_TABLE } from "#candidate/fts"
|
|
22
|
+
import { candidateQueryKeyFold } from "#candidate/key-fold"
|
|
25
23
|
import type { CandidateDatabase, CandidateTable, CountryCodeTable, PlacetypeCodeTable } from "#candidate/schema"
|
|
26
24
|
import { readGazetteerCoverageManifest } from "#coverage-manifest-schema"
|
|
27
25
|
import { POSTAL_CITY_CANDIDATE_TABLE, type PostalCityCandidateTable } from "#postal/city/candidate-schema"
|
|
28
|
-
import { rankByPrimaryPreference, type RankedRow, RERANK_FETCH } from "#primary-preference"
|
|
26
|
+
import { rankByPrimaryPreference, type RankedRow, regionAliasMargin, RERANK_FETCH } from "#primary-preference"
|
|
29
27
|
import { applyProximityRerank } from "#proximity-rerank"
|
|
30
28
|
import { REGION_CLASS_PLACETYPES, regionQualifierProbeKeys } from "#region-keys"
|
|
31
29
|
import { hasColumn, hasTable } from "#sqlite-utils"
|
|
@@ -136,6 +134,10 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
136
134
|
readonly #intervalCache = new Map<number, IntervalLabel | null>()
|
|
137
135
|
|
|
138
136
|
readonly #qualifierProbe: ReturnType<DatabaseClient["prepare"]> | undefined
|
|
137
|
+
/**
|
|
138
|
+
* The folds the artifact recorded for its `name_key` column, applied to every query key.
|
|
139
|
+
*/
|
|
140
|
+
readonly #queryKeyFold: (key: NameKey) => NameKey
|
|
139
141
|
/**
|
|
140
142
|
* Ancestor lineage accessor, nearest-first, present only when the artifact supports it.
|
|
141
143
|
*/
|
|
@@ -144,6 +146,8 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
144
146
|
constructor(opts: WOFCandidateTableLookupOpts) {
|
|
145
147
|
super(opts)
|
|
146
148
|
|
|
149
|
+
this.#queryKeyFold = candidateQueryKeyFold(this.database)
|
|
150
|
+
|
|
147
151
|
for (const r of allRows<CountryCodeTable>(this.database.prepare("SELECT id, code FROM country_codes"))) {
|
|
148
152
|
const code = String(r.code).toUpperCase()
|
|
149
153
|
this.#countryToID.set(code, Number(r.id))
|
|
@@ -249,7 +253,7 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
249
253
|
for (const key of regionQualifierProbeKeys(qualifier, country)) {
|
|
250
254
|
if (!key) continue
|
|
251
255
|
|
|
252
|
-
for (const row of allRows<{ spr_id: number }>(this.#qualifierProbe, key)) {
|
|
256
|
+
for (const row of allRows<{ spr_id: number }>(this.#qualifierProbe, this.#queryKeyFold(key as NameKey))) {
|
|
253
257
|
ids.add(Number(row.spr_id))
|
|
254
258
|
}
|
|
255
259
|
}
|
|
@@ -428,7 +432,8 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
428
432
|
text = text.replaceAll(/\s+/g, "")
|
|
429
433
|
}
|
|
430
434
|
|
|
431
|
-
const nameKey = normalizeLocalityForKey(text)
|
|
435
|
+
const nameKey = this.#queryKeyFold(normalizeLocalityForKey(text))
|
|
436
|
+
const strippedNameKey = this.#queryKeyFold(normalizeLocalityForKey(stripLocalityQualifier(text)))
|
|
432
437
|
|
|
433
438
|
if (!nameKey) return []
|
|
434
439
|
|
|
@@ -538,19 +543,19 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
538
543
|
|
|
539
544
|
const fetched = allRows<CandidateRow>(this.database.prepare(sql), ...params, Math.max(limit, RERANK_FETCH))
|
|
540
545
|
|
|
541
|
-
|
|
546
|
+
// Inside a stated region, an alias yields to a different place whose primary name equals
|
|
547
|
+
// the query, including an own-name variant the exemption spares from the worldwide penalty.
|
|
548
|
+
return regionID === null
|
|
549
|
+
? rankByPrimaryPreference(fetched, limit, undefined, this.#idToPlacetype, this.#variantAliasExemption)
|
|
550
|
+
: rankByPrimaryPreference(fetched, limit, regionAliasMargin, this.#idToPlacetype)
|
|
542
551
|
}
|
|
543
552
|
|
|
544
553
|
const cascade = (regionID: number | null): Array<RankedRow<CandidateRow>> => {
|
|
545
554
|
let rows = probe(nameKey, regionID)
|
|
546
555
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
if (strippedKey && strippedKey !== nameKey) {
|
|
551
|
-
// Stripped probes only accept primary rows to avoid alias-scrape matches.
|
|
552
|
-
rows = probe(strippedKey, regionID).filter((r) => r.is_primary === 1)
|
|
553
|
-
}
|
|
556
|
+
// Stripped probes only accept primary rows to avoid alias-scrape matches.
|
|
557
|
+
if (!rows.length && strippedNameKey && strippedNameKey !== nameKey) {
|
|
558
|
+
rows = probe(strippedNameKey, regionID).filter((r) => r.is_primary === 1)
|
|
554
559
|
}
|
|
555
560
|
|
|
556
561
|
// Typo-tolerant fallback for true name misses only, skipping postcodes.
|
|
@@ -576,7 +581,9 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
576
581
|
const hits = allRows<{ name_key: string }>(this.#ftsProbe, match, FUZZY_FETCH)
|
|
577
582
|
|
|
578
583
|
const ranked = hits
|
|
579
|
-
|
|
584
|
+
// An index built before the artifact's key folds holds unfolded keys, so each hit is folded too.
|
|
585
|
+
.map((h) => this.#queryKeyFold(String(h.name_key) as NameKey))
|
|
586
|
+
.map((nk) => ({ nk, s: wordFuzzySimilarity(nameKey, nk) }))
|
|
580
587
|
.filter((h) => h.s >= WORD_FUZZY_MIN && (hasCountryEvidence || h.nk[0] === nameKey[0]))
|
|
581
588
|
// oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array. toSorted would double-allocate on a hot path
|
|
582
589
|
.sort((a, b) => b.s - a.s)
|
|
@@ -641,7 +648,7 @@ export class WOFCandidateTableLookup extends SQLiteLookup<CandidateDatabase> imp
|
|
|
641
648
|
// Admin-containment re-rank runs last.
|
|
642
649
|
const containmentOptions: ContainmentOptions = {
|
|
643
650
|
nameKey,
|
|
644
|
-
strippedKey:
|
|
651
|
+
strippedKey: strippedNameKey,
|
|
645
652
|
shapeFilters,
|
|
646
653
|
shapeParams,
|
|
647
654
|
limit,
|