@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
package/lib/ranking-weights.ts
CHANGED
|
@@ -1,10 +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
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
+
* The locality-ranking weights and their shipped defaults live here because each
|
|
6
|
+
* value is a measured tuning decision with its rationale attached.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
* with its rationale attached. This block reads as a reference table outside the lookup's control flow.
|
|
8
|
+
* This block reads as a reference table outside the lookup's control flow.
|
|
8
9
|
* Tests import it directly to pin one change at a time.
|
|
9
10
|
*/
|
|
10
11
|
|
|
@@ -100,11 +101,11 @@ export interface RankingWeights {
|
|
|
100
101
|
* Its job is to break ties among candidates that match the query equally well,
|
|
101
102
|
* as in "Springfield" → Springfield IL over Springfield MA.
|
|
102
103
|
*
|
|
103
|
-
* It
|
|
104
|
+
* It doesn't promote a place that matches the query worse.
|
|
104
105
|
* Tiers keep match quality as the primary key and prominence as the secondary key within each tier.
|
|
105
106
|
*
|
|
106
107
|
* Note: tiering re-ranks within the over-fetched candidate window (`limit * 4`),
|
|
107
|
-
* so a pathological exact match outside that window
|
|
108
|
+
* so a pathological exact match outside that window isn't rescued.
|
|
108
109
|
*
|
|
109
110
|
* @defaultValue `true`
|
|
110
111
|
*/
|
package/lib/region-keys.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
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
|
* Both consumers use this expansion to compare parsed region qualifiers with stored keys.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* Admin-coherence verdicts (`mailwoman/admin-coherence.ts`) fold a qualifier
|
|
8
|
+
* and the winner's ancestry to decide `confirmed` or `contradicted`.
|
|
9
|
+
* The candidate backend's admin-containment re-rank (`candidate-lookup.ts`)
|
|
10
|
+
* uses the same fold to find region-class rows.
|
|
11
|
+
* The shared function keeps both decisions aligned.
|
|
12
|
+
*
|
|
13
|
+
* Lives here rather than in `mailwoman` because the dependency points this way.
|
|
14
|
+
* `mailwoman` depends on `@mailwoman/resolver-wof-sqlite`
|
|
15
|
+
* (which owns the fold and already depends on codex), never the reverse.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
import { matchSubdivision, matchSubdivisionIn } from "@mailwoman/codex/country"
|
|
@@ -130,7 +131,7 @@ export function regionKeys(value: string, countryAlpha2?: string | null): Set<st
|
|
|
130
131
|
|
|
131
132
|
// The empty fold stays in the set on purpose.
|
|
132
133
|
// The admin-coherence verdicts have always compared the empty key
|
|
133
|
-
// (two empty-folding strings intersect → `confirmed`), and this move
|
|
134
|
+
// (two empty-folding strings intersect → `confirmed`), and this move mustn't shift a verdict.
|
|
134
135
|
// A consumer probing a table by key filters the empty string out itself.
|
|
135
136
|
return keys
|
|
136
137
|
}
|
|
@@ -159,7 +160,7 @@ export function regionKeys(value: string, countryAlpha2?: string | null): Set<st
|
|
|
159
160
|
*/
|
|
160
161
|
export function regionQualifierProbeKeys(value: string, countryAlpha2?: string | null): Set<string> {
|
|
161
162
|
const keys = regionKeys(value, countryAlpha2)
|
|
162
|
-
// Snapshot before widening: the loop adds `county <key>` members that
|
|
163
|
+
// Snapshot before widening: the loop adds `county <key>` members that mustn't themselves be revisited.
|
|
163
164
|
const bare = [...keys]
|
|
164
165
|
|
|
165
166
|
for (const key of bare) {
|
package/lib/reverse.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
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
|
* Reverse geocoding: map a `(lat, lon)` point to the containing admin hierarchy.
|
|
7
6
|
*
|
|
8
7
|
* 1. Fetch the admin DB's `place_bbox` R*Tree candidates whose bbox contains the point,
|
|
9
8
|
* smallest-area-first, so the first polygon confirmation is the deepest.
|
|
10
9
|
* 2. Confirm each candidate by ray-cast (geo.ts, the canonical TS port of
|
|
11
10
|
* `scripts/eval/pip-containment.py`) against the polygon sidecar DB (`wof-polygons.db`,
|
|
12
|
-
* `polygons(id, geom)` with GeoJSON text, built by `scripts/build-wof-polygons.mjs`).
|
|
13
|
-
* candidate whose polygon exists but rejects the point is a bbox false positive and is
|
|
14
|
-
*
|
|
11
|
+
* `polygons(id, geom)` with GeoJSON text, built by `scripts/build-wof-polygons.mjs`).
|
|
12
|
+
* A candidate whose polygon exists but rejects the point is a bbox false positive and is dropped.
|
|
13
|
+
* A candidate with no polygon row stays eligible for the approximate fallback.
|
|
15
14
|
* 3. Descend tier-by-tier through the winner's descendants (the `ancestors` table, reversed),
|
|
16
|
-
* taking the PIP-confirmed child when a polygon exists and the nearest-centroid child
|
|
17
|
-
*
|
|
18
|
-
* 4. Assemble the deepest place's ancestor chain through the same walk forward
|
|
19
|
-
* so consumers get a symmetric tree.
|
|
15
|
+
* taking the PIP-confirmed child when a polygon exists and the nearest-centroid child otherwise.
|
|
16
|
+
* A centroid-fallback step is flagged `containment: "approximate"`.
|
|
17
|
+
* 4. Assemble the deepest place's ancestor chain through the same walk forward
|
|
18
|
+
* resolution uses, so consumers get a symmetric tree.
|
|
20
19
|
*
|
|
21
|
-
* Reverse quality is country-dependent, because polygon coverage is.
|
|
22
|
-
* result.
|
|
20
|
+
* Reverse quality is country-dependent, because polygon coverage is.
|
|
21
|
+
* `containment` records this per result.
|
|
23
22
|
*/
|
|
24
23
|
|
|
25
24
|
import { tryParsingJSON } from "@mailwoman/core/json"
|
|
@@ -118,7 +117,7 @@ export interface ReverseGeocodeOpts {
|
|
|
118
117
|
*
|
|
119
118
|
* Current measurements show that this covers a dense metro.
|
|
120
119
|
*
|
|
121
|
-
* The most bbox-overlapping point we
|
|
120
|
+
* The most bbox-overlapping point we've measured is a few dozen neighborhoods plus the admin chain.
|
|
122
121
|
*
|
|
123
122
|
* @defaultValue `128`
|
|
124
123
|
*/
|
|
@@ -236,7 +235,7 @@ export class WOFReverseGeocoder implements Disposable {
|
|
|
236
235
|
this.#ownsPolygons = !opts.polygonDatabase && Boolean(opts.polygonDBPath)
|
|
237
236
|
|
|
238
237
|
// Fail loudly up front.
|
|
239
|
-
// The R*Tree is a build artifact and
|
|
238
|
+
// The R*Tree is a build artifact and isn't part of the upstream WOF distribution,
|
|
240
239
|
// so a missing index would otherwise surface as an opaque SQL error per query.
|
|
241
240
|
if (!tableExists(this.#admin, PLACE_BBOX_TABLE)) {
|
|
242
241
|
throw new Error(
|
|
@@ -367,7 +366,7 @@ export class WOFReverseGeocoder implements Disposable {
|
|
|
367
366
|
currentConfirmed = nextConfirmed
|
|
368
367
|
currentDistanceKm = nextKm
|
|
369
368
|
}
|
|
370
|
-
// An empty tier
|
|
369
|
+
// An empty tier isn't terminal.
|
|
371
370
|
// Counties without localadmins jump straight to locality.
|
|
372
371
|
}
|
|
373
372
|
|
|
@@ -505,7 +504,7 @@ export class WOFReverseGeocoder implements Disposable {
|
|
|
505
504
|
|
|
506
505
|
const row = this.#polygons.prepare(`SELECT geom FROM polygons WHERE id = ?`).get(id) as { geom: string } | undefined
|
|
507
506
|
// Malformed row parses to null.
|
|
508
|
-
// Treat it as no-polygon so the query
|
|
507
|
+
// Treat it as no-polygon so the query doesn't fail.
|
|
509
508
|
const geometry = row ? tryParsingJSON<ParsedGeometry>(row.geom) : null
|
|
510
509
|
|
|
511
510
|
this.#geometryCache.set(id, geometry)
|
package/lib/schema.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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
|
* Kysely table types for the subset of the Who's On First SQLite schema this package touches.
|
|
7
6
|
*
|
|
8
7
|
* The full upstream distribution at data.geocode.earth/wof/dist/sqlite/ ships about seven tables.
|
|
9
|
-
* This file models only the tables we read.
|
|
8
|
+
* This file models only the tables we read.
|
|
9
|
+
*
|
|
10
|
+
* The others are outside the resolver interface.
|
|
11
|
+
* Their shapes remain unverified.
|
|
10
12
|
*
|
|
11
13
|
* Authoritative schema docs:
|
|
12
14
|
*
|
|
@@ -99,13 +101,19 @@ export interface NamesTable {
|
|
|
99
101
|
official: number | null
|
|
100
102
|
name: string
|
|
101
103
|
lastmodified: number
|
|
104
|
+
/**
|
|
105
|
+
* The dataset the row came from, one of `ROW_SOURCES` in `unified-schema.ts`.
|
|
106
|
+
*
|
|
107
|
+
* Databases built before the column existed have no such column.
|
|
108
|
+
*/
|
|
109
|
+
source?: string
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
/**
|
|
105
113
|
* Per-place GeoJSON blob.
|
|
106
114
|
*
|
|
107
115
|
* Centroid lat/lon are already exposed via `spr.{latitude,longitude}`,
|
|
108
|
-
* so the resolver
|
|
116
|
+
* so the resolver doesn't need to parse this.
|
|
109
117
|
* The table stays modeled so a caller that wants the full geometry for bbox or polygon work can read it.
|
|
110
118
|
*/
|
|
111
119
|
export interface GeojsonTable {
|
|
@@ -168,6 +176,12 @@ export interface ConcordancesTable {
|
|
|
168
176
|
other_id: string
|
|
169
177
|
other_source: string
|
|
170
178
|
lastmodified: number
|
|
179
|
+
/**
|
|
180
|
+
* The dataset the row came from, one of `ROW_SOURCES` in `unified-schema.ts`.
|
|
181
|
+
*
|
|
182
|
+
* Databases built before the column existed have no such column.
|
|
183
|
+
*/
|
|
184
|
+
source?: string
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
/**
|
package/lib/search-fetch.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
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
|
+
* Fetches FTS5 candidates for fuzzy name matching.
|
|
6
|
+
*
|
|
7
|
+
* It runs the schema-qualified `place_search` match and its population-ordered companion query.
|
|
8
|
+
* Both queries return the raw row shape defined here.
|
|
5
9
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
10
|
+
* Bbox and near-with-radius narrow at the SQL level through SQLite's built-in `rtree`,
|
|
11
|
+
* whose index name and schema are defined in `fts.ts` beside the FTS5 build.
|
|
12
|
+
* This package uses SQLite's R*Tree instead of SpatiaLite or turf.
|
|
8
13
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* instead of the whole corpus, so exact haversine calculations remain cheap.
|
|
14
|
+
* The R*Tree narrows the search to at most a few hundred candidates per query.
|
|
15
|
+
* Downstream passes work on that set instead of the whole corpus,
|
|
16
|
+
* so exact haversine calculations remain cheap.
|
|
13
17
|
*/
|
|
14
18
|
|
|
15
19
|
import { allRows } from "@mailwoman/core/utils"
|
|
@@ -150,7 +154,7 @@ export function fetchSearchRows<DB>(options: {
|
|
|
150
154
|
// Bbox and near-with-radius are SQL-level filters via the R*Tree.
|
|
151
155
|
// The join is emitted only when the active extract has the R*Tree.
|
|
152
156
|
// A requested filter on a legacy extract is silently treated as no bbox filter
|
|
153
|
-
// so the query
|
|
157
|
+
// so the query doesn't crash.
|
|
154
158
|
const extractHasBbox = hasBboxIndex.get(sch) === true
|
|
155
159
|
const useBboxJoin = (query.bbox || query.near?.maxDistanceKm) && extractHasBbox
|
|
156
160
|
let joinClause = `JOIN ${sch}.spr ON spr.id = place_search.wof_id`
|
|
@@ -240,7 +244,7 @@ export function fetchSearchRows<DB>(options: {
|
|
|
240
244
|
// by the row's alias bulk (measured ~15 pts, against a +4.0 boost cap).
|
|
241
245
|
// This fetch includes prominent holders of a name in the candidate pool.
|
|
242
246
|
// The exact-tier sort below decides whether they win.
|
|
243
|
-
// It is skipped without a population index, since there
|
|
247
|
+
// It is skipped without a population index, since there's no column to order by.
|
|
244
248
|
if (extractHasPopulation) {
|
|
245
249
|
const popStmt = db.prepare(`
|
|
246
250
|
SELECT
|
|
@@ -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 { tryParsingJSON } from "@mailwoman/core/json"
|
|
8
5
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
package/lib/sqlite/utils.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 Shared helpers for the SQLite-backed lookups.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -67,7 +67,7 @@ export function hasTable<DB>(db: DatabaseClient<DB>, name: string): boolean {
|
|
|
67
67
|
* at construction and leave the column out of their queries when it is missing.
|
|
68
68
|
* Avoid calling it per query, because it runs a pragma.
|
|
69
69
|
*
|
|
70
|
-
* The pragma
|
|
70
|
+
* The pragma doesn't accept bound parameters, so `table` is interpolated into the SQL.
|
|
71
71
|
* Pass only constants.
|
|
72
72
|
*/
|
|
73
73
|
export function hasColumn<DB>(db: DatabaseClient<DB>, table: string, column: string): boolean {
|
|
@@ -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
|
-
* Schema for the street-centroid extract. It groups address-point rows by street.
|
|
5
|
+
* Schema for the street-centroid extract.
|
|
6
|
+
* It groups address-point rows by street.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Kysely } from "kysely"
|
|
@@ -69,7 +69,7 @@ export interface StreetCentroidTable {
|
|
|
69
69
|
* to check that a street name exists.
|
|
70
70
|
*
|
|
71
71
|
* The name-evidence rerank folds the model's street text with the same function, so this
|
|
72
|
-
* column must use `foldStreetSurface` and
|
|
72
|
+
* column must use `foldStreetSurface` and mustn't follow the `street_norm` normalizer.
|
|
73
73
|
* The type is a plain string because `foldStreetSurface` differs from the
|
|
74
74
|
* {@link NameKey} fold that other `name_key` columns use.
|
|
75
75
|
*
|
package/lib/street/centroid.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 SQLite implementation of core's `StreetCentroidLookup`.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The street locale every country's address keys are folded under, for builders and readers alike.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { OFFICIAL_LANGUAGES } from "@mailwoman/codex/country/official-languages"
|
|
9
|
+
|
|
10
|
+
import type { StreetLocale } from "#street/normalize"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The locale whose rules fold streets written in each language, keyed by the two-letter
|
|
14
|
+
* ISO 639-1 code `OFFICIAL_LANGUAGES` lists first among a language's spellings.
|
|
15
|
+
*/
|
|
16
|
+
const STREET_LOCALE_BY_LANGUAGE: ReadonlyMap<string, StreetLocale> = new Map([
|
|
17
|
+
["en", "en"],
|
|
18
|
+
["es", "es"],
|
|
19
|
+
["fr", "fr"],
|
|
20
|
+
["de", "de"],
|
|
21
|
+
["it", "it"],
|
|
22
|
+
["nl", "nl"],
|
|
23
|
+
["pl", "pl"],
|
|
24
|
+
["vi", "vn"],
|
|
25
|
+
["id", "id"],
|
|
26
|
+
["zh", "zh"],
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Countries whose official languages span several locales, with the locale their
|
|
31
|
+
* published address databases were built under.
|
|
32
|
+
*
|
|
33
|
+
* Canada's OSM extract folds under `en`, and `streetLocaleForSurface` routes a
|
|
34
|
+
* street that opens with a French type word to `fr`.
|
|
35
|
+
*/
|
|
36
|
+
const STREET_LOCALE_EXCEPTIONS: ReadonlyMap<string, StreetLocale> = new Map([["CA", "en"]])
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The locale a country's streets fold under: its exception when it has one, else the one locale
|
|
40
|
+
* its official languages have rules in, else `und`, the shared fold with no language's abbreviations.
|
|
41
|
+
*
|
|
42
|
+
* The answer covers every ISO 3166-1 country, so a builder and a reader that
|
|
43
|
+
* both call this fold one street to one key.
|
|
44
|
+
* A country whose official languages span several locales folds under `und`
|
|
45
|
+
* until its built databases name one in {@link STREET_LOCALE_EXCEPTIONS}.
|
|
46
|
+
*/
|
|
47
|
+
export function streetLocaleForCountry(countryCode: string): StreetLocale {
|
|
48
|
+
const country = countryCode.trim().toUpperCase()
|
|
49
|
+
const exception = STREET_LOCALE_EXCEPTIONS.get(country)
|
|
50
|
+
|
|
51
|
+
if (exception) return exception
|
|
52
|
+
|
|
53
|
+
const locales = new Set<StreetLocale>()
|
|
54
|
+
|
|
55
|
+
for (const language of OFFICIAL_LANGUAGES[country]?.official ?? []) {
|
|
56
|
+
const locale = STREET_LOCALE_BY_LANGUAGE.get(language)
|
|
57
|
+
|
|
58
|
+
if (locale) {
|
|
59
|
+
locales.add(locale)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return locales.size === 1 ? [...locales][0]! : "und"
|
|
64
|
+
}
|
|
@@ -1,27 +1,29 @@
|
|
|
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
|
+
* Build a street-morphology FST from libpostal's street_types dictionaries.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* The morphology FST maps street-typing affixes (Street/Avenue/rue/Calle/Straße/...)
|
|
8
|
+
* to a single synthetic placetype `"street_affix"`.
|
|
9
|
+
* Its source data and purpose differ from the admin FST.
|
|
9
10
|
* It also produces a separate binary artifact.
|
|
10
11
|
*
|
|
11
|
-
* The morphology FST closes the inference-time vacuum identified by the v0.6.1 postmortem:
|
|
12
|
-
* tokens have no admin-FST anchor, so synth-street training pushed the model
|
|
13
|
-
* `dependent_locality` on subcomponents.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* The morphology FST closes the inference-time vacuum identified by the v0.6.1 postmortem:
|
|
13
|
+
* street tokens have no admin-FST anchor, so synth-street training pushed the model
|
|
14
|
+
* toward over-emitting `dependent_locality` on subcomponents.
|
|
15
|
+
* With the morphology FST, the neural decoder gets positive evidence for
|
|
16
|
+
* street-typing affixes and the adjacent name tokens, plus negative evidence
|
|
17
|
+
* away from `dependent_locality` on the same neighbors.
|
|
16
18
|
*
|
|
17
|
-
* Design rationale + the four-layer street-supplement architecture lives
|
|
18
|
-
* `docs/articles/concepts/street-supplement-architecture.md`.
|
|
19
|
+
* Design rationale + the four-layer street-supplement architecture lives
|
|
20
|
+
* in `docs/articles/concepts/street-supplement-architecture.md`.
|
|
19
21
|
*
|
|
20
|
-
* Source: `dictionaries/data/libpostal/dictionaries/{locale}/street_types.txt`.
|
|
21
|
-
* surface forms with the canonical form
|
|
22
|
+
* Source: `dictionaries/data/libpostal/dictionaries/{locale}/street_types.txt`.
|
|
23
|
+
* Each line is pipe-delimited surface forms with the canonical form
|
|
24
|
+
* first: avenue|av|ave|aven|avenu|avn|avnu|avnue
|
|
22
25
|
*
|
|
23
|
-
* Output: an `FSTMatcher` ready to serialize via `serializeFST` to e.g.
|
|
24
|
-
* `fst-street-morphology.bin`.
|
|
26
|
+
* Output: an `FSTMatcher` ready to serialize via `serializeFST` to e.g. `fst-street-morphology.bin`.
|
|
25
27
|
*/
|
|
26
28
|
|
|
27
29
|
import { AU_STATE_ABBREVIATIONS } from "@mailwoman/codex/au/state"
|
|
@@ -84,7 +86,7 @@ export interface BuildStreetMorphologyFSTOpts {
|
|
|
84
86
|
/**
|
|
85
87
|
* Variant surface forms, in joined post-normalization form, that the trie never holds.
|
|
86
88
|
*
|
|
87
|
-
* A two-character street type that
|
|
89
|
+
* A two-character street type that's also a region abbreviation, `ct` for court
|
|
88
90
|
* and Connecticut or `la` for lane and Louisiana, reads as the region at parse time.
|
|
89
91
|
* The artifact is locale-general, so the variant stays out for every locale.
|
|
90
92
|
*
|
|
@@ -245,7 +247,7 @@ export async function buildStreetMorphologyFST(
|
|
|
245
247
|
// (Avenue is almost never anything but street-typing).
|
|
246
248
|
// The morphology prior caps bias separately.
|
|
247
249
|
// This value only feeds the cap formula `referential * cap`.
|
|
248
|
-
// No encyclopedic score — a street affix
|
|
250
|
+
// No encyclopedic score — a street affix isn't a place and has no article.
|
|
249
251
|
referential: 1,
|
|
250
252
|
encyclopedic: null,
|
|
251
253
|
lat: 0,
|
|
@@ -1,22 +1,24 @@
|
|
|
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
|
+
* Runtime loader for the street-morphology FST.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* resolution ladder every node call site shares.
|
|
7
|
+
* The sealed artifact (`fst-street-morphology.bin`, built by `mailwoman gazetteer build street-morphology`)
|
|
8
|
+
* is the one resolution ladder every node call site shares.
|
|
9
9
|
*
|
|
10
|
-
* 1. An explicit `artifactPath`, e.g. the weights-package sibling surfaced
|
|
11
|
-
* `NeuralAddressClassifier.streetMorphologyPath`.
|
|
10
|
+
* 1. An explicit `artifactPath`, e.g. the weights-package sibling surfaced
|
|
11
|
+
* by `NeuralAddressClassifier.streetMorphologyPath`.
|
|
12
|
+
* When given, it is the only artifact probed.
|
|
12
13
|
* 2. Otherwise the staged sealed artifact at `$MAILWOMAN_DATA_ROOT/db/wof/fst-street-morphology.bin`.
|
|
13
|
-
* 3. A build-from-dictionaries fallback: `buildStreetMorphologyFST` over
|
|
14
|
-
* `street_types.txt` files, kept
|
|
15
|
-
* of a crash.
|
|
14
|
+
* 3. A build-from-dictionaries fallback: `buildStreetMorphologyFST` over
|
|
15
|
+
* `@mailwoman/dictionaries`' libpostal `street_types.txt` files, kept
|
|
16
|
+
* so a missing artifact degrades to a per-process build instead of a crash.
|
|
16
17
|
*
|
|
17
18
|
* A present-but-unreadable artifact reports through `onWarn` and falls through to the build rung.
|
|
18
|
-
* Browsers cannot take the fallback because they have no filesystem API.
|
|
19
|
-
*
|
|
19
|
+
* Browsers cannot take the fallback because they have no filesystem API.
|
|
20
|
+
*
|
|
21
|
+
* They deserialize the same artifact through `fst-deserialize-web.ts` (see the docs demo loader).
|
|
20
22
|
*/
|
|
21
23
|
|
|
22
24
|
import { readLocalBuffer } from "@mailwoman/core/fs/readers"
|
|
@@ -1,20 +1,21 @@
|
|
|
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
|
* The SQLite backend for {@link StreetLocalityEvidence}.
|
|
7
6
|
*
|
|
8
|
-
* Reads a street-name index (the FR instance is BAN `street-centroids-fr.db`,
|
|
9
|
-
* table of `street_norm × locality_base × postcode` rows)
|
|
10
|
-
* exist as a name" for the k-best rerank.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* Reads a street-name index (the FR instance is BAN `street-centroids-fr.db`,
|
|
8
|
+
* a `street_centroid` table of `street_norm × locality_base × postcode` rows)
|
|
9
|
+
* and answers "does this street surface exist as a name" for the k-best rerank.
|
|
10
|
+
* It is sync-by-interface and read-only, uses prepared statements.
|
|
11
|
+
*
|
|
12
|
+
* It also degrades gracefully on a tableless extract, following the same reader
|
|
13
|
+
* discipline as `AddressPointSqliteLookup`.
|
|
13
14
|
*
|
|
14
|
-
* The fold interface: the surface is folded with {@link foldStreetSurface}
|
|
15
|
-
* so the DB's `street_norm` column must have been built with
|
|
16
|
-
* or apostrophe'd street silently misses.
|
|
17
|
-
* backend is wired in production.
|
|
15
|
+
* The fold interface: the surface is folded with {@link foldStreetSurface}
|
|
16
|
+
* (the shared function), so the DB's `street_norm` column must have been built with
|
|
17
|
+
* that same fold or every hyphenated or apostrophe'd street silently misses.
|
|
18
|
+
* The column also needs a `street_norm` index before this backend is wired in production.
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
import { foldStreetSurface, type StreetEvidenceScope, type StreetLocalityEvidence } from "@mailwoman/resolver"
|
|
@@ -87,7 +88,7 @@ export class SQLiteStreetNameLookup extends SQLiteLookup<WOFDatabase> implements
|
|
|
87
88
|
|
|
88
89
|
// Scoped lookups tighten precision when the hypothesis includes a locality/postcode.
|
|
89
90
|
// A scoped miss falls back to the unscoped probe.
|
|
90
|
-
// The scope column may be incomplete, so a miss there
|
|
91
|
+
// The scope column may be incomplete, so a miss there doesn't establish absence.
|
|
91
92
|
if (scope?.locality && this.#byNameLocality && this.#byNameLocality.get(norm, foldStreetSurface(scope.locality))) {
|
|
92
93
|
return true
|
|
93
94
|
}
|