@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
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The one record every address-source adapter emits, and the key-table builder reads.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ADMIN_HIERARCHY_TAGS } from "@mailwoman/codex/component"
|
|
9
|
+
|
|
10
|
+
import { type NameKey, normalizeLocalityForKey, type RouteKey, type StreetKey } from "#street/normalize"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The hierarchy level a place name on an address record states, as the encoder model tags it.
|
|
14
|
+
*
|
|
15
|
+
* A record stores its postcode in {@link AddressRecord.postcode}, so `postcode` is never a name's level.
|
|
16
|
+
*/
|
|
17
|
+
export type AddressNameLevel = Exclude<(typeof ADMIN_HIERARCHY_TAGS)[number], "postcode">
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* How an adapter arrived at a place name.
|
|
21
|
+
*/
|
|
22
|
+
export const AddressNameForm = {
|
|
23
|
+
/**
|
|
24
|
+
* The publisher's own value, such as NAD's `Inc_Muni` `Town of Madison`.
|
|
25
|
+
*/
|
|
26
|
+
Written: "written",
|
|
27
|
+
/**
|
|
28
|
+
* The written municipality without its legal-form words, such as `Madison` from `Town of Madison`,
|
|
29
|
+
* or the city an arrondissement belongs to, such as `Paris` from `Paris 3e Arrondissement`.
|
|
30
|
+
*
|
|
31
|
+
* The per-source table of those words is data, never a branch in the adapter.
|
|
32
|
+
*/
|
|
33
|
+
Bare: "bare",
|
|
34
|
+
/**
|
|
35
|
+
* The postal city the publisher states, such as NAD's `Post_City`, or the postcode
|
|
36
|
+
* gazetteer's city for the record's postcode.
|
|
37
|
+
*/
|
|
38
|
+
Postal: "postal",
|
|
39
|
+
} as const
|
|
40
|
+
|
|
41
|
+
export type AddressNameForm = (typeof AddressNameForm)[keyof typeof AddressNameForm]
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* One place name on an address record.
|
|
45
|
+
*/
|
|
46
|
+
export interface AddressName {
|
|
47
|
+
level: AddressNameLevel
|
|
48
|
+
form: AddressNameForm
|
|
49
|
+
/**
|
|
50
|
+
* The name as the record states it, kept for display.
|
|
51
|
+
*/
|
|
52
|
+
value: string
|
|
53
|
+
/**
|
|
54
|
+
* Shared `normalizeLocalityForKey` of `value`, the form a key table stores and a lookup probes.
|
|
55
|
+
*/
|
|
56
|
+
key: NameKey
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Collects a record's names in the order an adapter states them.
|
|
61
|
+
*
|
|
62
|
+
* Each value is trimmed and keyed with `normalizeLocalityForKey`.
|
|
63
|
+
* A value whose key is empty, or whose level and key an earlier name already holds, is skipped.
|
|
64
|
+
*/
|
|
65
|
+
export function collectAddressNames(): {
|
|
66
|
+
names: AddressName[]
|
|
67
|
+
add(level: AddressNameLevel, form: AddressNameForm, value: string | null | undefined): void
|
|
68
|
+
} {
|
|
69
|
+
const names: AddressName[] = []
|
|
70
|
+
const seen = new Set<string>()
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
names,
|
|
74
|
+
add(level, form, value) {
|
|
75
|
+
const trimmed = value?.trim()
|
|
76
|
+
|
|
77
|
+
if (!trimmed) return
|
|
78
|
+
|
|
79
|
+
const key = normalizeLocalityForKey(trimmed)
|
|
80
|
+
const identity = `${level}|${key}`
|
|
81
|
+
|
|
82
|
+
if (!key || seen.has(identity)) return
|
|
83
|
+
|
|
84
|
+
seen.add(identity)
|
|
85
|
+
names.push({ level, form, value: trimmed, key })
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* One address point from one source, with every name tagged by its hierarchy level.
|
|
92
|
+
*
|
|
93
|
+
* Two sources' records for one address stay two records.
|
|
94
|
+
* The reader returns both with their sources.
|
|
95
|
+
*/
|
|
96
|
+
export interface AddressRecord {
|
|
97
|
+
/**
|
|
98
|
+
* The wire source id the register maps, such as `usgov-nad` or `openaddresses:us/wi/statewide`.
|
|
99
|
+
*/
|
|
100
|
+
source: string
|
|
101
|
+
/**
|
|
102
|
+
* The publisher's own id for the point, such as NAD's normalized `UUID`.
|
|
103
|
+
*
|
|
104
|
+
* An adapter whose publisher states none writes a digest of the rendered address.
|
|
105
|
+
*/
|
|
106
|
+
sourceRecordID: string
|
|
107
|
+
/**
|
|
108
|
+
* The ISO 3166-1 alpha-2 code of the country the point lies in.
|
|
109
|
+
*/
|
|
110
|
+
country: string
|
|
111
|
+
/**
|
|
112
|
+
* The ISO 3166-2 code of the first-level subdivision the point lies in, such as `US-WI`
|
|
113
|
+
* or `FR-IDF`, or `null` when the source states none.
|
|
114
|
+
*
|
|
115
|
+
* A country large enough to be split is written one file per subdivision.
|
|
116
|
+
*/
|
|
117
|
+
subdivision: string | null
|
|
118
|
+
/**
|
|
119
|
+
* The house number lower-cased and kept as text, since `123-A` and `12 1/2` are numbers.
|
|
120
|
+
*/
|
|
121
|
+
number: string
|
|
122
|
+
unit: string | null
|
|
123
|
+
/**
|
|
124
|
+
* The street as the publisher writes it, kept for display.
|
|
125
|
+
*/
|
|
126
|
+
streetRaw: string
|
|
127
|
+
streetKey: StreetKey
|
|
128
|
+
routeKey: RouteKey
|
|
129
|
+
postcode: string | null
|
|
130
|
+
/**
|
|
131
|
+
* Every place name the record states or an adapter derived, at every level, in no fixed order.
|
|
132
|
+
*
|
|
133
|
+
* A level may hold several names, such as a municipality's written and bare forms.
|
|
134
|
+
*/
|
|
135
|
+
names: readonly AddressName[]
|
|
136
|
+
/**
|
|
137
|
+
* The publisher's own code for the municipality, such as BAN's `code_insee` (`75103`),
|
|
138
|
+
* or `null` when the publisher states none.
|
|
139
|
+
*
|
|
140
|
+
* The key-table build joins it to the Who's On First place that holds the same code.
|
|
141
|
+
*/
|
|
142
|
+
adminCode: string | null
|
|
143
|
+
lat: number
|
|
144
|
+
lon: number
|
|
145
|
+
/**
|
|
146
|
+
* How the publisher placed the point, such as NAD's `Placement` (`Structure - Rooftop`),
|
|
147
|
+
* or `null` when unstated.
|
|
148
|
+
*/
|
|
149
|
+
placement: string | null
|
|
150
|
+
/**
|
|
151
|
+
* The authority that assigned the address, such as NAD's `AddAuth` (`co.adams.wi.us`),
|
|
152
|
+
* or `null` when unstated.
|
|
153
|
+
*/
|
|
154
|
+
authority: string | null
|
|
155
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Counts the distinct addresses one source places at one point.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The SQL that lists every stacked point of an `address` table: each source and point,
|
|
10
|
+
* rounded to 1e-5 degrees, with `n`, the distinct street-and-number pairs the source
|
|
11
|
+
* places there, for points where `n` exceeds `minimum`.
|
|
12
|
+
*
|
|
13
|
+
* It selects `source_id`, `la`, `lo` and `n`.
|
|
14
|
+
* The layer build, its duplicate rule and the pair sampler all read stacks through it,
|
|
15
|
+
* so each counts a stack the same way.
|
|
16
|
+
*/
|
|
17
|
+
export function addressPointStacksSQL(minimum: number): string {
|
|
18
|
+
return `SELECT source_id, round(lat, 5) AS la, round(lon, 5) AS lo, count(DISTINCT street_raw || '|' || number) AS n
|
|
19
|
+
FROM address GROUP BY 1, 2, 3 HAVING n > ${Math.trunc(minimum)}`
|
|
20
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Refuses an address record whose point lies outside the bounding box of the subdivision it states.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { type LatLonBounds, latLonBoundsContain } from "@mailwoman/spatial/bbox"
|
|
9
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
10
|
+
import type { PathBuilderLike } from "path-ts"
|
|
11
|
+
|
|
12
|
+
import type { AddressRecord } from "#address/record"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The reason a record outside its subdivision's box is refused under.
|
|
16
|
+
*/
|
|
17
|
+
export const OUTSIDE_SUBDIVISION = "outside-subdivision"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A record check over one Who's On First admin database, closed on dispose.
|
|
21
|
+
*/
|
|
22
|
+
export interface SubdivisionBoundsCheck extends Disposable {
|
|
23
|
+
/**
|
|
24
|
+
* Returns {@linkcode OUTSIDE_SUBDIVISION} for a record whose point lies outside
|
|
25
|
+
* the bounding box of its stated subdivision, or `null`.
|
|
26
|
+
*
|
|
27
|
+
* A record that states no subdivision, or whose subdivision the database
|
|
28
|
+
* holds no current region for, is kept.
|
|
29
|
+
*/
|
|
30
|
+
refuse(record: AddressRecord): string | null
|
|
31
|
+
/**
|
|
32
|
+
* The subdivisions the database held no current region for, so their records went unchecked.
|
|
33
|
+
*/
|
|
34
|
+
readonly unchecked: ReadonlySet<string>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Opens a check that reads each subdivision's box from a Who's On First admin database.
|
|
39
|
+
*
|
|
40
|
+
* The region is found by its `iso:code` concordance (`US-WI`), so the check reads
|
|
41
|
+
* every country's subdivisions the same way.
|
|
42
|
+
* Each box is read once and kept.
|
|
43
|
+
*/
|
|
44
|
+
export function openSubdivisionBoundsCheck(adminDatabasePath: PathBuilderLike): SubdivisionBoundsCheck {
|
|
45
|
+
const db = new DatabaseClient<unknown>(adminDatabasePath, { readOnly: true })
|
|
46
|
+
|
|
47
|
+
const read = db.prepare(
|
|
48
|
+
`SELECT s.min_latitude AS minLat, s.max_latitude AS maxLat, s.min_longitude AS minLon, s.max_longitude AS maxLon
|
|
49
|
+
FROM concordances c JOIN spr s ON s.id = c.id
|
|
50
|
+
WHERE c.other_source = 'iso:code' AND c.other_id = ? AND s.placetype = 'region' AND s.is_current = 1
|
|
51
|
+
ORDER BY s.max_latitude - s.min_latitude DESC LIMIT 1`
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
const boxes = new Map<string, LatLonBounds | null>()
|
|
55
|
+
const unchecked = new Set<string>()
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
unchecked,
|
|
59
|
+
refuse(record) {
|
|
60
|
+
const subdivision = record.subdivision
|
|
61
|
+
|
|
62
|
+
if (!subdivision) return null
|
|
63
|
+
|
|
64
|
+
let box = boxes.get(subdivision)
|
|
65
|
+
|
|
66
|
+
if (box === undefined) {
|
|
67
|
+
box = (read.get(subdivision) as LatLonBounds | undefined) ?? null
|
|
68
|
+
boxes.set(subdivision, box)
|
|
69
|
+
|
|
70
|
+
if (!box) {
|
|
71
|
+
unchecked.add(subdivision)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!box) return null
|
|
76
|
+
|
|
77
|
+
return latLonBoundsContain(box, record.lat, record.lon) ? null : OUTSIDE_SUBDIVISION
|
|
78
|
+
},
|
|
79
|
+
[Symbol.dispose]: () => db[Symbol.dispose](),
|
|
80
|
+
}
|
|
81
|
+
}
|
package/lib/address.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 "#address/point"
|
|
8
5
|
export * from "#address/point/interpolation"
|
package/lib/ancestry/backfill.ts
CHANGED
|
@@ -1,76 +1,47 @@
|
|
|
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
|
+
* Repair the truncated ancestry left by the `parent_id` closure.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
+
* Must run after `populateAncestors` and before the build freezes.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import type { WOFFeature } from "@mailwoman/gazetteer/whosonfirst"
|
|
10
11
|
import { hierarchyAncestorsInAnyBranch } from "@mailwoman/gazetteer/whosonfirst/hierarchy"
|
|
11
12
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
12
|
-
import { PathBuilder, type PathBuilderLike } from "path-ts"
|
|
13
|
-
import { Globerator } from "spliterator/node/fs"
|
|
14
13
|
|
|
15
14
|
import type { WOFDatabase } from "#schema"
|
|
16
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Reads the WOF record with an id, such as a primary-key read of the WOF record store, or returns `null`.
|
|
18
|
+
*/
|
|
19
|
+
export type WOFFeatureReader = (
|
|
20
|
+
id: number
|
|
21
|
+
) => Pick<WOFFeature, "properties"> | null | Promise<Pick<WOFFeature, "properties"> | null>
|
|
22
|
+
|
|
17
23
|
const TOP_PLACETYPES = new Set(["country", "continent", "empire", "ocean", "marinearea", "planet"])
|
|
18
24
|
|
|
19
25
|
export interface AncestryBackfillResult {
|
|
20
26
|
placesFixed: number
|
|
21
27
|
rowsAdded: number
|
|
22
28
|
/**
|
|
23
|
-
* Candidates
|
|
29
|
+
* Candidates the reader returned no record for (non-WOF backfilled places or absent repos),
|
|
24
30
|
* skipped rather than treated as an error.
|
|
25
31
|
*/
|
|
26
32
|
noGeojson: number
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
/**
|
|
30
|
-
* Discover the `data` directories under a WOF repos root that hold attached geojson,
|
|
31
|
-
* accepting both the nested lab layout and a flat layout at most two directory levels deep.
|
|
32
|
-
*/
|
|
33
|
-
export async function discoverAdminDataRoots(reposRoot: PathBuilderLike): Promise<PathBuilder[]> {
|
|
34
|
-
const roots: PathBuilder[] = []
|
|
35
|
-
|
|
36
|
-
const visit = async (dir: PathBuilder, depth: number): Promise<void> => {
|
|
37
|
-
if (depth > 2) return
|
|
38
|
-
|
|
39
|
-
let names: string[]
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
names = (await Globerator.from("*", { cwd: dir, withFileTypes: true, onlyFiles: false }).toArray())
|
|
43
|
-
.filter((entry) => entry.isDirectory())
|
|
44
|
-
.map((entry) => entry.name)
|
|
45
|
-
} catch {
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
for (const name of names) {
|
|
50
|
-
const child = dir(name)
|
|
51
|
-
|
|
52
|
-
if (name === "data") {
|
|
53
|
-
roots.push(child)
|
|
54
|
-
} else if (name.startsWith("whosonfirst-data")) {
|
|
55
|
-
await visit(child, depth + 1)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
await visit(PathBuilder.from(reposRoot), 0)
|
|
61
|
-
|
|
62
|
-
return roots
|
|
63
|
-
}
|
|
64
|
-
|
|
65
35
|
/**
|
|
66
36
|
* Insert missing ancestor rows for places whose ancestry chain ended before reaching a country.
|
|
67
37
|
*
|
|
68
|
-
* The function reads `wof:hierarchy`
|
|
38
|
+
* The function reads each candidate's `wof:hierarchy` through `readFeature`
|
|
39
|
+
* and runs in one transaction under the caller's connection.
|
|
69
40
|
* `opts.maxID` bounds the scan to avoid probing synthetic-id Overture and GeoNames rows.
|
|
70
41
|
*/
|
|
71
42
|
export async function backfillAncestorsFromHierarchy(
|
|
72
43
|
db: DatabaseClient<WOFDatabase>,
|
|
73
|
-
|
|
44
|
+
readFeature: WOFFeatureReader,
|
|
74
45
|
opts: { maxID?: number } = {}
|
|
75
46
|
): Promise<AncestryBackfillResult> {
|
|
76
47
|
const maxID = opts.maxID ?? Number.MAX_SAFE_INTEGER
|
|
@@ -123,7 +94,7 @@ export async function backfillAncestorsFromHierarchy(
|
|
|
123
94
|
|
|
124
95
|
for (const { id, placetype } of candidates) {
|
|
125
96
|
if (placetype && TOP_PLACETYPES.has(placetype)) continue
|
|
126
|
-
const gj = await
|
|
97
|
+
const gj = await readFeature(id)
|
|
127
98
|
const hierarchy = gj?.properties?.["wof:hierarchy"]
|
|
128
99
|
|
|
129
100
|
if (!hierarchy || !hierarchy.length) {
|
package/lib/ancestry.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
* The shared ancestor-lineage walk over the WOF `ancestors` table: one place's
|
|
6
|
+
* containment chain joined with `spr` for canonical names and centroids,
|
|
7
|
+
* ordered nearest-first with the deepest placetype first and the country last.
|
|
5
8
|
*
|
|
6
|
-
* The
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* The reverse geocoder and `WOFSQLitePlaceLookup.ancestors()` share this walk.
|
|
10
|
+
* Placetype specificity lives here in `PLACETYPE_DEPTH`, a single TypeScript map that extends
|
|
11
|
+
* below `localadmin` so locality, borough, neighborhood and microhood rank correctly.
|
|
9
12
|
*
|
|
10
|
-
*
|
|
11
|
-
* specificity lives here in `PLACETYPE_DEPTH`, a single TypeScript map that extends below
|
|
12
|
-
* `localadmin` so locality, borough, neighborhood and microhood rank correctly. Forward
|
|
13
|
-
* resolution rarely sees those as ancestor placetypes, while reverse geocoding always does.
|
|
13
|
+
* Forward resolution rarely sees those as ancestor placetypes, while reverse geocoding always does.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { allRows } from "@mailwoman/core/utils"
|
package/lib/build/candidate.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 { COUNTRY_POPULATION } from "@mailwoman/codex/country"
|
|
8
5
|
import { bareAdminName } from "@mailwoman/codex/country/bare-admin-names"
|
|
@@ -20,7 +17,9 @@ import { stageCountryDisplayNames } from "#candidate/country-display-names"
|
|
|
20
17
|
import { foldExtract } from "#candidate/extract-fold"
|
|
21
18
|
import { createCandidateFTS } from "#candidate/fts"
|
|
22
19
|
import { IMPORTANCE_JOIN_RADIUS_KM, loadImportanceIndex } from "#candidate/importance"
|
|
20
|
+
import { applyCandidateKeyFold, type CandidateKeyFold } from "#candidate/key-fold"
|
|
23
21
|
import { GLOSS_KEY_THRESHOLD, stampNameRoles } from "#candidate/name-roles"
|
|
22
|
+
import { refuseNicknamesOfNamesakes } from "#candidate/nickname-namesakes"
|
|
24
23
|
import type { PlaceAttrs } from "#candidate/place-attrs"
|
|
25
24
|
import {
|
|
26
25
|
CANDIDATE_COLUMNS,
|
|
@@ -30,7 +29,6 @@ import {
|
|
|
30
29
|
} from "#candidate/schema"
|
|
31
30
|
import { createCapitalTable } from "#capital-schema"
|
|
32
31
|
import type { CapitalPoint } from "#capitals"
|
|
33
|
-
import { resurrectCurrencyHoles } from "#currency-backfill"
|
|
34
32
|
import type { WOFDatabase } from "#schema"
|
|
35
33
|
import { normalizeLocalityForKey } from "#street/normalize"
|
|
36
34
|
|
|
@@ -87,25 +85,6 @@ export interface BuildCandidateOptions {
|
|
|
87
85
|
*/
|
|
88
86
|
importance?: PathBuilderLike
|
|
89
87
|
|
|
90
|
-
/**
|
|
91
|
-
* Settings for restoring deprecated WOF places that have no successor and have a GeoNames attestation.
|
|
92
|
-
*
|
|
93
|
-
* A deprecated place is restored only when no live row of the same name lies within 10 km and
|
|
94
|
-
* a GeoNames populated place with the same folded name and at least 1,000 people lies within 10 km.
|
|
95
|
-
* Countries without `<cc>.txt` under `geonamesDir` are skipped and reported.
|
|
96
|
-
*/
|
|
97
|
-
currencyBackfill?: {
|
|
98
|
-
geonamesDir: PathBuilderLike
|
|
99
|
-
countries: readonly string[]
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The deprecated placetypes eligible for restoration.
|
|
103
|
-
*
|
|
104
|
-
* @defaultValue `locality`
|
|
105
|
-
*/
|
|
106
|
-
deadPlacetypes?: readonly string[]
|
|
107
|
-
}
|
|
108
|
-
|
|
109
88
|
/**
|
|
110
89
|
* Receives a phase name and a message as each build step runs.
|
|
111
90
|
*/
|
|
@@ -119,6 +98,14 @@ export interface BuildCandidateOptions {
|
|
|
119
98
|
* @defaultValue {@linkcode GLOSS_KEY_THRESHOLD}
|
|
120
99
|
*/
|
|
121
100
|
glossKeyThreshold?: number
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Folds applied to every `name_key` after `normalizeLocalityForKey`, recorded in
|
|
104
|
+
* the artifact so its reader folds query keys the same way.
|
|
105
|
+
*
|
|
106
|
+
* @defaultValue none
|
|
107
|
+
*/
|
|
108
|
+
keyFolds?: readonly CandidateKeyFold[]
|
|
122
109
|
}
|
|
123
110
|
|
|
124
111
|
/**
|
|
@@ -129,6 +116,11 @@ export interface BuildCandidateResult {
|
|
|
129
116
|
places: number
|
|
130
117
|
primaries: number
|
|
131
118
|
aliases: number
|
|
119
|
+
/**
|
|
120
|
+
* The count of alias rows staged as a name's key with its apostrophe-like marks
|
|
121
|
+
* removed (`hawaii` for `Hawaiʻi`), which `aliases` excludes.
|
|
122
|
+
*/
|
|
123
|
+
markFreeAliases: number
|
|
132
124
|
|
|
133
125
|
/**
|
|
134
126
|
* The count of region aliases dropped because another region in the same
|
|
@@ -137,6 +129,14 @@ export interface BuildCandidateResult {
|
|
|
137
129
|
* The count is always zero for a source without a `names` table.
|
|
138
130
|
*/
|
|
139
131
|
regionOfficialRefused: number
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The count of alias rows from a colloquial or unclassified name dropped
|
|
135
|
+
* because a populated place holds the same key by a real name.
|
|
136
|
+
*
|
|
137
|
+
* The count is always zero for a source without a `names` table.
|
|
138
|
+
*/
|
|
139
|
+
nicknameRefused: number
|
|
140
140
|
abbrevs: number
|
|
141
141
|
postcodes: number
|
|
142
142
|
|
|
@@ -420,32 +420,11 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
420
420
|
}).toLocaleString()} bare admin names`
|
|
421
421
|
)
|
|
422
422
|
|
|
423
|
-
if (opts.currencyBackfill) {
|
|
424
|
-
const nBackfill = await resurrectCurrencyHoles({
|
|
425
|
-
src,
|
|
426
|
-
tx: kdb,
|
|
427
|
-
geonamesDir: opts.currencyBackfill.geonamesDir,
|
|
428
|
-
countries: opts.currencyBackfill.countries,
|
|
429
|
-
...(opts.currencyBackfill.deadPlacetypes ? { deadPlacetypes: opts.currencyBackfill.deadPlacetypes } : {}),
|
|
430
|
-
attrs,
|
|
431
|
-
ccID,
|
|
432
|
-
ptID,
|
|
433
|
-
regionOf,
|
|
434
|
-
importance,
|
|
435
|
-
stageRow,
|
|
436
|
-
progress,
|
|
437
|
-
})
|
|
438
|
-
|
|
439
|
-
progress("currency-backfill", `${nBackfill.toLocaleString()} resurrections staged`)
|
|
440
|
-
} else {
|
|
441
|
-
progress("currency-backfill", "not configured — deprecated-no-successor holes stay dead (#1737)")
|
|
442
|
-
}
|
|
443
|
-
|
|
444
423
|
progress("aliases", "exploding alias bags")
|
|
445
424
|
|
|
446
425
|
const iso2ByCountryID = new Map([...ccodes].map(([code, id]) => [id, code]))
|
|
447
426
|
|
|
448
|
-
const { nAlias, nBare, keyCounts, regionOfficialRefused } = explodeAliasBags(src, kdb, attrs, stageRow, {
|
|
427
|
+
const { nAlias, nBare, nMarkFree, keyCounts, regionOfficialRefused } = explodeAliasBags(src, kdb, attrs, stageRow, {
|
|
449
428
|
regionPlacetypeID: ptID("region"),
|
|
450
429
|
ccID,
|
|
451
430
|
bareName: (countryID, alias) => bareAdminName(iso2ByCountryID.get(countryID) ?? "", alias),
|
|
@@ -453,7 +432,8 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
453
432
|
|
|
454
433
|
progress(
|
|
455
434
|
"aliases",
|
|
456
|
-
`${nAlias.toLocaleString()} aliases; ${nBare.toLocaleString()} bare admin aliases` +
|
|
435
|
+
`${nAlias.toLocaleString()} aliases; ${nBare.toLocaleString()} bare admin aliases; ` +
|
|
436
|
+
`${nMarkFree.toLocaleString()} mark-free aliases` +
|
|
457
437
|
(regionOfficialRefused
|
|
458
438
|
? `; ${regionOfficialRefused.toLocaleString()} region aliases refused as another region's official name`
|
|
459
439
|
: "")
|
|
@@ -477,6 +457,14 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
477
457
|
kdb.exec("COMMIT")
|
|
478
458
|
progress("abbrevs", `${nAbbr.toLocaleString()} abbrevs`)
|
|
479
459
|
|
|
460
|
+
const nicknames = refuseNicknamesOfNamesakes(src, kdb, attrs)
|
|
461
|
+
|
|
462
|
+
progress(
|
|
463
|
+
"nicknames",
|
|
464
|
+
`${nicknames.rows.toLocaleString()} colloquial or unclassified alias rows refused on ` +
|
|
465
|
+
`${nicknames.keys.toLocaleString()} keys a populated place holds by a real name`
|
|
466
|
+
)
|
|
467
|
+
|
|
480
468
|
const roles = stampNameRoles({
|
|
481
469
|
src,
|
|
482
470
|
out: kdb,
|
|
@@ -585,6 +573,12 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
585
573
|
kdb.exec(`INSERT OR IGNORE INTO candidate (${cols}) SELECT ${cols} FROM cand_stage ORDER BY ${keyOrder};`)
|
|
586
574
|
await kdb.schema.dropTable("cand_stage").execute()
|
|
587
575
|
|
|
576
|
+
for (const fold of opts.keyFolds ?? []) {
|
|
577
|
+
const { rekeyed, merged } = await applyCandidateKeyFold(kdb, fold)
|
|
578
|
+
|
|
579
|
+
progress("key-fold", `${fold}: ${rekeyed.toLocaleString()} rows rekeyed, ${merged.toLocaleString()} merged`)
|
|
580
|
+
}
|
|
581
|
+
|
|
588
582
|
progress("fts", "building FTS5-trigram fuzzy index")
|
|
589
583
|
createCandidateFTS(kdb)
|
|
590
584
|
|
|
@@ -601,7 +595,9 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
601
595
|
places: attrs.size,
|
|
602
596
|
primaries: nPrim,
|
|
603
597
|
aliases: nAlias,
|
|
598
|
+
markFreeAliases: nMarkFree,
|
|
604
599
|
regionOfficialRefused,
|
|
600
|
+
nicknameRefused: nicknames.rows,
|
|
605
601
|
abbrevs: nAbbr,
|
|
606
602
|
postcodes: nPostcode,
|
|
607
603
|
postcodeAliases: nPostcodeAlias,
|
|
@@ -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
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
5
|
* @file Populations the gazetteer records at a fraction of their size, corrected against the record's own concordance.
|
|
6
6
|
*
|
|
7
|
-
* This file records corrections for review. The build
|
|
7
|
+
* This file records corrections for review. The build mustn't rewrite populations from a
|
|
8
8
|
* same-name-parent ratio. The detector cannot distinguish a district's mis-recorded namesake
|
|
9
9
|
* city from a small village with the district name. Both places are real.
|
|
10
10
|
*
|
package/lib/build/slim.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 { statPath, pathExists } from "@mailwoman/core/fs/readers/stat"
|
|
8
5
|
import { temporaryDirectory } from "@mailwoman/core/fs/temporary"
|
|
@@ -161,7 +158,7 @@ export async function buildSlimWOFDatabase(opts: BuildSlimOptions): Promise<Buil
|
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
// `place_search` and `place_bbox` derive purely from `spr` + `names`, and the
|
|
164
|
-
// population aux table
|
|
161
|
+
// population aux table isn't rebuilt because it was copied verbatim.
|
|
165
162
|
progress("fts", "building place_search / place_bbox on slim DB")
|
|
166
163
|
|
|
167
164
|
buildPlaceSearchFTS(out, {
|