@mailwoman/resolver-wof-sqlite 11.1.0 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/lib/address/duplicate.ts +1 -1
- package/lib/address/keys/attribution.ts +6 -1
- package/lib/address/keys/build.ts +1 -1
- package/lib/address/keys/layout.ts +27 -1
- package/lib/address/keys/lookup.ts +2 -2
- package/lib/address/keys/point-lookup.ts +2 -2
- package/lib/address/number-forms.ts +4 -6
- package/lib/address/point/interpolation.ts +11 -3
- package/lib/address/point/schema.ts +1 -1
- package/lib/address/point.ts +15 -14
- package/lib/address/record.ts +1 -1
- package/lib/ancestry/backfill.ts +13 -43
- package/lib/build/candidate.ts +171 -35
- package/lib/build/slim.ts +4 -1
- package/lib/build/sources.ts +50 -0
- package/lib/candidate/alias-bags.ts +74 -20
- package/lib/candidate/ancestors/schema.ts +1 -1
- package/lib/candidate/ancestors/sidecar.ts +13 -2
- package/lib/candidate/bare-admin-names.ts +1 -1
- package/lib/{capital-schema.ts → candidate/capital-schema.ts} +3 -3
- package/lib/{capitals.ts → candidate/capitals.ts} +1 -1
- package/lib/candidate/country-display-names.ts +1 -1
- package/lib/candidate/{extract-fold.ts → extract-rows.ts} +7 -4
- package/lib/candidate/importance.ts +90 -11
- package/lib/candidate/key-fold.ts +132 -0
- package/lib/candidate/lookup.ts +101 -60
- package/lib/candidate/name-roles.ts +1 -1
- package/lib/candidate/nickname-namesakes.ts +147 -0
- package/lib/candidate/overture-twins.ts +83 -0
- package/lib/candidate/place-attrs.ts +2 -2
- package/lib/candidate/postcode-browse.ts +173 -0
- package/lib/candidate/schema.ts +43 -2
- package/lib/candidate/scoring.ts +4 -4
- package/lib/convention.ts +1 -1
- package/lib/env.ts +15 -3
- package/lib/fst/binary-matcher.ts +26 -41
- package/lib/fst/builder.ts +8 -6
- package/lib/fst/deserialize-web.ts +1 -1
- package/lib/fst/format.ts +144 -7
- package/lib/fst/freshness.ts +2 -2
- package/lib/fst/serialize.ts +93 -64
- package/lib/fts/query.ts +1 -1
- package/lib/{search-fetch.ts → fts/search-fetch.ts} +2 -2
- package/lib/geonames/aliases.ts +42 -45
- package/lib/geonames/postal.ts +3 -3
- package/lib/index.ts +20 -17
- package/lib/{postal/city → labels/locality/postal-city}/alias/lookup.ts +1 -1
- package/lib/{postal/city → labels/locality/postal-city}/candidate-schema.ts +1 -1
- package/lib/labels/locality.ts +6 -0
- package/lib/{region-keys.ts → labels/region.ts} +5 -2
- package/lib/{street → labels/street}/centroid/schema.ts +1 -1
- package/lib/{street → labels/street}/centroid.ts +7 -7
- package/lib/{interpolation.ts → labels/street/interpolation.ts} +12 -4
- package/lib/labels/street/locale.ts +117 -0
- package/lib/{street → labels/street}/morphology/fst/loader.ts +1 -1
- package/lib/{street → labels/street}/name-lookup.ts +2 -0
- package/lib/{street → labels/street}/normalize.ts +284 -133
- package/lib/{street → labels/street}/segment-schema.ts +1 -1
- package/lib/{street → labels/street}/table.ts +1 -1
- package/lib/labels/street.ts +11 -0
- package/lib/landmark/rows.ts +1 -1
- package/lib/lookup/browse.ts +304 -0
- package/lib/{extracts.ts → lookup/extracts.ts} +1 -1
- package/lib/lookup/former-divisions.ts +183 -0
- package/lib/{postcode-point-lookup.ts → lookup/postcode-point.ts} +5 -0
- package/lib/{reverse.ts → lookup/reverse.ts} +4 -4
- package/lib/{types.ts → lookup/types.ts} +10 -0
- package/lib/lookup.ts +21 -31
- package/lib/poi/schema.ts +1 -1
- package/lib/{primary-preference.ts → ranking/primary-preference.ts} +45 -2
- package/lib/schema/importance-source.ts +210 -0
- package/lib/schema/overture-match.ts +79 -0
- package/lib/{place-importance-schema.ts → schema/place-importance.ts} +86 -0
- package/lib/schema.ts +3 -3
- package/lib/sqlite/convention-source.ts +1 -1
- package/lib/uprn/existence.ts +2 -0
- package/lib/{weights-overlay-linker.ts → weights/overlay-linker.ts} +244 -103
- package/out/address/duplicate.js +1 -1
- package/out/address/duplicate.js.map +1 -1
- package/out/address/keys/attribution.d.ts +4 -0
- package/out/address/keys/attribution.d.ts.map +1 -1
- package/out/address/keys/attribution.js +5 -1
- package/out/address/keys/attribution.js.map +1 -1
- package/out/address/keys/build.d.ts.map +1 -1
- package/out/address/keys/build.js +1 -1
- package/out/address/keys/build.js.map +1 -1
- package/out/address/keys/layout.d.ts +18 -1
- package/out/address/keys/layout.d.ts.map +1 -1
- package/out/address/keys/layout.js +23 -1
- package/out/address/keys/layout.js.map +1 -1
- package/out/address/keys/lookup.js +2 -2
- package/out/address/keys/lookup.js.map +1 -1
- package/out/address/keys/point-lookup.d.ts.map +1 -1
- package/out/address/keys/point-lookup.js +2 -2
- package/out/address/keys/point-lookup.js.map +1 -1
- package/out/address/number-forms.d.ts +1 -1
- package/out/address/number-forms.d.ts.map +1 -1
- package/out/address/number-forms.js +4 -5
- package/out/address/number-forms.js.map +1 -1
- package/out/address/point/interpolation.d.ts +1 -1
- package/out/address/point/interpolation.d.ts.map +1 -1
- package/out/address/point/interpolation.js +9 -2
- package/out/address/point/interpolation.js.map +1 -1
- package/out/address/point/schema.d.ts +1 -1
- package/out/address/point/schema.d.ts.map +1 -1
- package/out/address/point.d.ts +4 -5
- package/out/address/point.d.ts.map +1 -1
- package/out/address/point.js +11 -11
- package/out/address/point.js.map +1 -1
- package/out/address/record.d.ts +1 -1
- package/out/address/record.d.ts.map +1 -1
- package/out/address/record.js +1 -1
- package/out/address/record.js.map +1 -1
- package/out/ancestry/backfill.d.ts +14 -9
- package/out/ancestry/backfill.d.ts.map +1 -1
- package/out/ancestry/backfill.js +4 -42
- package/out/ancestry/backfill.js.map +1 -1
- package/out/build/candidate.d.ts +46 -1
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +82 -31
- package/out/build/candidate.js.map +1 -1
- package/out/build/slim.d.ts.map +1 -1
- package/out/build/slim.js +4 -1
- package/out/build/slim.js.map +1 -1
- package/out/build/sources.d.ts +32 -0
- package/out/build/sources.d.ts.map +1 -0
- package/out/build/sources.js +35 -0
- package/out/build/sources.js.map +1 -0
- package/out/candidate/alias-bags.d.ts +8 -3
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +63 -17
- package/out/candidate/alias-bags.js.map +1 -1
- package/out/candidate/ancestors/schema.d.ts +1 -1
- package/out/candidate/ancestors/schema.d.ts.map +1 -1
- package/out/candidate/ancestors/sidecar.d.ts +0 -3
- package/out/candidate/ancestors/sidecar.d.ts.map +1 -1
- package/out/candidate/ancestors/sidecar.js +16 -2
- package/out/candidate/ancestors/sidecar.js.map +1 -1
- package/out/candidate/bare-admin-names.js +1 -1
- package/out/candidate/bare-admin-names.js.map +1 -1
- package/out/{capital-schema.d.ts → candidate/capital-schema.d.ts} +2 -2
- package/out/candidate/capital-schema.d.ts.map +1 -0
- package/out/{capital-schema.js → candidate/capital-schema.js} +2 -2
- package/out/candidate/capital-schema.js.map +1 -0
- package/out/candidate/capitals.d.ts.map +1 -0
- package/out/{capitals.js → candidate/capitals.js} +1 -1
- package/out/candidate/capitals.js.map +1 -0
- package/out/candidate/country-display-names.js +1 -1
- package/out/candidate/country-display-names.js.map +1 -1
- package/out/{coverage-manifest-schema.d.ts → candidate/coverage-manifest.d.ts} +1 -1
- package/out/candidate/coverage-manifest.d.ts.map +1 -0
- package/out/{coverage-manifest-schema.js → candidate/coverage-manifest.js} +1 -1
- package/out/candidate/coverage-manifest.js.map +1 -0
- package/out/candidate/{extract-fold.d.ts → extract-rows.d.ts} +2 -2
- package/out/candidate/extract-rows.d.ts.map +1 -0
- package/out/candidate/{extract-fold.js → extract-rows.js} +8 -5
- package/out/candidate/extract-rows.js.map +1 -0
- package/out/candidate/importance.d.ts +34 -3
- package/out/candidate/importance.d.ts.map +1 -1
- package/out/candidate/importance.js +57 -11
- 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 +5 -1
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +80 -54
- package/out/candidate/lookup.js.map +1 -1
- package/out/candidate/name-roles.d.ts.map +1 -1
- package/out/candidate/name-roles.js +1 -1
- package/out/candidate/name-roles.js.map +1 -1
- package/out/candidate/nickname-namesakes.d.ts +28 -0
- package/out/candidate/nickname-namesakes.d.ts.map +1 -0
- package/out/candidate/nickname-namesakes.js +109 -0
- package/out/candidate/nickname-namesakes.js.map +1 -0
- package/out/candidate/overture-twins.d.ts +30 -0
- package/out/candidate/overture-twins.d.ts.map +1 -0
- package/out/candidate/overture-twins.js +40 -0
- package/out/candidate/overture-twins.js.map +1 -0
- package/out/candidate/place-attrs.d.ts +2 -2
- package/out/candidate/postcode-browse.d.ts +36 -0
- package/out/candidate/postcode-browse.d.ts.map +1 -0
- package/out/candidate/postcode-browse.js +119 -0
- package/out/candidate/postcode-browse.js.map +1 -0
- package/out/candidate/schema.d.ts +30 -2
- package/out/candidate/schema.d.ts.map +1 -1
- package/out/candidate/schema.js +29 -0
- package/out/candidate/schema.js.map +1 -1
- package/out/candidate/scoring.d.ts +3 -3
- package/out/candidate/scoring.d.ts.map +1 -1
- package/out/candidate/scoring.js +2 -2
- package/out/candidate/scoring.js.map +1 -1
- package/out/convention.d.ts +1 -1
- package/out/convention.d.ts.map +1 -1
- package/out/env.d.ts +3 -0
- package/out/env.d.ts.map +1 -1
- package/out/env.js +14 -3
- package/out/env.js.map +1 -1
- package/out/fst/binary-matcher.d.ts.map +1 -1
- package/out/fst/binary-matcher.js +9 -30
- package/out/fst/binary-matcher.js.map +1 -1
- package/out/fst/builder.d.ts.map +1 -1
- package/out/fst/builder.js +8 -6
- package/out/fst/builder.js.map +1 -1
- package/out/fst/deserialize-web.js +1 -1
- package/out/fst/deserialize-web.js.map +1 -1
- package/out/fst/format.d.ts +60 -9
- package/out/fst/format.d.ts.map +1 -1
- package/out/fst/format.js +97 -6
- package/out/fst/format.js.map +1 -1
- package/out/fst/freshness.js +2 -2
- package/out/fst/freshness.js.map +1 -1
- package/out/fst/serialize.d.ts.map +1 -1
- package/out/fst/serialize.js +67 -55
- package/out/fst/serialize.js.map +1 -1
- package/out/fts/query.d.ts +1 -1
- package/out/fts/query.d.ts.map +1 -1
- package/out/{search-fetch.d.ts → fts/search-fetch.d.ts} +2 -2
- package/out/fts/search-fetch.d.ts.map +1 -0
- package/out/fts/search-fetch.js.map +1 -0
- package/out/geonames/aliases.d.ts +18 -18
- package/out/geonames/aliases.d.ts.map +1 -1
- package/out/geonames/aliases.js +20 -24
- package/out/geonames/aliases.js.map +1 -1
- package/out/geonames/postal.d.ts +1 -1
- package/out/geonames/postal.js +3 -3
- package/out/index.d.ts +17 -17
- package/out/index.d.ts.map +1 -1
- package/out/index.js +12 -12
- package/out/index.js.map +1 -1
- package/out/{postal/city → labels/locality/postal-city}/alias/lookup.d.ts +1 -1
- package/out/labels/locality/postal-city/alias/lookup.d.ts.map +1 -0
- package/out/labels/locality/postal-city/alias/lookup.js.map +1 -0
- package/out/labels/locality/postal-city/alias/schema.d.ts.map +1 -0
- package/out/labels/locality/postal-city/alias/schema.js.map +1 -0
- package/out/{postal/city → labels/locality/postal-city}/candidate-schema.d.ts +1 -1
- package/out/labels/locality/postal-city/candidate-schema.d.ts.map +1 -0
- package/out/labels/locality/postal-city/candidate-schema.js.map +1 -0
- package/out/labels/locality.d.ts +4 -0
- package/out/labels/locality.d.ts.map +1 -0
- package/out/labels/locality.js +6 -0
- package/out/labels/locality.js.map +1 -0
- package/out/{region-keys.d.ts → labels/region.d.ts} +1 -1
- package/out/{region-keys.d.ts.map → labels/region.d.ts.map} +1 -1
- package/out/{region-keys.js → labels/region.js} +6 -3
- package/out/labels/region.js.map +1 -0
- package/out/{street → labels/street}/centroid/schema.d.ts +1 -1
- package/out/labels/street/centroid/schema.d.ts.map +1 -0
- package/out/labels/street/centroid/schema.js.map +1 -0
- package/out/{street → labels/street}/centroid.d.ts +5 -5
- package/out/labels/street/centroid.d.ts.map +1 -0
- package/out/{street → labels/street}/centroid.js +5 -5
- package/out/labels/street/centroid.js.map +1 -0
- package/out/{interpolation.d.ts → labels/street/interpolation.d.ts} +6 -1
- package/out/labels/street/interpolation.d.ts.map +1 -0
- package/out/{interpolation.js → labels/street/interpolation.js} +10 -8
- package/out/labels/street/interpolation.js.map +1 -0
- package/out/labels/street/locale.d.ts +26 -0
- package/out/labels/street/locale.d.ts.map +1 -0
- package/out/labels/street/locale.js +98 -0
- package/out/labels/street/locale.js.map +1 -0
- package/out/labels/street/morphology/fst/builder.d.ts.map +1 -0
- package/out/labels/street/morphology/fst/builder.js.map +1 -0
- package/out/labels/street/morphology/fst/loader.d.ts.map +1 -0
- package/out/{street → labels/street}/morphology/fst/loader.js +1 -1
- package/out/labels/street/morphology/fst/loader.js.map +1 -0
- package/out/labels/street/name-lookup.d.ts.map +1 -0
- package/out/{street → labels/street}/name-lookup.js +2 -0
- package/out/labels/street/name-lookup.js.map +1 -0
- package/out/labels/street/normalize.d.ts +188 -0
- package/out/labels/street/normalize.d.ts.map +1 -0
- package/out/{street → labels/street}/normalize.js +200 -119
- package/out/labels/street/normalize.js.map +1 -0
- package/out/{street → labels/street}/segment-schema.d.ts +1 -1
- package/out/labels/street/segment-schema.d.ts.map +1 -0
- package/out/labels/street/segment-schema.js.map +1 -0
- package/out/labels/street/table.d.ts.map +1 -0
- package/out/{street → labels/street}/table.js +1 -1
- package/out/labels/street/table.js.map +1 -0
- package/out/labels/street.d.ts +9 -0
- package/out/labels/street.d.ts.map +1 -0
- package/out/labels/street.js +11 -0
- package/out/labels/street.js.map +1 -0
- package/out/landmark/rows.js +1 -1
- package/out/landmark/rows.js.map +1 -1
- package/out/lookup/browse.d.ts +79 -0
- package/out/lookup/browse.d.ts.map +1 -0
- package/out/lookup/browse.js +194 -0
- package/out/lookup/browse.js.map +1 -0
- package/out/lookup/exact-match.d.ts.map +1 -0
- package/out/lookup/exact-match.js.map +1 -0
- package/out/lookup/extracts.d.ts.map +1 -0
- package/out/{extracts.js → lookup/extracts.js} +1 -1
- package/out/lookup/extracts.js.map +1 -0
- package/out/lookup/former-divisions.d.ts +99 -0
- package/out/lookup/former-divisions.d.ts.map +1 -0
- package/out/lookup/former-divisions.js +98 -0
- package/out/lookup/former-divisions.js.map +1 -0
- package/out/{postcode-point-lookup.d.ts → lookup/postcode-point.d.ts} +5 -1
- package/out/lookup/postcode-point.d.ts.map +1 -0
- package/out/{postcode-point-lookup.js → lookup/postcode-point.js} +1 -1
- package/out/lookup/postcode-point.js.map +1 -0
- package/out/{reverse.d.ts → lookup/reverse.d.ts} +1 -1
- package/out/lookup/reverse.d.ts.map +1 -0
- package/out/{reverse.js → lookup/reverse.js} +3 -3
- package/out/lookup/reverse.js.map +1 -0
- package/out/{types.d.ts → lookup/types.d.ts} +9 -0
- package/out/lookup/types.d.ts.map +1 -0
- package/out/lookup/types.js.map +1 -0
- package/out/lookup.d.ts +4 -4
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +14 -20
- package/out/lookup.js.map +1 -1
- package/out/poi/schema.d.ts +1 -1
- package/out/poi/schema.d.ts.map +1 -1
- package/out/ranking/name-score.d.ts.map +1 -0
- package/out/ranking/name-score.js.map +1 -0
- package/out/{primary-preference.d.ts → ranking/primary-preference.d.ts} +20 -1
- package/out/ranking/primary-preference.d.ts.map +1 -0
- package/out/{primary-preference.js → ranking/primary-preference.js} +35 -1
- package/out/ranking/primary-preference.js.map +1 -0
- package/out/ranking/proximity-rerank.d.ts.map +1 -0
- package/out/ranking/proximity-rerank.js.map +1 -0
- package/out/{ranking-weights.d.ts → ranking/weights.d.ts} +1 -1
- package/out/ranking/weights.d.ts.map +1 -0
- package/out/{ranking-weights.js → ranking/weights.js} +1 -1
- package/out/ranking/weights.js.map +1 -0
- package/out/schema/importance-source.d.ts +90 -0
- package/out/schema/importance-source.d.ts.map +1 -0
- package/out/schema/importance-source.js +133 -0
- package/out/schema/importance-source.js.map +1 -0
- package/out/schema/overture-match.d.ts +53 -0
- package/out/schema/overture-match.d.ts.map +1 -0
- package/out/schema/overture-match.js +33 -0
- package/out/schema/overture-match.js.map +1 -0
- package/out/{place-importance-schema.d.ts → schema/place-importance.d.ts} +50 -1
- package/out/schema/place-importance.d.ts.map +1 -0
- package/out/{place-importance-schema.js → schema/place-importance.js} +34 -1
- package/out/schema/place-importance.js.map +1 -0
- package/out/{polygon-schema.d.ts → schema/polygon.d.ts} +1 -1
- package/out/schema/polygon.d.ts.map +1 -0
- package/out/{polygon-schema.js → schema/polygon.js} +1 -1
- package/out/schema/polygon.js.map +1 -0
- package/out/{unified-schema.d.ts → schema/unified.d.ts} +1 -1
- package/out/schema/unified.d.ts.map +1 -0
- package/out/{unified-schema.js → schema/unified.js} +1 -1
- package/out/schema/unified.js.map +1 -0
- package/out/schema.d.ts +3 -3
- package/out/sqlite/convention-source.js +1 -1
- package/out/sqlite/convention-source.js.map +1 -1
- package/out/uprn/existence.d.ts.map +1 -1
- package/out/uprn/existence.js +2 -0
- package/out/uprn/existence.js.map +1 -1
- package/out/{weights-overlay-linker.d.ts → weights/overlay-linker.d.ts} +43 -24
- package/out/weights/overlay-linker.d.ts.map +1 -0
- package/out/{weights-overlay-linker.js → weights/overlay-linker.js} +182 -66
- package/out/weights/overlay-linker.js.map +1 -0
- package/package.json +12 -32
- package/lib/postal.ts +0 -6
- package/lib/street/locale.ts +0 -64
- package/lib/street.ts +0 -11
- package/out/candidate/extract-fold.d.ts.map +0 -1
- package/out/candidate/extract-fold.js.map +0 -1
- package/out/capital-schema.d.ts.map +0 -1
- package/out/capital-schema.js.map +0 -1
- package/out/capitals.d.ts.map +0 -1
- package/out/capitals.js.map +0 -1
- package/out/coverage-manifest-schema.d.ts.map +0 -1
- package/out/coverage-manifest-schema.js.map +0 -1
- package/out/exact-match.d.ts.map +0 -1
- package/out/exact-match.js.map +0 -1
- package/out/extracts.d.ts.map +0 -1
- package/out/extracts.js.map +0 -1
- package/out/interpolation.d.ts.map +0 -1
- package/out/interpolation.js.map +0 -1
- package/out/name-score.d.ts.map +0 -1
- package/out/name-score.js.map +0 -1
- package/out/place-importance-schema.d.ts.map +0 -1
- package/out/place-importance-schema.js.map +0 -1
- package/out/polygon-schema.d.ts.map +0 -1
- package/out/polygon-schema.js.map +0 -1
- package/out/postal/city/alias/lookup.d.ts.map +0 -1
- package/out/postal/city/alias/lookup.js.map +0 -1
- package/out/postal/city/alias/schema.d.ts.map +0 -1
- package/out/postal/city/alias/schema.js.map +0 -1
- package/out/postal/city/candidate-schema.d.ts.map +0 -1
- package/out/postal/city/candidate-schema.js.map +0 -1
- package/out/postal.d.ts +0 -4
- package/out/postal.d.ts.map +0 -1
- package/out/postal.js +0 -6
- package/out/postal.js.map +0 -1
- package/out/postcode-point-lookup.d.ts.map +0 -1
- package/out/postcode-point-lookup.js.map +0 -1
- package/out/primary-preference.d.ts.map +0 -1
- package/out/primary-preference.js.map +0 -1
- package/out/proximity-rerank.d.ts.map +0 -1
- package/out/proximity-rerank.js.map +0 -1
- package/out/ranking-weights.d.ts.map +0 -1
- package/out/ranking-weights.js.map +0 -1
- package/out/region-keys.js.map +0 -1
- package/out/reverse.d.ts.map +0 -1
- package/out/reverse.js.map +0 -1
- package/out/search-fetch.d.ts.map +0 -1
- package/out/search-fetch.js.map +0 -1
- package/out/street/centroid/schema.d.ts.map +0 -1
- package/out/street/centroid/schema.js.map +0 -1
- package/out/street/centroid.d.ts.map +0 -1
- package/out/street/centroid.js.map +0 -1
- package/out/street/locale.d.ts +0 -12
- package/out/street/locale.d.ts.map +0 -1
- package/out/street/locale.js +0 -54
- package/out/street/locale.js.map +0 -1
- package/out/street/morphology/fst/builder.d.ts.map +0 -1
- package/out/street/morphology/fst/builder.js.map +0 -1
- package/out/street/morphology/fst/loader.d.ts.map +0 -1
- package/out/street/morphology/fst/loader.js.map +0 -1
- package/out/street/name-lookup.d.ts.map +0 -1
- package/out/street/name-lookup.js.map +0 -1
- package/out/street/normalize.d.ts +0 -111
- package/out/street/normalize.d.ts.map +0 -1
- package/out/street/normalize.js.map +0 -1
- package/out/street/segment-schema.d.ts.map +0 -1
- package/out/street/segment-schema.js.map +0 -1
- package/out/street/table.d.ts.map +0 -1
- package/out/street/table.js.map +0 -1
- package/out/street.d.ts +0 -9
- package/out/street.d.ts.map +0 -1
- package/out/street.js +0 -11
- package/out/street.js.map +0 -1
- package/out/types.d.ts.map +0 -1
- package/out/types.js.map +0 -1
- package/out/unified-schema.d.ts.map +0 -1
- package/out/unified-schema.js.map +0 -1
- package/out/weights-overlay-linker.d.ts.map +0 -1
- package/out/weights-overlay-linker.js.map +0 -1
- /package/lib/{coverage-manifest-schema.ts → candidate/coverage-manifest.ts} +0 -0
- /package/lib/{postal/city → labels/locality/postal-city}/alias/schema.ts +0 -0
- /package/lib/{street → labels/street}/morphology/fst/builder.ts +0 -0
- /package/lib/{exact-match.ts → lookup/exact-match.ts} +0 -0
- /package/lib/{name-score.ts → ranking/name-score.ts} +0 -0
- /package/lib/{proximity-rerank.ts → ranking/proximity-rerank.ts} +0 -0
- /package/lib/{ranking-weights.ts → ranking/weights.ts} +0 -0
- /package/lib/{polygon-schema.ts → schema/polygon.ts} +0 -0
- /package/lib/{unified-schema.ts → schema/unified.ts} +0 -0
- /package/out/{capitals.d.ts → candidate/capitals.d.ts} +0 -0
- /package/out/{search-fetch.js → fts/search-fetch.js} +0 -0
- /package/out/{postal/city → labels/locality/postal-city}/alias/lookup.js +0 -0
- /package/out/{postal/city → labels/locality/postal-city}/alias/schema.d.ts +0 -0
- /package/out/{postal/city → labels/locality/postal-city}/alias/schema.js +0 -0
- /package/out/{postal/city → labels/locality/postal-city}/candidate-schema.js +0 -0
- /package/out/{street → labels/street}/centroid/schema.js +0 -0
- /package/out/{street → labels/street}/morphology/fst/builder.d.ts +0 -0
- /package/out/{street → labels/street}/morphology/fst/builder.js +0 -0
- /package/out/{street → labels/street}/morphology/fst/loader.d.ts +0 -0
- /package/out/{street → labels/street}/name-lookup.d.ts +0 -0
- /package/out/{street → labels/street}/segment-schema.js +0 -0
- /package/out/{street → labels/street}/table.d.ts +0 -0
- /package/out/{exact-match.d.ts → lookup/exact-match.d.ts} +0 -0
- /package/out/{exact-match.js → lookup/exact-match.js} +0 -0
- /package/out/{extracts.d.ts → lookup/extracts.d.ts} +0 -0
- /package/out/{types.js → lookup/types.js} +0 -0
- /package/out/{name-score.d.ts → ranking/name-score.d.ts} +0 -0
- /package/out/{name-score.js → ranking/name-score.js} +0 -0
- /package/out/{proximity-rerank.d.ts → ranking/proximity-rerank.d.ts} +0 -0
- /package/out/{proximity-rerank.js → ranking/proximity-rerank.js} +0 -0
package/lib/build/candidate.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { COUNTRY_POPULATION } from "@mailwoman/codex/country"
|
|
|
5
5
|
import { bareAdminName } from "@mailwoman/codex/country/bare-admin-names"
|
|
6
6
|
import { pathExists } from "@mailwoman/core/fs/readers/stat"
|
|
7
7
|
import { removePath } from "@mailwoman/core/fs/writers"
|
|
8
|
-
import {
|
|
8
|
+
import { isOverturePartID } from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
9
|
+
import { stringifyJSON } from "@mailwoman/core/values/json"
|
|
9
10
|
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
10
11
|
import type { PathBuilderLike } from "path-ts"
|
|
11
12
|
|
|
@@ -13,22 +14,27 @@ import { POPULATION_CORRECTIONS } from "#build/population-corrections"
|
|
|
13
14
|
import { explodeAliasBags } from "#candidate/alias-bags"
|
|
14
15
|
import { buildAncestorsSidecar } from "#candidate/ancestors/sidecar"
|
|
15
16
|
import { stageBareAdminNames } from "#candidate/bare-admin-names"
|
|
17
|
+
import { createCapitalTable } from "#candidate/capital-schema"
|
|
18
|
+
import type { CapitalPoint } from "#candidate/capitals"
|
|
16
19
|
import { stageCountryDisplayNames } from "#candidate/country-display-names"
|
|
17
|
-
import {
|
|
20
|
+
import { stageExtractRows } from "#candidate/extract-rows"
|
|
18
21
|
import { createCandidateFTS } from "#candidate/fts"
|
|
19
22
|
import { IMPORTANCE_JOIN_RADIUS_KM, loadImportanceIndex } from "#candidate/importance"
|
|
23
|
+
import { applyCandidateKeyFold, type CandidateKeyFold } from "#candidate/key-fold"
|
|
20
24
|
import { GLOSS_KEY_THRESHOLD, stampNameRoles } from "#candidate/name-roles"
|
|
25
|
+
import { refuseNicknamesOfNamesakes } from "#candidate/nickname-namesakes"
|
|
26
|
+
import { stageOvertureTwins } from "#candidate/overture-twins"
|
|
21
27
|
import type { PlaceAttrs } from "#candidate/place-attrs"
|
|
22
28
|
import {
|
|
23
29
|
CANDIDATE_COLUMNS,
|
|
30
|
+
createCandidatePostcodePlaceIndex,
|
|
24
31
|
createCandidateStagingTables,
|
|
25
32
|
createCandidateTable,
|
|
26
33
|
type CandidateDatabase,
|
|
34
|
+
POSTCODE_PLACETYPE,
|
|
27
35
|
} from "#candidate/schema"
|
|
28
|
-
import {
|
|
29
|
-
import type { CapitalPoint } from "#capitals"
|
|
36
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
30
37
|
import type { WOFDatabase } from "#schema"
|
|
31
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* Options for {@link buildCandidateTable}.
|
|
@@ -83,6 +89,18 @@ export interface BuildCandidateOptions {
|
|
|
83
89
|
*/
|
|
84
90
|
importance?: PathBuilderLike
|
|
85
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Rank each place with no population by the importance database's
|
|
94
|
+
* `place_population_estimate`, when it has an estimate there.
|
|
95
|
+
*
|
|
96
|
+
* The estimate sets `neg_rank` only; `population` stays NULL, because no source measured it.
|
|
97
|
+
*
|
|
98
|
+
* Requires {@link BuildCandidateOptions.importance}, built with sub-locality estimates.
|
|
99
|
+
*
|
|
100
|
+
* @defaultValue false
|
|
101
|
+
*/
|
|
102
|
+
populationEstimates?: boolean
|
|
103
|
+
|
|
86
104
|
/**
|
|
87
105
|
* Receives a phase name and a message as each build step runs.
|
|
88
106
|
*/
|
|
@@ -96,6 +114,14 @@ export interface BuildCandidateOptions {
|
|
|
96
114
|
* @defaultValue {@linkcode GLOSS_KEY_THRESHOLD}
|
|
97
115
|
*/
|
|
98
116
|
glossKeyThreshold?: number
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Folds applied to every `name_key` after `normalizeLocalityForKey`, recorded in
|
|
120
|
+
* the artifact so its reader folds query keys the same way.
|
|
121
|
+
*
|
|
122
|
+
* @defaultValue none
|
|
123
|
+
*/
|
|
124
|
+
keyFolds?: readonly CandidateKeyFold[]
|
|
99
125
|
}
|
|
100
126
|
|
|
101
127
|
/**
|
|
@@ -106,6 +132,11 @@ export interface BuildCandidateResult {
|
|
|
106
132
|
places: number
|
|
107
133
|
primaries: number
|
|
108
134
|
aliases: number
|
|
135
|
+
/**
|
|
136
|
+
* The count of alias rows staged as a name's key with its apostrophe-like marks
|
|
137
|
+
* removed (`hawaii` for `Hawaiʻi`), which `aliases` excludes.
|
|
138
|
+
*/
|
|
139
|
+
markFreeAliases: number
|
|
109
140
|
|
|
110
141
|
/**
|
|
111
142
|
* The count of region aliases dropped because another region in the same
|
|
@@ -114,6 +145,14 @@ export interface BuildCandidateResult {
|
|
|
114
145
|
* The count is always zero for a source without a `names` table.
|
|
115
146
|
*/
|
|
116
147
|
regionOfficialRefused: number
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The count of alias rows from a colloquial or unclassified name dropped
|
|
151
|
+
* because a populated place holds the same key by a real name.
|
|
152
|
+
*
|
|
153
|
+
* The count is always zero for a source without a `names` table.
|
|
154
|
+
*/
|
|
155
|
+
nicknameRefused: number
|
|
117
156
|
abbrevs: number
|
|
118
157
|
postcodes: number
|
|
119
158
|
|
|
@@ -158,6 +197,11 @@ export interface BuildCandidateResult {
|
|
|
158
197
|
*/
|
|
159
198
|
importanceFiltered: number | null
|
|
160
199
|
|
|
200
|
+
/**
|
|
201
|
+
* The count of places ranked by a population estimate, or `null` when estimates weren't asked for.
|
|
202
|
+
*/
|
|
203
|
+
populationEstimated: number | null
|
|
204
|
+
|
|
161
205
|
/**
|
|
162
206
|
* The count of alias rows the gloss anomaly detector stamped `name_role = 'gloss'`.
|
|
163
207
|
*/
|
|
@@ -178,6 +222,78 @@ export interface BuildCandidateResult {
|
|
|
178
222
|
* The count of places in `keyTailPlaces` with at least one stamped role row.
|
|
179
223
|
*/
|
|
180
224
|
keyTailWithRole: number
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The Overture divisions the admin database matched to a WOF record, copied into
|
|
228
|
+
* `overture_wof_match`, or null when the admin database predates that table.
|
|
229
|
+
*/
|
|
230
|
+
overtureMatches: number | null
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* The matched divisions' staged rows dropped on keys their WOF record holds,
|
|
234
|
+
* or null with `overtureMatches`.
|
|
235
|
+
*/
|
|
236
|
+
overtureTwinRowsDropped: number | null
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Each place's region from the admin database's `ancestors`, the lowest id
|
|
241
|
+
* when it has more than one, with the count of places that have more than one.
|
|
242
|
+
*/
|
|
243
|
+
function loadRegionAncestry(src: DatabaseClient<WOFDatabase>): { regionOf: Map<number, number>; multiRegion: number } {
|
|
244
|
+
const regionOf = new Map<number, number>()
|
|
245
|
+
let multiRegion = 0
|
|
246
|
+
|
|
247
|
+
for (const r of src
|
|
248
|
+
.prepare(
|
|
249
|
+
"SELECT id, MIN(ancestor_id) AS ancestor_id, COUNT(DISTINCT ancestor_id) AS n" +
|
|
250
|
+
" FROM ancestors WHERE ancestor_placetype='region' GROUP BY id"
|
|
251
|
+
)
|
|
252
|
+
.iterate()) {
|
|
253
|
+
regionOf.set(Number(r.id), Number(r.ancestor_id))
|
|
254
|
+
|
|
255
|
+
if (Number(r.n) > 1) {
|
|
256
|
+
multiRegion++
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return { regionOf, multiRegion }
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The two staging passes that delete rows by another place's rows, in order:
|
|
265
|
+
* the nickname refusal, then the Overture twins.
|
|
266
|
+
*
|
|
267
|
+
* The twins pass compares with the WOF rows the refusal keeps.
|
|
268
|
+
*/
|
|
269
|
+
async function refuseNicknamesAndTwins(
|
|
270
|
+
src: DatabaseClient<WOFDatabase>,
|
|
271
|
+
kdb: DatabaseClient<CandidateDatabase>,
|
|
272
|
+
attrs: Map<number, PlaceAttrs>,
|
|
273
|
+
progress: (phase: string, message: string) => void
|
|
274
|
+
): Promise<{
|
|
275
|
+
nicknames: ReturnType<typeof refuseNicknamesOfNamesakes>
|
|
276
|
+
twins: Awaited<ReturnType<typeof stageOvertureTwins>>
|
|
277
|
+
}> {
|
|
278
|
+
const nicknames = refuseNicknamesOfNamesakes(src, kdb, attrs)
|
|
279
|
+
|
|
280
|
+
progress(
|
|
281
|
+
"nicknames",
|
|
282
|
+
`${nicknames.rows.toLocaleString()} colloquial or unclassified alias rows refused on ` +
|
|
283
|
+
`${nicknames.keys.toLocaleString()} keys a populated place holds by a real name`
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
const twins = await stageOvertureTwins(src, kdb)
|
|
287
|
+
|
|
288
|
+
if (twins) {
|
|
289
|
+
progress(
|
|
290
|
+
"overture-twins",
|
|
291
|
+
`${twins.matches.toLocaleString()} Overture divisions matched to a WOF record. ` +
|
|
292
|
+
`${twins.rowsDropped.toLocaleString()} of their rows dropped on keys the WOF record holds`
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return { nicknames, twins }
|
|
181
297
|
}
|
|
182
298
|
|
|
183
299
|
/**
|
|
@@ -231,33 +347,24 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
231
347
|
|
|
232
348
|
if (opts.importance) {
|
|
233
349
|
progress("importance", `loading place_importance from ${opts.importance}`)
|
|
234
|
-
importance = loadImportanceIndex(opts.importance)
|
|
350
|
+
importance = loadImportanceIndex(opts.importance, { populationEstimates: opts.populationEstimates === true })
|
|
235
351
|
|
|
236
352
|
progress(
|
|
237
353
|
"importance",
|
|
238
354
|
`${importance.stats.places.toLocaleString()} scored places in ${importance.stats.keys.toLocaleString()} (name, country, placetype) groups` +
|
|
239
|
-
(importance.stats.unkeyable ? `; ${importance.stats.unkeyable.toLocaleString()} unkeyable names skipped` : "")
|
|
355
|
+
(importance.stats.unkeyable ? `; ${importance.stats.unkeyable.toLocaleString()} unkeyable names skipped` : "") +
|
|
356
|
+
(typeof importance.stats.estimates === "number"
|
|
357
|
+
? `; ${importance.stats.estimates.toLocaleString()} population estimates to rank unmeasured places by`
|
|
358
|
+
: "")
|
|
240
359
|
)
|
|
360
|
+
} else if (opts.populationEstimates) {
|
|
361
|
+
throw new Error("buildCandidateTable: populationEstimates reads the importance database; pass importance too")
|
|
241
362
|
} else {
|
|
242
363
|
progress("importance", "no score source given — `importance` will be NULL on every row")
|
|
243
364
|
}
|
|
244
365
|
|
|
245
366
|
progress("region", "loading region ancestry")
|
|
246
|
-
const regionOf
|
|
247
|
-
let multiRegion = 0
|
|
248
|
-
|
|
249
|
-
for (const r of src
|
|
250
|
-
.prepare(
|
|
251
|
-
"SELECT id, MIN(ancestor_id) AS ancestor_id, COUNT(DISTINCT ancestor_id) AS n" +
|
|
252
|
-
" FROM ancestors WHERE ancestor_placetype='region' GROUP BY id"
|
|
253
|
-
)
|
|
254
|
-
.iterate()) {
|
|
255
|
-
regionOf.set(Number(r.id), Number(r.ancestor_id))
|
|
256
|
-
|
|
257
|
-
if (Number(r.n) > 1) {
|
|
258
|
-
multiRegion++
|
|
259
|
-
}
|
|
260
|
-
}
|
|
367
|
+
const { regionOf, multiRegion } = loadRegionAncestry(src)
|
|
261
368
|
|
|
262
369
|
progress(
|
|
263
370
|
"region",
|
|
@@ -293,7 +400,7 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
293
400
|
POPULATION_CORRECTIONS[sid]?.population ??
|
|
294
401
|
(wofPop === null && r.placetype === "country" ? (COUNTRY_POPULATION[String(r.country ?? "")] ?? null) : wofPop)
|
|
295
402
|
|
|
296
|
-
const neg = -Math.log10((pop ?? 0) + 1)
|
|
403
|
+
const neg = -Math.log10((pop ?? importance?.estimatedPopulation(sid) ?? 0) + 1)
|
|
297
404
|
const name = String(r.name ?? "")
|
|
298
405
|
const pkey = normalizeLocalityForKey(name)
|
|
299
406
|
const lat = r.lat as number
|
|
@@ -313,7 +420,15 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
313
420
|
pop,
|
|
314
421
|
neg,
|
|
315
422
|
pkey,
|
|
316
|
-
imp:
|
|
423
|
+
imp:
|
|
424
|
+
importance?.find(
|
|
425
|
+
name,
|
|
426
|
+
r.country as string | null,
|
|
427
|
+
r.placetype as string | null,
|
|
428
|
+
lat,
|
|
429
|
+
lon,
|
|
430
|
+
isOverturePartID(sid)
|
|
431
|
+
) ?? null,
|
|
317
432
|
}
|
|
318
433
|
|
|
319
434
|
attrs.set(sid, a)
|
|
@@ -401,7 +516,7 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
401
516
|
|
|
402
517
|
const iso2ByCountryID = new Map([...ccodes].map(([code, id]) => [id, code]))
|
|
403
518
|
|
|
404
|
-
const { nAlias, nBare, keyCounts, regionOfficialRefused } = explodeAliasBags(src, kdb, attrs, stageRow, {
|
|
519
|
+
const { nAlias, nBare, nMarkFree, keyCounts, regionOfficialRefused } = explodeAliasBags(src, kdb, attrs, stageRow, {
|
|
405
520
|
regionPlacetypeID: ptID("region"),
|
|
406
521
|
ccID,
|
|
407
522
|
bareName: (countryID, alias) => bareAdminName(iso2ByCountryID.get(countryID) ?? "", alias),
|
|
@@ -409,7 +524,8 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
409
524
|
|
|
410
525
|
progress(
|
|
411
526
|
"aliases",
|
|
412
|
-
`${nAlias.toLocaleString()} aliases; ${nBare.toLocaleString()} bare admin aliases` +
|
|
527
|
+
`${nAlias.toLocaleString()} aliases; ${nBare.toLocaleString()} bare admin aliases; ` +
|
|
528
|
+
`${nMarkFree.toLocaleString()} mark-free aliases` +
|
|
413
529
|
(regionOfficialRefused
|
|
414
530
|
? `; ${regionOfficialRefused.toLocaleString()} region aliases refused as another region's official name`
|
|
415
531
|
: "")
|
|
@@ -433,6 +549,8 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
433
549
|
kdb.exec("COMMIT")
|
|
434
550
|
progress("abbrevs", `${nAbbr.toLocaleString()} abbrevs`)
|
|
435
551
|
|
|
552
|
+
const { nicknames, twins } = await refuseNicknamesAndTwins(src, kdb, attrs, progress)
|
|
553
|
+
|
|
436
554
|
const roles = stampNameRoles({
|
|
437
555
|
src,
|
|
438
556
|
out: kdb,
|
|
@@ -450,18 +568,18 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
450
568
|
let nPostcodeAlias = 0
|
|
451
569
|
|
|
452
570
|
for (const pcDB of opts.postcodes ?? []) {
|
|
453
|
-
const
|
|
571
|
+
const staged = stageExtractRows({
|
|
454
572
|
out: kdb,
|
|
455
573
|
extractPath: pcDB,
|
|
456
|
-
extractPlacetype:
|
|
574
|
+
extractPlacetype: POSTCODE_PLACETYPE,
|
|
457
575
|
ccID,
|
|
458
576
|
ptID,
|
|
459
577
|
stageRow,
|
|
460
578
|
progress,
|
|
461
579
|
})
|
|
462
580
|
|
|
463
|
-
nPostcode +=
|
|
464
|
-
nPostcodeAlias +=
|
|
581
|
+
nPostcode += staged.primaries
|
|
582
|
+
nPostcodeAlias += staged.aliases
|
|
465
583
|
}
|
|
466
584
|
|
|
467
585
|
if (nPostcode > 0) {
|
|
@@ -473,7 +591,7 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
473
591
|
let nLocalityAncestor = 0
|
|
474
592
|
|
|
475
593
|
for (const locDB of opts.localities ?? []) {
|
|
476
|
-
const
|
|
594
|
+
const staged = stageExtractRows({
|
|
477
595
|
out: kdb,
|
|
478
596
|
extractPath: locDB,
|
|
479
597
|
extractPlacetype: "locality",
|
|
@@ -484,15 +602,15 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
484
602
|
progress,
|
|
485
603
|
})
|
|
486
604
|
|
|
487
|
-
nLocality +=
|
|
488
|
-
nLocalityScoped +=
|
|
489
|
-
nLocalityAncestor +=
|
|
605
|
+
nLocality += staged.primaries
|
|
606
|
+
nLocalityScoped += staged.scoped
|
|
607
|
+
nLocalityAncestor += staged.ancestorRows
|
|
490
608
|
}
|
|
491
609
|
|
|
492
610
|
if (nLocality > 0) {
|
|
493
611
|
progress(
|
|
494
612
|
"localities",
|
|
495
|
-
`${nLocality.toLocaleString()} extract localities
|
|
613
|
+
`${nLocality.toLocaleString()} extract localities added` +
|
|
496
614
|
(nLocalityScoped
|
|
497
615
|
? `; ${nLocalityScoped.toLocaleString()} carry a region scope (${nLocalityAncestor.toLocaleString()} closure rows)`
|
|
498
616
|
: "")
|
|
@@ -541,9 +659,22 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
541
659
|
kdb.exec(`INSERT OR IGNORE INTO candidate (${cols}) SELECT ${cols} FROM cand_stage ORDER BY ${keyOrder};`)
|
|
542
660
|
await kdb.schema.dropTable("cand_stage").execute()
|
|
543
661
|
|
|
662
|
+
for (const fold of opts.keyFolds ?? []) {
|
|
663
|
+
const { rekeyed, merged } = await applyCandidateKeyFold(kdb, fold)
|
|
664
|
+
|
|
665
|
+
progress("key-fold", `${fold}: ${rekeyed.toLocaleString()} rows rekeyed, ${merged.toLocaleString()} merged`)
|
|
666
|
+
}
|
|
667
|
+
|
|
544
668
|
progress("fts", "building FTS5-trigram fuzzy index")
|
|
545
669
|
createCandidateFTS(kdb)
|
|
546
670
|
|
|
671
|
+
const postcodePlacetypeID = ptcodes.get(POSTCODE_PLACETYPE)
|
|
672
|
+
|
|
673
|
+
if (postcodePlacetypeID != null) {
|
|
674
|
+
progress("postcode-index", `indexing postcode places by spr_id (placetype id ${postcodePlacetypeID})`)
|
|
675
|
+
await createCandidatePostcodePlaceIndex(kdb, postcodePlacetypeID)
|
|
676
|
+
}
|
|
677
|
+
|
|
547
678
|
kdb.exec("PRAGMA page_size=8192")
|
|
548
679
|
kdb.exec("VACUUM")
|
|
549
680
|
|
|
@@ -557,7 +688,9 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
557
688
|
places: attrs.size,
|
|
558
689
|
primaries: nPrim,
|
|
559
690
|
aliases: nAlias,
|
|
691
|
+
markFreeAliases: nMarkFree,
|
|
560
692
|
regionOfficialRefused,
|
|
693
|
+
nicknameRefused: nicknames.rows,
|
|
561
694
|
abbrevs: nAbbr,
|
|
562
695
|
postcodes: nPostcode,
|
|
563
696
|
postcodeAliases: nPostcodeAlias,
|
|
@@ -567,5 +700,8 @@ export async function buildCandidateTable(opts: BuildCandidateOptions): Promise<
|
|
|
567
700
|
...roles,
|
|
568
701
|
importanceScored: importance ? importance.matched : null,
|
|
569
702
|
importanceFiltered: importance ? importance.refused : null,
|
|
703
|
+
populationEstimated: typeof importance?.stats.estimates === "number" ? importance.estimated : null,
|
|
704
|
+
overtureMatches: twins ? twins.matches : null,
|
|
705
|
+
overtureTwinRowsDropped: twins ? twins.rowsDropped : null,
|
|
570
706
|
}
|
|
571
707
|
}
|
package/lib/build/slim.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { statPath, pathExists } from "@mailwoman/core/fs/readers/stat"
|
|
5
5
|
import { temporaryDirectory } from "@mailwoman/core/fs/temporary"
|
|
6
6
|
import { copyFileTo, removePath } from "@mailwoman/core/fs/writers"
|
|
7
|
-
import { stringifyJSON } from "@mailwoman/core/json"
|
|
7
|
+
import { stringifyJSON } from "@mailwoman/core/values/json"
|
|
8
8
|
import { countRows } from "@mailwoman/sqlite"
|
|
9
9
|
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
10
10
|
import { sealDatabase } from "@mailwoman/sqlite/sealed/db"
|
|
@@ -103,6 +103,9 @@ interface BuildSchema {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export async function buildSlimWOFDatabase(opts: BuildSlimOptions): Promise<BuildSlimResult> {
|
|
106
|
+
// country-branch: a slim build that states no countries keeps the places of one country, the US.
|
|
107
|
+
// The commit that added the default recorded no reason, and a required
|
|
108
|
+
// `countries` option would replace it.
|
|
106
109
|
const countries = (opts.countries ?? ["US"]).map((c) => c.toUpperCase())
|
|
107
110
|
const topLocalities = opts.topLocalitiesPerCountry ?? 1000
|
|
108
111
|
const progress = opts.onProgress ?? (() => {})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The sources a gazetteer build records in its `layer_manifest.source`, and
|
|
6
|
+
* where a user obtains each one.
|
|
7
|
+
*
|
|
8
|
+
* The admin build writes these names, joined with `+`, and a server reads them
|
|
9
|
+
* back to link each collection to the data behind it.
|
|
10
|
+
* One table serves both, so a name the build writes always has its location here.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { SourceLocation } from "@mailwoman/core/resolver"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The name each gazetteer source goes by in a manifest's `source`.
|
|
17
|
+
*/
|
|
18
|
+
export const GazetteerSourceName = {
|
|
19
|
+
WhosOnFirst: "whosonfirst",
|
|
20
|
+
OvertureDivisions: "overture-divisions",
|
|
21
|
+
GeoNames: "geonames",
|
|
22
|
+
} as const
|
|
23
|
+
|
|
24
|
+
export type GazetteerSourceName = (typeof GazetteerSourceName)[keyof typeof GazetteerSourceName]
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The location of each gazetteer source.
|
|
28
|
+
*
|
|
29
|
+
* Who's On First points to the `mailwoman` organization.
|
|
30
|
+
* It holds the forks of the `whosonfirst-data-admin-<cc>` repositories the admin build clones.
|
|
31
|
+
*
|
|
32
|
+
* Each fork's upstream is the repository of the same name under `whosonfirst-data`.
|
|
33
|
+
*/
|
|
34
|
+
export const GAZETTEER_SOURCE_LOCATIONS: Readonly<Record<GazetteerSourceName, SourceLocation>> = {
|
|
35
|
+
[GazetteerSourceName.WhosOnFirst]: { title: "Who's On First", url: "https://github.com/mailwoman" },
|
|
36
|
+
[GazetteerSourceName.OvertureDivisions]: {
|
|
37
|
+
title: "Overture Maps divisions theme",
|
|
38
|
+
url: "https://docs.overturemaps.org/guides/divisions/",
|
|
39
|
+
},
|
|
40
|
+
[GazetteerSourceName.GeoNames]: { title: "GeoNames", url: "https://download.geonames.org/export/dump/" },
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The location of a source a manifest records, or null when the name has none here.
|
|
45
|
+
*/
|
|
46
|
+
export function gazetteerSourceLocation(name: string): SourceLocation | null {
|
|
47
|
+
return Object.hasOwn(GAZETTEER_SOURCE_LOCATIONS, name)
|
|
48
|
+
? GAZETTEER_SOURCE_LOCATIONS[name as GazetteerSourceName]
|
|
49
|
+
: null
|
|
50
|
+
}
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* @file Pass 2 of the candidate build: explode `place_search.alt_names` into distinct alias rows.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { isOverturePartID } from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
8
9
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
9
10
|
import { tableExists } from "@mailwoman/sqlite/introspection"
|
|
10
11
|
|
|
11
12
|
import type { PlaceAttrs, StageRow } from "#candidate/place-attrs"
|
|
12
13
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
13
14
|
import { ALIAS_SEPARATOR } from "#fts"
|
|
15
|
+
import { type NameKey, normalizeLocalityForKey, withoutApostropheLikeMarks } from "#labels/street/normalize"
|
|
14
16
|
import type { WOFDatabase } from "#schema"
|
|
15
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* The official name of every current region, keyed `${country id}\0${name key}` →
|
|
@@ -22,14 +23,19 @@ import { normalizeLocalityForKey } from "#street/normalize"
|
|
|
22
23
|
*
|
|
23
24
|
* The positive evidence behind the alias refusal below: a name is refused from a region's
|
|
24
25
|
* bag only when another region of the same country holds it as its official name.
|
|
26
|
+
*
|
|
27
|
+
* `rest` leaves out the regions of the Overture Divisions part and `all` holds every region.
|
|
28
|
+
* The gazetteer is a Collective Database whose Overture part is ODbL, so a region outside that part
|
|
29
|
+
* reads `rest`, and an Overture division's official name never refuses a WOF or GeoNames region's alias.
|
|
25
30
|
*/
|
|
26
31
|
function officialNameHoldersByRegion(
|
|
27
32
|
src: DatabaseClient<WOFDatabase>,
|
|
28
33
|
ccID: (code: string | null) => number
|
|
29
|
-
): Map<string, number> {
|
|
30
|
-
const
|
|
34
|
+
): { rest: Map<string, number>; all: Map<string, number> } {
|
|
35
|
+
const rest = new Map<string, number>()
|
|
36
|
+
const all = new Map<string, number>()
|
|
31
37
|
|
|
32
|
-
if (!tableExists(src, "names")) return
|
|
38
|
+
if (!tableExists(src, "names")) return { rest, all }
|
|
33
39
|
|
|
34
40
|
for (const r of src
|
|
35
41
|
.prepare(
|
|
@@ -41,11 +47,18 @@ function officialNameHoldersByRegion(
|
|
|
41
47
|
const k = normalizeLocalityForKey(String(r.name ?? ""))
|
|
42
48
|
|
|
43
49
|
if (k) {
|
|
44
|
-
|
|
50
|
+
const key = `${ccID(r.country as string | null)}\0${k}`
|
|
51
|
+
const id = Number(r.id)
|
|
52
|
+
|
|
53
|
+
all.set(key, id)
|
|
54
|
+
|
|
55
|
+
if (!isOverturePartID(id)) {
|
|
56
|
+
rest.set(key, id)
|
|
57
|
+
}
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
|
|
48
|
-
return
|
|
61
|
+
return { rest, all }
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
/**
|
|
@@ -55,6 +68,13 @@ function officialNameHoldersByRegion(
|
|
|
55
68
|
* With `regionPlacetypeID` and `ccID` given, a region's alias that's another same-country region's
|
|
56
69
|
* official name is refused and counted rather than staged (see {@link officialNameHoldersByRegion}).
|
|
57
70
|
* Without them the pass stages every alias.
|
|
71
|
+
*
|
|
72
|
+
* Each key holding an apostrophe-like mark, the primary's included, also stages
|
|
73
|
+
* its mark-free form ({@link withoutApostropheLikeMarks}).
|
|
74
|
+
* The count excludes those forms.
|
|
75
|
+
*
|
|
76
|
+
* The gloss detector compares the count with its threshold, and a mark-free form
|
|
77
|
+
* spells a name the count already includes.
|
|
58
78
|
*/
|
|
59
79
|
export function explodeAliasBags(
|
|
60
80
|
src: DatabaseClient<WOFDatabase>,
|
|
@@ -72,16 +92,23 @@ export function explodeAliasBags(
|
|
|
72
92
|
*/
|
|
73
93
|
bareName?: (countryID: number, alias: string) => string | null
|
|
74
94
|
} = {}
|
|
75
|
-
): {
|
|
95
|
+
): {
|
|
96
|
+
nAlias: number
|
|
97
|
+
nBare: number
|
|
98
|
+
nMarkFree: number
|
|
99
|
+
keyCounts: Map<number, number>
|
|
100
|
+
regionOfficialRefused: number
|
|
101
|
+
} {
|
|
76
102
|
let nAlias = 0
|
|
77
103
|
let nBare = 0
|
|
104
|
+
let nMarkFree = 0
|
|
78
105
|
let regionOfficialRefused = 0
|
|
79
106
|
const keyCounts = new Map<number, number>()
|
|
80
107
|
|
|
81
108
|
const official =
|
|
82
109
|
typeof opts.regionPlacetypeID === "number" && opts.ccID
|
|
83
110
|
? officialNameHoldersByRegion(src, opts.ccID)
|
|
84
|
-
: new Map<string, number>()
|
|
111
|
+
: { rest: new Map<string, number>(), all: new Map<string, number>() }
|
|
85
112
|
|
|
86
113
|
out.exec("BEGIN")
|
|
87
114
|
|
|
@@ -90,14 +117,36 @@ export function explodeAliasBags(
|
|
|
90
117
|
const a = attrs.get(id)
|
|
91
118
|
const alt = r.alt_names as string | null
|
|
92
119
|
|
|
93
|
-
if (!a
|
|
120
|
+
if (!a) continue
|
|
94
121
|
const seen = new Set<string>([a.pkey])
|
|
122
|
+
const markFree = new Set<string>()
|
|
95
123
|
const isRegion = a.ptid === opts.regionPlacetypeID
|
|
124
|
+
const holders = isOverturePartID(id) ? official.all : official.rest
|
|
125
|
+
|
|
126
|
+
const refused = (k: string): boolean => {
|
|
127
|
+
if (!isRegion) return false
|
|
128
|
+
const holder = holders.get(`${a.cid}\0${k}`)
|
|
129
|
+
|
|
130
|
+
return typeof holder === "number" && holder !== id
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Returns 1 when it staged a row, so the caller adds the result to the count.
|
|
134
|
+
const stageMarkFree = (k: NameKey): number => {
|
|
135
|
+
const free = withoutApostropheLikeMarks(k)
|
|
136
|
+
|
|
137
|
+
if (!free || free === k || seen.has(free) || markFree.has(free) || refused(free)) return 0
|
|
138
|
+
markFree.add(free)
|
|
139
|
+
stageRow(free, a, id, 0)
|
|
140
|
+
|
|
141
|
+
return 1
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
nMarkFree += stageMarkFree(a.pkey as NameKey)
|
|
96
145
|
|
|
97
146
|
// The writer space-pads each separator and appends a trailing one, so every piece
|
|
98
147
|
// includes surrounding whitespace and the last one is empty.
|
|
99
148
|
// `normalizeLocalityForKey` folds both away.
|
|
100
|
-
for (const piece of alt
|
|
149
|
+
for (const piece of alt?.split(ALIAS_SEPARATOR) ?? []) {
|
|
101
150
|
const bare = opts.bareName?.(a.cid, piece.trim())
|
|
102
151
|
const keys = [normalizeLocalityForKey(piece), bare ? normalizeLocalityForKey(bare) : ""]
|
|
103
152
|
|
|
@@ -105,30 +154,35 @@ export function explodeAliasBags(
|
|
|
105
154
|
if (!k || seen.has(k)) continue
|
|
106
155
|
seen.add(k)
|
|
107
156
|
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (typeof holder === "number" && holder !== id) {
|
|
112
|
-
regionOfficialRefused++
|
|
157
|
+
if (refused(k)) {
|
|
158
|
+
regionOfficialRefused++
|
|
113
159
|
|
|
114
|
-
|
|
115
|
-
}
|
|
160
|
+
continue
|
|
116
161
|
}
|
|
117
162
|
|
|
118
|
-
|
|
163
|
+
// A mark-free form staged earlier now arrives as a name of its own, so it counts as one.
|
|
164
|
+
if (markFree.delete(k)) {
|
|
165
|
+
nMarkFree--
|
|
166
|
+
} else {
|
|
167
|
+
stageRow(k, a, id, 0)
|
|
168
|
+
}
|
|
119
169
|
|
|
120
170
|
if (position) {
|
|
121
171
|
nBare++
|
|
122
172
|
} else {
|
|
123
173
|
nAlias++
|
|
124
174
|
}
|
|
175
|
+
|
|
176
|
+
nMarkFree += stageMarkFree(k as NameKey)
|
|
125
177
|
}
|
|
126
178
|
}
|
|
127
179
|
|
|
128
|
-
|
|
180
|
+
if (alt) {
|
|
181
|
+
keyCounts.set(id, seen.size)
|
|
182
|
+
}
|
|
129
183
|
}
|
|
130
184
|
|
|
131
185
|
out.exec("COMMIT")
|
|
132
186
|
|
|
133
|
-
return { nAlias, nBare, keyCounts, regionOfficialRefused }
|
|
187
|
+
return { nAlias, nBare, nMarkFree, keyCounts, regionOfficialRefused }
|
|
134
188
|
}
|
|
@@ -76,7 +76,7 @@ import { sql, type Kysely } from "kysely"
|
|
|
76
76
|
// parameter is invariant, so the DDL functions must take the full database type their caller holds.
|
|
77
77
|
// Erased at runtime.
|
|
78
78
|
import type { CandidateDatabase } from "#candidate/schema"
|
|
79
|
-
import type { NameKey } from "#street/normalize"
|
|
79
|
+
import type { NameKey } from "#labels/street/normalize"
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* The deepest chain the sidecar stores per place.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @file Pass 3b of the candidate build — the containment sidecar (closure rows + interval labels).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { isOverturePartID } from "@mailwoman/core/resolver/synthetic-id-ranges"
|
|
8
9
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
9
10
|
|
|
10
11
|
import { placetypeDepth } from "#ancestry"
|
|
@@ -77,7 +78,15 @@ export async function buildAncestorsSidecar(ctx: {
|
|
|
77
78
|
ancestorRows++
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
// The gazetteer is a Collective Database whose Overture Divisions part is ODbL.
|
|
82
|
+
// The interval tree links a place only to a parent of its own part, so an Overture division
|
|
83
|
+
// under a WOF record leaves that record's labels as they are without the Overture divisions.
|
|
84
|
+
// The closure rows above keep every edge, and containment across the parts
|
|
85
|
+
// reads them instead of the labels.
|
|
86
|
+
const childOverture = isOverturePartID(childID)
|
|
87
|
+
const canonical = edges.find((edge) => isOverturePartID(edge.aid) === childOverture)?.aid
|
|
88
|
+
|
|
89
|
+
if (typeof canonical !== "number") return
|
|
81
90
|
|
|
82
91
|
canonicalParentOf.set(childID, canonical)
|
|
83
92
|
|
|
@@ -138,8 +147,10 @@ export async function buildAncestorsSidecar(ctx: {
|
|
|
138
147
|
|
|
139
148
|
const roots = [...forest].filter((id) => !canonicalParentOf.has(id))
|
|
140
149
|
|
|
150
|
+
// The Overture part's trees are numbered after every other tree, so the other parts' labels
|
|
151
|
+
// are the labels a build without the Overture divisions gives them.
|
|
141
152
|
// oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass built
|
|
142
|
-
roots.sort((a, b) => a - b)
|
|
153
|
+
roots.sort((a, b) => Number(isOverturePartID(a)) - Number(isOverturePartID(b)) || a - b)
|
|
143
154
|
|
|
144
155
|
let counter = 0
|
|
145
156
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { bareAdminName } from "@mailwoman/codex/country/bare-admin-names"
|
|
9
9
|
|
|
10
10
|
import type { PlaceAttrs, StageRow } from "#candidate/place-attrs"
|
|
11
|
-
import { normalizeLocalityForKey } from "#street/normalize"
|
|
11
|
+
import { normalizeLocalityForKey } from "#labels/street/normalize"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Stages an alias row under the bare form of every place name a country writes with an admin-unit suffix.
|