@mailwoman/resolver-wof-sqlite 11.0.0 → 11.1.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 +1 -1
- 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 +5 -4
- package/lib/ancestry.ts +10 -10
- package/lib/build/candidate.ts +2 -46
- package/lib/build/population-corrections.ts +4 -4
- package/lib/build/slim.ts +3 -6
- package/lib/candidate/alias-bags.ts +4 -4
- 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 +29 -24
- package/lib/candidate/lookup.ts +2 -5
- package/lib/candidate/name-roles.ts +4 -4
- 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 +10 -9
- package/lib/fst/builder.ts +32 -11
- package/lib/fst/deserialize-web.ts +9 -8
- package/lib/fst/format.ts +9 -7
- package/lib/fst/freshness.ts +3 -4
- package/lib/fst/matcher.ts +6 -6
- package/lib/fst/serialize.ts +5 -9
- 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 +193 -43
- package/lib/geonames/postal.ts +17 -15
- package/lib/geonames.ts +2 -5
- 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 +2 -5
- 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 +20 -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 +0 -7
- package/out/ancestry/backfill.d.ts.map +1 -1
- package/out/ancestry/backfill.js +4 -4
- 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 +0 -22
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +2 -26
- 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 +1 -4
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +3 -7
- 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 +28 -24
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/lookup.d.ts +0 -5
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +2 -5
- 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/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 +3 -13
- 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 +6 -7
- package/out/fst/format.d.ts.map +1 -1
- package/out/fst/format.js +3 -10
- 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 +4 -8
- 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 +109 -41
- 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/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 +0 -5
- package/out/primary-preference.d.ts.map +1 -1
- package/out/primary-preference.js +2 -5
- 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 +10 -12
- package/out/street/normalize.d.ts.map +1 -1
- package/out/street/normalize.js +15 -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
package/lib/fst/freshness.ts
CHANGED
|
@@ -1,8 +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
|
-
*
|
|
6
5
|
* Does an `fst-*.bin` still match the gazetteer it was built from?
|
|
7
6
|
*/
|
|
8
7
|
|
package/lib/fst/matcher.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
+
* In-memory FST matcher.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* arrays at accepting states.
|
|
7
|
+
* Built by `fst-builder.ts`, queried at runtime for emission priors and CLI introspection.
|
|
8
|
+
* The structure is a deterministic trie over normalized tokens with PlaceEntry arrays at accepting states.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { AncestrieMatch } from "@mailwoman/ancestrie"
|
package/lib/fst/serialize.ts
CHANGED
|
@@ -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 Binary serialization for the FST gazetteer.
|
|
6
6
|
*
|
|
7
7
|
* All integers are little-endian. The writer emits the current version. The reader accepts every earlier version.
|
|
@@ -53,11 +53,7 @@ const MAGIC = Buffer.from(FST_MAGIC_BYTES)
|
|
|
53
53
|
*/
|
|
54
54
|
const MAX_CHAIN_LEN = 8
|
|
55
55
|
|
|
56
|
-
const placetypeToIdx = new Map<string, number>()
|
|
57
|
-
|
|
58
|
-
for (let i = 0; i < PLACETYPE_ORDER.length; i++) {
|
|
59
|
-
placetypeToIdx.set(PLACETYPE_ORDER[i]!, i)
|
|
60
|
-
}
|
|
56
|
+
const placetypeToIdx = new Map<string, number>(PLACETYPE_ORDER.map((placetype, index) => [placetype, index]))
|
|
61
57
|
|
|
62
58
|
/**
|
|
63
59
|
* Serializes a matcher, with optional provenance, into the current FST binary format.
|
|
@@ -303,7 +299,7 @@ export function deserializeFST(buf: Buffer): FSTMatcher {
|
|
|
303
299
|
? buf.readFloatLE(pp + 12)
|
|
304
300
|
: Math.min(1, Math.log2(1 + buf.readUInt32LE(pp + 12) / 1000) / 14)
|
|
305
301
|
|
|
306
|
-
// Files before version 5 have no encyclopedic score, so their reserved byte
|
|
302
|
+
// Files before version 5 have no encyclopedic score, so their reserved byte isn't read as a flag.
|
|
307
303
|
const hasEncyclopedic =
|
|
308
304
|
isSplit && (buf.readUInt8(pp + 7) & PLACE_FLAG_HAS_ENCYCLOPEDIC) === PLACE_FLAG_HAS_ENCYCLOPEDIC
|
|
309
305
|
|
package/lib/fst/types.ts
CHANGED
|
@@ -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 Types for the FST gazetteer. These types map place-name token sequences to place entries.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -150,7 +150,7 @@ export interface BuildFSTOpts {
|
|
|
150
150
|
*/
|
|
151
151
|
excludeSurfaces?: ReadonlySet<string>
|
|
152
152
|
/**
|
|
153
|
-
* Tokens that a name
|
|
153
|
+
* Tokens that a name mustn't consist of entirely, such as "de la".
|
|
154
154
|
*
|
|
155
155
|
* Build this set from stopwords only.
|
|
156
156
|
* A street-type word can be part of a real name, as in "Avenue Road".
|
package/lib/fst.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
|
export * from "#fst/autocomplete"
|
|
8
5
|
export * from "#fst/binary-matcher"
|
package/lib/fts/query.ts
CHANGED
|
@@ -1,8 +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
|
-
*
|
|
6
5
|
* Query shaping for the FTS5 lookup: placetype normalization and the match-expression sanitizer.
|
|
7
6
|
*/
|
|
8
7
|
|
package/lib/fts.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 type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
8
5
|
import { tableExists } from "@mailwoman/sqlite/introspection"
|
package/lib/geonames/aliases.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
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 { isOfficialLanguage } from "@mailwoman/codex/country"
|
|
8
5
|
import { readUnquotedTSV } from "@mailwoman/core/fs/delimited"
|
|
9
6
|
import { pathExists } from "@mailwoman/core/fs/readers/stat"
|
|
10
7
|
import { GEONAMES_ID_BASE, GEONAMES_POSTAL_ID_BASE } from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
11
|
-
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
8
|
+
import type { DatabaseClient, StatementSync } from "@mailwoman/sqlite/client"
|
|
12
9
|
import { type PathBuilderLike, resolvePathBuilder } from "path-ts"
|
|
13
10
|
|
|
14
11
|
import type { WOFDatabase } from "#schema"
|
|
@@ -64,6 +61,12 @@ export interface GeonamesIngestProgress {
|
|
|
64
61
|
* It distinguishes a sparse source from aliases that the fold discarded.
|
|
65
62
|
*/
|
|
66
63
|
aliasesRefused: number | null
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The number of populated places that matched an existing record and added their
|
|
67
|
+
* names to it, or null when the fold had no matcher.
|
|
68
|
+
*/
|
|
69
|
+
matched?: number | null
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
/**
|
|
@@ -74,7 +77,9 @@ export function formatGeonamesIngestProgress(event: GeonamesIngestProgress, miss
|
|
|
74
77
|
return `${event.country}: ${missingFile ? `${missingFile} missing` : "dump missing"} — download from download.geonames.org/export/dump/${event.country}.zip; skipped`
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
const matched = event.matched == null ? "" : `, ${event.matched.toLocaleString()} matched an existing record`
|
|
81
|
+
|
|
82
|
+
return `${event.country}: ${event.places.toLocaleString()} places${matched}, ${(event.aliasesRefused ?? 0).toLocaleString()} alt-names refused`
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
interface V2Alias {
|
|
@@ -139,6 +144,113 @@ async function parseAlternateNamesV2(
|
|
|
139
144
|
return v2
|
|
140
145
|
}
|
|
141
146
|
|
|
147
|
+
/**
|
|
148
|
+
* A GeoNames place the fold is about to write.
|
|
149
|
+
*/
|
|
150
|
+
export interface GeonamesFoldPlace {
|
|
151
|
+
geonamesID: number
|
|
152
|
+
name: string
|
|
153
|
+
placetype: "country" | "region" | "locality"
|
|
154
|
+
country: string
|
|
155
|
+
latitude: number
|
|
156
|
+
longitude: number
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The record a GeoNames place matched in the database being folded into.
|
|
161
|
+
*/
|
|
162
|
+
export interface GeonamesFoldMatch {
|
|
163
|
+
id: number
|
|
164
|
+
placetype: string
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Matches GeoNames places against the records already in the database being folded into.
|
|
169
|
+
*/
|
|
170
|
+
export interface GeonamesFoldMatcher {
|
|
171
|
+
match(place: GeonamesFoldPlace): GeonamesFoldMatch | null
|
|
172
|
+
/**
|
|
173
|
+
* Answers whether the matched record lacks a name, recording it so the name is written once.
|
|
174
|
+
*/
|
|
175
|
+
claimName(match: GeonamesFoldMatch, country: string, name: string): boolean
|
|
176
|
+
onGap(place: GeonamesFoldPlace & { id: number }): void
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Folds one country's GeoNames `A`-class rows, its country and its ADM1 regions,
|
|
181
|
+
* and links each region the fold wrote to the country.
|
|
182
|
+
*
|
|
183
|
+
* A row that matches an existing record writes no row and adds its name to that record,
|
|
184
|
+
* and its id is the existing record's.
|
|
185
|
+
* Only regions the fold wrote are re-parented, so an existing region keeps its own parent.
|
|
186
|
+
*/
|
|
187
|
+
function foldAdminRows(
|
|
188
|
+
statements: { db: DatabaseClient<WOFDatabase>; spr: StatementSync; names: StatementSync; ancestors: StatementSync },
|
|
189
|
+
input: {
|
|
190
|
+
rows: readonly string[][]
|
|
191
|
+
country: string
|
|
192
|
+
clean: (s: string) => string | null
|
|
193
|
+
existing: GeonamesFoldMatcher | undefined
|
|
194
|
+
claim: (match: GeonamesFoldMatch, name: string) => void
|
|
195
|
+
nextID: number
|
|
196
|
+
}
|
|
197
|
+
): { countryID: number; adminMap: Map<string, number>; nextID: number } {
|
|
198
|
+
const { rows, country: cc, clean, existing, claim } = input
|
|
199
|
+
let id = input.nextID
|
|
200
|
+
let countryID = -1
|
|
201
|
+
const adminMap = new Map<string, number>()
|
|
202
|
+
// The regions this fold wrote, as opposed to existing records a region matched.
|
|
203
|
+
const writtenRegions = new Set<number>()
|
|
204
|
+
|
|
205
|
+
for (const f of rows) {
|
|
206
|
+
const aname = clean(f[2] ?? "") ?? clean(f[1] ?? "")
|
|
207
|
+
|
|
208
|
+
if (!aname) continue
|
|
209
|
+
const lat = Number(f[4]) || 0
|
|
210
|
+
const lon = Number(f[5]) || 0
|
|
211
|
+
const placetype: GeonamesFoldPlace["placetype"] = f[7]?.startsWith("PCL") ? "country" : "region"
|
|
212
|
+
|
|
213
|
+
if (placetype === "country" && countryID >= 0) continue
|
|
214
|
+
|
|
215
|
+
if (placetype === "region" && !(f[7] === "ADM1" && f[10])) continue
|
|
216
|
+
|
|
217
|
+
const place = { geonamesID: Number(f[0]), name: aname, placetype, country: cc, latitude: lat, longitude: lon }
|
|
218
|
+
const matched = existing?.match(place) ?? null
|
|
219
|
+
|
|
220
|
+
if (matched) {
|
|
221
|
+
claim(matched, aname)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const rid = matched?.id ?? id++
|
|
225
|
+
|
|
226
|
+
if (!matched) {
|
|
227
|
+
statements.spr.run(rid, -1, aname, placetype, cc, lat, lon, lat, lon, lat, lon, 1, 0, 0, 0, 0, 0)
|
|
228
|
+
statements.names.run(rid, aname, placetype, cc, "", "", 0, 0)
|
|
229
|
+
statements.ancestors.run(rid, rid, placetype)
|
|
230
|
+
existing?.onGap({ ...place, id: rid })
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (placetype === "country") {
|
|
234
|
+
countryID = rid
|
|
235
|
+
} else {
|
|
236
|
+
adminMap.set(f[10]!, rid)
|
|
237
|
+
|
|
238
|
+
if (!matched) {
|
|
239
|
+
writtenRegions.add(rid)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (countryID >= 0) {
|
|
245
|
+
for (const rid of writtenRegions) {
|
|
246
|
+
statements.db.prepare("UPDATE spr SET parent_id = ? WHERE id = ?").run(countryID, rid)
|
|
247
|
+
statements.ancestors.run(rid, countryID, "country")
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return { countryID, adminMap, nextID: id }
|
|
252
|
+
}
|
|
253
|
+
|
|
142
254
|
/**
|
|
143
255
|
* Purges the fold's id range, then adds GeoNames `P`-class places and their
|
|
144
256
|
* alternate names for `countries` to `db`.
|
|
@@ -156,6 +268,13 @@ export async function ingestGeonamesAliases(
|
|
|
156
268
|
adminForCountries?: ReadonlySet<string>
|
|
157
269
|
|
|
158
270
|
alternateDir?: PathBuilderLike
|
|
271
|
+
/**
|
|
272
|
+
* The records already in `db` to match against.
|
|
273
|
+
*
|
|
274
|
+
* A GeoNames place that matches one adds its names to that record and writes no row.
|
|
275
|
+
* A place that matches none is written and reported to `onGap`.
|
|
276
|
+
*/
|
|
277
|
+
existing?: GeonamesFoldMatcher
|
|
159
278
|
}
|
|
160
279
|
): Promise<number> {
|
|
161
280
|
const LATIN_NAME = /^[\p{Script=Latin}\p{M}\s\-'.]{2,60}$/u
|
|
@@ -184,7 +303,7 @@ export async function ingestGeonamesAliases(
|
|
|
184
303
|
)
|
|
185
304
|
|
|
186
305
|
const namesInsert = db.prepare(
|
|
187
|
-
`INSERT INTO names (id, name, placetype, country, language, privateuse, official, lastmodified) VALUES (?, ?, ?, ?, ?, ?, ?,
|
|
306
|
+
`INSERT INTO names (id, name, placetype, country, language, privateuse, official, lastmodified, source) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 'geonames')`
|
|
188
307
|
)
|
|
189
308
|
|
|
190
309
|
const populationInsert = db.prepare(`INSERT OR REPLACE INTO place_population (id, population) VALUES (?, ?)`)
|
|
@@ -218,6 +337,7 @@ export async function ingestGeonamesAliases(
|
|
|
218
337
|
|
|
219
338
|
let nc = 0
|
|
220
339
|
let refused = 0
|
|
340
|
+
let matchedPlaces = 0
|
|
221
341
|
|
|
222
342
|
const addAdmin = opts?.adminForCountries?.has(cc) ?? false
|
|
223
343
|
const v2File = opts?.alternateDir ? resolvePathBuilder(opts.alternateDir, `${cc}.txt`) : null
|
|
@@ -244,40 +364,26 @@ export async function ingestGeonamesAliases(
|
|
|
244
364
|
|
|
245
365
|
const v2 = readV2 ? await parseAlternateNamesV2(v2File!, cc, wanted) : null
|
|
246
366
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (!aname) continue
|
|
255
|
-
const lat = Number(f[4]) || 0
|
|
256
|
-
const lon = Number(f[5]) || 0
|
|
257
|
-
|
|
258
|
-
if (f[7]?.startsWith("PCL")) {
|
|
259
|
-
if (countryID >= 0) continue
|
|
260
|
-
countryID = id++
|
|
261
|
-
sprInsert.run(countryID, -1, aname, "country", cc, lat, lon, lat, lon, lat, lon, 1, 0, 0, 0, 0, 0)
|
|
262
|
-
namesInsert.run(countryID, aname, "country", cc, "", "", 0, 0)
|
|
263
|
-
ancestorInsert.run(countryID, countryID, "country")
|
|
264
|
-
} else if (f[7] === "ADM1" && f[10]) {
|
|
265
|
-
const rid = id++
|
|
266
|
-
sprInsert.run(rid, -1, aname, "region", cc, lat, lon, lat, lon, lat, lon, 1, 0, 0, 0, 0, 0)
|
|
267
|
-
namesInsert.run(rid, aname, "region", cc, "", "", 0, 0)
|
|
268
|
-
ancestorInsert.run(rid, rid, "region")
|
|
269
|
-
adminMap.set(f[10], rid)
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (countryID >= 0) {
|
|
274
|
-
for (const rid of adminMap.values()) {
|
|
275
|
-
db.prepare("UPDATE spr SET parent_id = ? WHERE id = ?").run(countryID, rid)
|
|
276
|
-
ancestorInsert.run(rid, countryID, "country")
|
|
277
|
-
}
|
|
367
|
+
/**
|
|
368
|
+
* Writes a place's name onto the existing record it matched, once.
|
|
369
|
+
*/
|
|
370
|
+
const claim = (match: GeonamesFoldMatch, name: string, language = "", privateuse = "", official = 0) => {
|
|
371
|
+
if (opts?.existing?.claimName(match, cc, name)) {
|
|
372
|
+
namesInsert.run(match.id, name, match.placetype, cc, language, privateuse, official, 0)
|
|
278
373
|
}
|
|
279
374
|
}
|
|
280
375
|
|
|
376
|
+
const admin = addAdmin
|
|
377
|
+
? foldAdminRows(
|
|
378
|
+
{ db, spr: sprInsert, names: namesInsert, ancestors: ancestorInsert },
|
|
379
|
+
{ rows: adminRows, country: cc, clean, existing: opts?.existing, claim, nextID: id }
|
|
380
|
+
)
|
|
381
|
+
: { countryID: -1, adminMap: new Map<string, number>(), nextID: id }
|
|
382
|
+
|
|
383
|
+
const { countryID, adminMap } = admin
|
|
384
|
+
|
|
385
|
+
id = admin.nextID
|
|
386
|
+
|
|
281
387
|
for await (const f of readUnquotedTSV(file)) {
|
|
282
388
|
if (f[6] !== "P") continue
|
|
283
389
|
const lat = Number(f[4])
|
|
@@ -287,8 +393,47 @@ export async function ingestGeonamesAliases(
|
|
|
287
393
|
const name = clean(f[1] ?? "")
|
|
288
394
|
|
|
289
395
|
if (!name) continue
|
|
396
|
+
|
|
397
|
+
const tags = v2?.get(Number(f[0]))
|
|
398
|
+
const alternates = [f[2] ?? "", ...(f[3] ? f[3].split(",") : [])]
|
|
399
|
+
|
|
400
|
+
const place = {
|
|
401
|
+
geonamesID: Number(f[0]),
|
|
402
|
+
name,
|
|
403
|
+
placetype: "locality" as const,
|
|
404
|
+
country: cc,
|
|
405
|
+
latitude: lat,
|
|
406
|
+
longitude: lon,
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const matched = opts?.existing?.match(place) ?? null
|
|
410
|
+
|
|
411
|
+
if (matched) {
|
|
412
|
+
claim(matched, name)
|
|
413
|
+
|
|
414
|
+
for (const raw of alternates) {
|
|
415
|
+
const alt = cleanAlias(raw)
|
|
416
|
+
|
|
417
|
+
if (!alt && raw.trim()) {
|
|
418
|
+
refused++
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (alt) {
|
|
422
|
+
const tag = tags?.get(alt)
|
|
423
|
+
|
|
424
|
+
claim(matched, alt, tag?.language ?? "", tag?.privateuse ?? "", tag?.official ?? 0)
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
matchedPlaces++
|
|
429
|
+
|
|
430
|
+
continue
|
|
431
|
+
}
|
|
432
|
+
|
|
290
433
|
const nid = id++
|
|
291
434
|
|
|
435
|
+
opts?.existing?.onGap({ ...place, id: nid })
|
|
436
|
+
|
|
292
437
|
const regionID = addAdmin ? (adminMap.get(f[10] ?? "") ?? -1) : -1
|
|
293
438
|
const parentID = regionID >= 0 ? regionID : addAdmin && countryID >= 0 ? countryID : -1
|
|
294
439
|
|
|
@@ -309,9 +454,7 @@ export async function ingestGeonamesAliases(
|
|
|
309
454
|
|
|
310
455
|
const seen = new Set([name])
|
|
311
456
|
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
for (const raw of [f[2] ?? "", ...(f[3] ? f[3].split(",") : [])]) {
|
|
457
|
+
for (const raw of alternates) {
|
|
315
458
|
const alt = cleanAlias(raw)
|
|
316
459
|
|
|
317
460
|
if (!alt && raw.trim()) {
|
|
@@ -335,7 +478,14 @@ export async function ingestGeonamesAliases(
|
|
|
335
478
|
nc++
|
|
336
479
|
}
|
|
337
480
|
|
|
338
|
-
report({
|
|
481
|
+
report({
|
|
482
|
+
country: cc,
|
|
483
|
+
places: nc,
|
|
484
|
+
skipped: false,
|
|
485
|
+
aliasesRefused: refused,
|
|
486
|
+
matched: opts?.existing ? matchedPlaces : null,
|
|
487
|
+
})
|
|
488
|
+
|
|
339
489
|
total += nc
|
|
340
490
|
}
|
|
341
491
|
|
package/lib/geonames/postal.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
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
|
-
* Fold GeoNames postcode rows into a WOF or unified postcode extract as first-class `postalcode`
|
|
7
|
-
* places for countries whose WOF postalcode repos do not exist.
|
|
5
|
+
* Fold GeoNames postcode rows into a WOF or unified postcode extract as first-class
|
|
6
|
+
* `postalcode` places for countries whose WOF postalcode repos do not exist.
|
|
8
7
|
*
|
|
9
8
|
* Two laws are enforced here in code rather than in a runbook.
|
|
10
9
|
*
|
|
11
|
-
* 1. The name law.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
10
|
+
* 1. The name law.
|
|
11
|
+
* A postcode row's `name` is stored in the sanitized-query token shape with
|
|
12
|
+
* every non-letter and non-number stripped.
|
|
13
|
+
* `sanitizeFTSQuery` reduces the parsed token to that shape at lookup time.
|
|
14
|
+
* A stored `"110 00"` or `"11-041"` can never match the query `"11000"` or `"11041"`.
|
|
15
|
+
* The display form is preserved as an alt row in `names`.
|
|
16
|
+
* 2. The medoid law.
|
|
17
|
+
* A postcode whose rows contain scattered points has no single true center.
|
|
18
|
+
* Their average puts the code somewhere no address is.
|
|
19
|
+
* The medoid is the member point nearest the group's mean.
|
|
18
20
|
*
|
|
19
21
|
* `build-unified-wof --geonames-postal-countries`, standalone folds and the `mailwoman
|
|
20
22
|
* gazetteer` commands share one implementation. The GeoNames postal dump is
|
|
@@ -77,7 +79,7 @@ export interface MedoidSupport {
|
|
|
77
79
|
* Distinct coordinates among them.
|
|
78
80
|
*
|
|
79
81
|
* One means every row refers to the same point.
|
|
80
|
-
* In a dump whose coordinates are computed, that
|
|
82
|
+
* In a dump whose coordinates are computed, that's one value inherited N times
|
|
81
83
|
* rather than N sources agreeing.
|
|
82
84
|
*/
|
|
83
85
|
distinctPoints: number
|
|
@@ -223,7 +225,7 @@ export async function ingestGeonamesPostal(
|
|
|
223
225
|
)
|
|
224
226
|
|
|
225
227
|
const namesInsert = db.prepare(
|
|
226
|
-
`INSERT INTO names (id, name, placetype, country, language, lastmodified) VALUES (?, ?, 'postalcode', ?, '', 0)`
|
|
228
|
+
`INSERT INTO names (id, name, placetype, country, language, lastmodified, source) VALUES (?, ?, 'postalcode', ?, '', 0, 'geonames')`
|
|
227
229
|
)
|
|
228
230
|
|
|
229
231
|
let nextID = GEONAMES_POSTAL_ID_BASE
|
package/lib/geonames.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
|
export * from "#geonames/aliases"
|
|
8
5
|
export * from "#geonames/postal"
|
package/lib/index.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
|
export type { FindPlaceQuery, PlaceCandidate, PlaceLookup, WOFPlacetype } from "#types"
|
|
8
5
|
|
|
@@ -122,6 +119,8 @@ export {
|
|
|
122
119
|
|
|
123
120
|
export { AddressPointInterpolator } from "#address/point/interpolation"
|
|
124
121
|
export { AddressPointSqliteLookup } from "#address/point"
|
|
122
|
+
export { openAddressLayerLookup } from "#address/keys/open"
|
|
123
|
+
export { readLatestAddressLayerManifest } from "#address/keys/layout"
|
|
125
124
|
|
|
126
125
|
export {
|
|
127
126
|
STREET_CENTROID_COLUMNS,
|
package/lib/interpolation.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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
|
-
*
|
|
6
|
-
* House-number interpolation: when the exact address-point tier misses, estimate the coordinate from tiger street-segment ranges by parity-aware range match and linear interpolation along the segment polyline.
|
|
5
|
+
* House-number interpolation: when the exact address-point tier misses,
|
|
6
|
+
* estimate the coordinate from tiger street-segment ranges by parity-aware range match
|
|
7
|
+
* and linear interpolation along the segment polyline.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
import { parseJSONStrict } from "@mailwoman/core/json"
|
|
@@ -134,7 +135,7 @@ export class StreetInterpolator<
|
|
|
134
135
|
/**
|
|
135
136
|
* Resources this instance opened.
|
|
136
137
|
*
|
|
137
|
-
* A caller-supplied connection
|
|
138
|
+
* A caller-supplied connection isn't in here, so disposal cannot reach it.
|
|
138
139
|
*/
|
|
139
140
|
readonly #resources: DisposableStack
|
|
140
141
|
readonly #byPostcode:
|
package/lib/landmark/rows.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
+
* The landmark table's read, shared by the native lookup and the range-read lookup a Worker uses.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* client, so a Worker bundle can import it.
|
|
7
|
+
* It holds no database client, so a Worker bundle can import it.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { LandmarkHit, LandmarkKind } from "@mailwoman/core/resolver"
|
package/lib/landmark.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
*
|
|
6
|
-
* The landmark layer: Wikidata places keyed by every name and alias they are written with, ranked by the number of
|
|
7
|
-
* Wikipedia language editions that describe them. The source is CC0, so the database may ship.
|
|
5
|
+
* The landmark layer: Wikidata places keyed by every name and alias they're written with,
|
|
6
|
+
* ranked by the number of Wikipedia language editions that describe them.
|
|
7
|
+
* The source is CC0, so the database may ship.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { LandmarkHit, LandmarkLookup } from "@mailwoman/core/resolver"
|
package/lib/lookup.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
|
-
* `WOFSQLitePlaceLookup` — the resolver implementation backed by `node:sqlite` plus a Kysely-typed query layer where the queries are non-trivial and raw SQL where they are not.
|
|
5
|
+
* `WOFSQLitePlaceLookup` — the resolver implementation backed by `node:sqlite` plus a
|
|
6
|
+
* Kysely-typed query layer where the queries are non-trivial and raw SQL where they're not.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { expandPlacetypeFilter } from "@mailwoman/codex/placetype-map"
|
|
@@ -550,7 +550,7 @@ export class WOFSQLitePlaceLookup extends SQLiteLookup<WOFDatabase> implements P
|
|
|
550
550
|
/**
|
|
551
551
|
* Coordinate-first locality resolution: union the postcode's containing
|
|
552
552
|
* and closest neighboring localities with the FTS name candidates and soft-score them,
|
|
553
|
-
* returning null when the postcode
|
|
553
|
+
* returning null when the postcode isn't in the table.
|
|
554
554
|
*/
|
|
555
555
|
async #findLocalityCoordFirst(
|
|
556
556
|
query: FindPlaceQuery,
|
|
@@ -583,7 +583,7 @@ export class WOFSQLitePlaceLookup extends SQLiteLookup<WOFDatabase> implements P
|
|
|
583
583
|
}
|
|
584
584
|
|
|
585
585
|
// Observed postal-city aliases for this postcode keyed by geographic locality name,
|
|
586
|
-
// empty when the reader
|
|
586
|
+
// empty when the reader isn't supplied.
|
|
587
587
|
const postalAliasByGeo = new Map<string, string[]>()
|
|
588
588
|
|
|
589
589
|
if (this.#postalCityAliases) {
|
|
@@ -635,7 +635,7 @@ export class WOFSQLitePlaceLookup extends SQLiteLookup<WOFDatabase> implements P
|
|
|
635
635
|
// with the soft score breaking ties within a tier.
|
|
636
636
|
scored.sort((a, b) => Number(b.exact) - Number(a.exact) || b.score - a.score)
|
|
637
637
|
|
|
638
|
-
// When the chosen locality
|
|
638
|
+
// When the chosen locality isn't the postcode's containing locality and sits far
|
|
639
639
|
// from it, flag `mismatch` rather than overriding the name.
|
|
640
640
|
const top = scored[0]
|
|
641
641
|
|
package/lib/name-score.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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
|
+
* Soft name matching for locality ranking: case/diacritic folding, padded character
|
|
6
|
+
* trigrams and the trigram-Jaccard score built on them.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* both rank the same typo identically — the whole reason this is one module rather than two copies.
|
|
8
|
+
* Shared by the FTS lookup and the candidate-table backend so both rank the same typo
|
|
9
|
+
* identically — the whole reason this is one module rather than two copies.
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
/**
|