@mailwoman/resolver-wof-sqlite 11.2.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/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/build/candidate.ts +136 -40
- package/lib/build/slim.ts +4 -1
- package/lib/build/sources.ts +50 -0
- package/lib/candidate/alias-bags.ts +22 -8
- 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 +86 -8
- package/lib/candidate/key-fold.ts +1 -1
- package/lib/candidate/lookup.ts +79 -48
- package/lib/candidate/name-roles.ts +1 -1
- package/lib/candidate/nickname-namesakes.ts +8 -1
- 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/builder.ts +8 -6
- package/lib/fst/deserialize-web.ts +1 -1
- package/lib/fst/freshness.ts +2 -2
- package/lib/fst/serialize.ts +1 -1
- package/lib/fts/query.ts +1 -1
- package/lib/{search-fetch.ts → fts/search-fetch.ts} +2 -2
- package/lib/geonames/aliases.ts +37 -33
- 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 +242 -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} +5 -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/build/candidate.d.ts +26 -1
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +71 -32
- 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 +0 -3
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +22 -7
- 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 +53 -8
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/key-fold.d.ts +1 -1
- package/out/candidate/key-fold.d.ts.map +1 -1
- package/out/candidate/key-fold.js +1 -1
- package/out/candidate/key-fold.js.map +1 -1
- package/out/candidate/lookup.d.ts +5 -1
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +59 -43
- 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 +0 -4
- package/out/candidate/nickname-namesakes.d.ts.map +1 -1
- package/out/candidate/nickname-namesakes.js +12 -1
- package/out/candidate/nickname-namesakes.js.map +1 -1
- 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/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/freshness.js +2 -2
- package/out/fst/freshness.js.map +1 -1
- package/out/fst/serialize.js +1 -1
- 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 +17 -17
- 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/{street → labels/street}/normalize.d.ts +85 -27
- package/out/labels/street/normalize.d.ts.map +1 -0
- package/out/{street → labels/street}/normalize.js +162 -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/ranking/primary-preference.d.ts.map +1 -0
- package/out/{primary-preference.js → ranking/primary-preference.js} +4 -0
- 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.map +1 -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/importance-source.d.ts.map +0 -1
- package/out/importance-source.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.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/{importance-source.ts → schema/importance-source.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/{primary-preference.d.ts → ranking/primary-preference.d.ts} +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/out/{importance-source.d.ts → schema/importance-source.d.ts} +0 -0
- /package/out/{importance-source.js → schema/importance-source.js} +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file The candidate build's Overture twins: a matched division answers only on the keys its WOF record lacks.
|
|
6
|
+
*
|
|
7
|
+
* The admin gazetteer writes every Overture division as its own row, including a division that matched a
|
|
8
|
+
* WOF record, and records the pair in `overture_wof_match`. Both rows staged in full would return one place
|
|
9
|
+
* twice for every name the two share. The pass deletes each matched division's staged rows on the keys its
|
|
10
|
+
* WOF record also holds, so the division answers only on the names WOF lacks.
|
|
11
|
+
*
|
|
12
|
+
* It changes only the Overture part's rows. The WOF rows it reads are left as they are, so the gazetteer
|
|
13
|
+
* stays a Collective Database whose Overture Divisions part is ODbL. The match table is copied into the
|
|
14
|
+
* artifact as a table of that part.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
18
|
+
|
|
19
|
+
import type { CandidateDatabase } from "#candidate/schema"
|
|
20
|
+
import type { WOFDatabase } from "#schema"
|
|
21
|
+
import { createOvertureWOFMatchTable, OVERTURE_WOF_MATCH_TABLE, readOvertureWOFMatches } from "#schema/overture-match"
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Copies the admin database's `overture_wof_match` into the candidate and drops each
|
|
25
|
+
* matched division's staged rows on keys its WOF record holds.
|
|
26
|
+
*
|
|
27
|
+
* Runs on `cand_stage` after the nickname refusal, so the comparison is with the WOF rows that stay.
|
|
28
|
+
*
|
|
29
|
+
* @returns The matches copied and the staged rows dropped, or `null`
|
|
30
|
+
* when the admin database predates the table.
|
|
31
|
+
* Such a database's matched divisions wrote no rows of their own.
|
|
32
|
+
*/
|
|
33
|
+
export async function stageOvertureTwins(
|
|
34
|
+
src: DatabaseClient<WOFDatabase>,
|
|
35
|
+
out: DatabaseClient<CandidateDatabase>
|
|
36
|
+
): Promise<{ matches: number; rowsDropped: number } | null> {
|
|
37
|
+
const matches = readOvertureWOFMatches(src)
|
|
38
|
+
|
|
39
|
+
if (!matches) return null
|
|
40
|
+
|
|
41
|
+
await createOvertureWOFMatchTable(out)
|
|
42
|
+
|
|
43
|
+
const insert = out.prepare(`INSERT INTO ${OVERTURE_WOF_MATCH_TABLE} (overture_id, wof_id, match_by) VALUES (?, ?, ?)`)
|
|
44
|
+
|
|
45
|
+
out.exec("BEGIN")
|
|
46
|
+
|
|
47
|
+
for (const match of matches) {
|
|
48
|
+
insert.run(match.overture_id, match.wof_id, match.match_by)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
out.exec("COMMIT")
|
|
52
|
+
|
|
53
|
+
// `cand_stage` has no index while it stages, so each side is one scan: the WOF records' keys
|
|
54
|
+
// are collected under their divisions' ids, then every division row is checked against that table.
|
|
55
|
+
out.exec(
|
|
56
|
+
"CREATE TEMP TABLE twin_wof (wof_id INTEGER NOT NULL, overture_id INTEGER NOT NULL, PRIMARY KEY (wof_id, overture_id)) WITHOUT ROWID"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
out.exec(`INSERT OR IGNORE INTO twin_wof SELECT wof_id, overture_id FROM ${OVERTURE_WOF_MATCH_TABLE}`)
|
|
60
|
+
|
|
61
|
+
out.exec(
|
|
62
|
+
"CREATE TEMP TABLE twin_key (overture_id INTEGER NOT NULL, name_key TEXT NOT NULL, PRIMARY KEY (overture_id, name_key)) WITHOUT ROWID"
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
out.exec(
|
|
66
|
+
`INSERT OR IGNORE INTO twin_key
|
|
67
|
+
SELECT t.overture_id, w.name_key FROM cand_stage w JOIN twin_wof t ON t.wof_id = w.spr_id`
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
const rowsDropped = Number(
|
|
71
|
+
out
|
|
72
|
+
.prepare(
|
|
73
|
+
`DELETE FROM cand_stage
|
|
74
|
+
WHERE EXISTS (SELECT 1 FROM twin_key t WHERE t.overture_id = cand_stage.spr_id AND t.name_key = cand_stage.name_key)`
|
|
75
|
+
)
|
|
76
|
+
.run().changes
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
out.exec("DROP TABLE twin_key")
|
|
80
|
+
out.exec("DROP TABLE twin_wof")
|
|
81
|
+
|
|
82
|
+
return { matches: matches.length, rowsDropped }
|
|
83
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @file The per-place record every candidate-staging pass writes its rows from.
|
|
6
6
|
*
|
|
7
7
|
* Pass 1 reduces each current `spr` row to one {@link PlaceAttrs}. Every later pass (alias bags,
|
|
8
|
-
* region abbreviations, country display names, the currency backfill, the extract
|
|
8
|
+
* region abbreviations, country display names, the currency backfill, the extract rows) discovers
|
|
9
9
|
* additional name keys for a place already in that map and stages a row against the same record.
|
|
10
10
|
* That keeps each candidate row denormalized without re-reading the source. A pass therefore needs
|
|
11
11
|
* exactly four values: the key, place, row ID, plus a flag for the place's canonical name.
|
|
@@ -45,7 +45,7 @@ export interface PlaceAttrs {
|
|
|
45
45
|
* Stages one candidate row with a normalized name key, place, source ID,
|
|
46
46
|
* plus a canonical-name flag (`is_primary`).
|
|
47
47
|
*
|
|
48
|
-
* `sid` is passed separately rather than read off the place because
|
|
48
|
+
* `sid` is passed separately rather than read off the place because the extract-rows pass
|
|
49
49
|
* and the alias pass stage rows for ids the admin `attrs` map never held.
|
|
50
50
|
*/
|
|
51
51
|
export type StageRow = (k: string, a: PlaceAttrs, sid: number, isPrimary: number) => void
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pages through a candidate gazetteer's postcode places in ascending `spr_id`
|
|
6
|
+
* order, inside a bounding box.
|
|
7
|
+
*
|
|
8
|
+
* A page reads only {@link CANDIDATE_POSTCODE_PLACE_INDEX}: the index holds each
|
|
9
|
+
* postcode place's primary rows in `spr_id` order with their point and name.
|
|
10
|
+
* Each entry also stores the clustered key, and its `country_id` identifies the country.
|
|
11
|
+
*
|
|
12
|
+
* A page continues after the last id the previous page returned, so the database
|
|
13
|
+
* seeks to it and a deep page costs what the first page costs.
|
|
14
|
+
*
|
|
15
|
+
* A box filters the walk by point, so a box holding few postcode places reads more
|
|
16
|
+
* of the index before its page fills, and never more than the index once.
|
|
17
|
+
*
|
|
18
|
+
* The statements stay raw because a partial index is used only by a query that
|
|
19
|
+
* states its literal, and `INDEXED BY` has no query-builder form.
|
|
20
|
+
* `INDEXED BY` makes a statement fail to prepare rather than scan the table when the index is missing.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { DatabaseClient, type StatementSync } from "@mailwoman/sqlite/client"
|
|
24
|
+
import { indexExists, tableExists } from "@mailwoman/sqlite/introspection"
|
|
25
|
+
import { SQLiteLookup, type SQLiteLookupOptions } from "@mailwoman/sqlite/lookup"
|
|
26
|
+
import type { PathBuilderLike } from "path-ts"
|
|
27
|
+
|
|
28
|
+
import { CANDIDATE_POSTCODE_PLACE_INDEX, type CandidateDatabase, POSTCODE_PLACETYPE } from "#candidate/schema"
|
|
29
|
+
import type { BrowsedPlace, BrowsePageRequest } from "#lookup/browse"
|
|
30
|
+
import type { WOFDatabase } from "#schema"
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Whether a WOF database such as `postalcode-us.db` holds at least one current postcode place in `spr`.
|
|
34
|
+
*
|
|
35
|
+
* A database without `spr` holds none.
|
|
36
|
+
*/
|
|
37
|
+
export function wofDatabaseHoldsPostcodes(databasePath: PathBuilderLike): boolean {
|
|
38
|
+
using db = new DatabaseClient<WOFDatabase>(databasePath, { readOnly: true })
|
|
39
|
+
|
|
40
|
+
if (!tableExists(db, "spr")) return false
|
|
41
|
+
|
|
42
|
+
return Boolean(
|
|
43
|
+
db.prepare("SELECT 1 FROM spr WHERE placetype = ? AND is_current != 0 LIMIT 1").get(POSTCODE_PLACETYPE)
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface PostcodeRow {
|
|
48
|
+
spr_id: number
|
|
49
|
+
country_id: number
|
|
50
|
+
latitude: number | null
|
|
51
|
+
longitude: number | null
|
|
52
|
+
name: string | null
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The statements of a gazetteer that records the postcode placetype.
|
|
57
|
+
*/
|
|
58
|
+
interface PostcodeStatements {
|
|
59
|
+
any: StatementSync
|
|
60
|
+
place: StatementSync
|
|
61
|
+
page: StatementSync
|
|
62
|
+
pageInBox: StatementSync
|
|
63
|
+
pageAcrossAntimeridian: StatementSync
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Pages through the postcode places of a candidate gazetteer such as `candidate.db`.
|
|
68
|
+
*
|
|
69
|
+
* A postcode place appears once, read from the primary row with the least name.
|
|
70
|
+
*/
|
|
71
|
+
export class PostcodePlaceBrowser extends SQLiteLookup<CandidateDatabase> {
|
|
72
|
+
/**
|
|
73
|
+
* Null when the gazetteer records no postcode placetype.
|
|
74
|
+
*/
|
|
75
|
+
readonly #statements: PostcodeStatements | null
|
|
76
|
+
readonly #countryCodes: Map<number, string>
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @throws When the gazetteer records the postcode placetype but lacks
|
|
80
|
+
* {@link CANDIDATE_POSTCODE_PLACE_INDEX}, because a page would then scan the whole candidate table.
|
|
81
|
+
*/
|
|
82
|
+
constructor(options: SQLiteLookupOptions<CandidateDatabase>) {
|
|
83
|
+
super(options)
|
|
84
|
+
|
|
85
|
+
const placetype = this.database
|
|
86
|
+
.prepare("SELECT id FROM placetype_codes WHERE placetype = ?")
|
|
87
|
+
.get(POSTCODE_PLACETYPE) as { id: number } | undefined
|
|
88
|
+
|
|
89
|
+
if (placetype && !indexExists(this.database, CANDIDATE_POSTCODE_PLACE_INDEX)) {
|
|
90
|
+
this[Symbol.dispose]()
|
|
91
|
+
|
|
92
|
+
throw new Error(`the candidate gazetteer has no ${CANDIDATE_POSTCODE_PLACE_INDEX} index`)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.#statements = placetype ? this.#prepare(placetype.id) : null
|
|
96
|
+
|
|
97
|
+
const countries = this.database.prepare("SELECT id, code FROM country_codes").all() as Array<{
|
|
98
|
+
id: number
|
|
99
|
+
code: string
|
|
100
|
+
}>
|
|
101
|
+
|
|
102
|
+
this.#countryCodes = new Map(countries.map(({ id, code }) => [id, code]))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#prepare(placetypeID: number): PostcodeStatements {
|
|
106
|
+
const from =
|
|
107
|
+
`FROM candidate INDEXED BY ${CANDIDATE_POSTCODE_PLACE_INDEX} ` +
|
|
108
|
+
`WHERE placetype_id = ${Math.trunc(placetypeID)} AND is_primary = 1`
|
|
109
|
+
|
|
110
|
+
const select = `SELECT spr_id, country_id, latitude, longitude, MIN(name) AS name ${from}`
|
|
111
|
+
|
|
112
|
+
const page = (box: string) =>
|
|
113
|
+
this.database.prepare(`${select} AND spr_id > ? ${box} GROUP BY spr_id ORDER BY spr_id LIMIT ?`)
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
any: this.database.prepare(`SELECT 1 ${from} LIMIT 1`),
|
|
117
|
+
place: this.database.prepare(`${select} AND spr_id = ? GROUP BY spr_id`),
|
|
118
|
+
page: page(""),
|
|
119
|
+
pageInBox: page("AND latitude BETWEEN ? AND ? AND longitude BETWEEN ? AND ?"),
|
|
120
|
+
pageAcrossAntimeridian: page("AND latitude BETWEEN ? AND ? AND (longitude >= ? OR longitude <= ?)"),
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#toPlace(row: PostcodeRow): BrowsedPlace {
|
|
125
|
+
return {
|
|
126
|
+
id: row.spr_id,
|
|
127
|
+
name: row.name ?? "",
|
|
128
|
+
placetype: POSTCODE_PLACETYPE,
|
|
129
|
+
country: this.#countryCodes.get(row.country_id) ?? "",
|
|
130
|
+
latitude: row.latitude ?? 0,
|
|
131
|
+
longitude: row.longitude ?? 0,
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Whether the gazetteer holds at least one postcode place.
|
|
137
|
+
*/
|
|
138
|
+
holdsPostcodes(): boolean {
|
|
139
|
+
return Boolean(this.#statements?.any.get())
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The postcode place with this id, or null when the gazetteer holds no postcode place with it.
|
|
144
|
+
*/
|
|
145
|
+
async place(id: number): Promise<BrowsedPlace | null> {
|
|
146
|
+
const row = this.#statements?.place.get(id) as PostcodeRow | undefined
|
|
147
|
+
|
|
148
|
+
return row ? this.#toPlace(row) : null
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The postcode places the request selects, in ascending id order, at most `limit` of them.
|
|
153
|
+
*/
|
|
154
|
+
async page({ box, after, limit }: BrowsePageRequest): Promise<BrowsedPlace[]> {
|
|
155
|
+
const statements = this.#statements
|
|
156
|
+
|
|
157
|
+
if (!statements) return []
|
|
158
|
+
|
|
159
|
+
const cursor = after ?? Number.MIN_SAFE_INTEGER
|
|
160
|
+
|
|
161
|
+
let rows: unknown[]
|
|
162
|
+
|
|
163
|
+
if (!box) {
|
|
164
|
+
rows = statements.page.all(cursor, limit)
|
|
165
|
+
} else {
|
|
166
|
+
const statement = box.minLon <= box.maxLon ? statements.pageInBox : statements.pageAcrossAntimeridian
|
|
167
|
+
|
|
168
|
+
rows = statement.all(cursor, box.minLat, box.maxLat, box.minLon, box.maxLon, limit)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return (rows as PostcodeRow[]).map((row) => this.#toPlace(row))
|
|
172
|
+
}
|
|
173
|
+
}
|
package/lib/candidate/schema.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import { sql, type Kysely } from "kysely"
|
|
5
5
|
|
|
6
6
|
import type { CandidateAncestorsDatabase } from "#candidate/ancestors/schema"
|
|
7
|
-
import type { CapitalTable } from "#capital-schema"
|
|
8
|
-
import type { NameKey } from "#street/normalize"
|
|
7
|
+
import type { CapitalTable } from "#candidate/capital-schema"
|
|
8
|
+
import type { NameKey } from "#labels/street/normalize"
|
|
9
|
+
import type { OvertureWOFMatchTable } from "#schema/overture-match"
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* One candidate row.
|
|
@@ -102,6 +103,11 @@ export interface CandidateDatabase extends CandidateAncestorsDatabase {
|
|
|
102
103
|
* See capital-schema.ts.
|
|
103
104
|
*/
|
|
104
105
|
capital: CapitalTable
|
|
106
|
+
/**
|
|
107
|
+
* Which WOF record each matched Overture division is, a table of the Overture Divisions part.
|
|
108
|
+
* See overture-match-schema.ts.
|
|
109
|
+
*/
|
|
110
|
+
overture_wof_match: OvertureWOFMatchTable
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
/**
|
|
@@ -206,3 +212,38 @@ export async function createCandidateTable(db: Kysely<CandidateDatabase>): Promi
|
|
|
206
212
|
.modifyEnd(sql`without rowid`)
|
|
207
213
|
.execute()
|
|
208
214
|
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The partial index over the primary rows of postcode places, in `spr_id` order.
|
|
218
|
+
*
|
|
219
|
+
* It holds `spr_id`, the point and the name.
|
|
220
|
+
* Each entry also stores the clustered key.
|
|
221
|
+
*
|
|
222
|
+
* A page of postcode places in id order, with or without a box, therefore reads only the index.
|
|
223
|
+
*/
|
|
224
|
+
export const CANDIDATE_POSTCODE_PLACE_INDEX = "candidate_postcode_place"
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The placetype of postcode places in `placetype_codes`.
|
|
228
|
+
*/
|
|
229
|
+
export const POSTCODE_PLACETYPE = "postalcode"
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Create {@link CANDIDATE_POSTCODE_PLACE_INDEX} on the built `candidate` table.
|
|
233
|
+
*
|
|
234
|
+
* A partial index selects its rows with a literal, so the placetype's dictionary id is
|
|
235
|
+
* written into the index and a reader states the same literal to use it.
|
|
236
|
+
*
|
|
237
|
+
* @param placetypeID The id `placetype_codes` gives {@link POSTCODE_PLACETYPE}.
|
|
238
|
+
*/
|
|
239
|
+
export async function createCandidatePostcodePlaceIndex(
|
|
240
|
+
db: Kysely<CandidateDatabase>,
|
|
241
|
+
placetypeID: number
|
|
242
|
+
): Promise<void> {
|
|
243
|
+
await db.schema
|
|
244
|
+
.createIndex(CANDIDATE_POSTCODE_PLACE_INDEX)
|
|
245
|
+
.on("candidate")
|
|
246
|
+
.columns(["spr_id", "latitude", "longitude", "name"])
|
|
247
|
+
.where(sql<boolean>`placetype_id = ${sql.lit(placetypeID)} AND is_primary = 1`)
|
|
248
|
+
.execute()
|
|
249
|
+
}
|
package/lib/candidate/scoring.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { compareReferential, referentialFromPopulation } from "@mailwoman/core/r
|
|
|
5
5
|
import { haversine } from "@mailwoman/spatial/geometries/point/distance"
|
|
6
6
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
7
7
|
|
|
8
|
-
import { exactMatchIDs, officialNameIDs } from "#exact-match"
|
|
9
8
|
import { foldQueryText } from "#fts"
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import type { FindPlaceQuery, PlaceCandidate, WOFPlacetype } from "#types"
|
|
9
|
+
import type { RawSearchRow } from "#fts/search-fetch"
|
|
10
|
+
import { exactMatchIDs, officialNameIDs } from "#lookup/exact-match"
|
|
11
|
+
import type { FindPlaceQuery, PlaceCandidate, WOFPlacetype } from "#lookup/types"
|
|
12
|
+
import { populationBoostTerm, type RankingWeights } from "#ranking/weights"
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Score one raw FTS row into a `PlaceCandidate`: the weighted sum over the negated
|
package/lib/convention.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* The strategy implementations live in `lookup.ts` and are registered by name.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { FindPlaceQuery, PlaceCandidate } from "#types"
|
|
10
|
+
import type { FindPlaceQuery, PlaceCandidate } from "#lookup/types"
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Soft-scoring weights for the `postcode_area_resolution` strategy: `pc·S_pc + name·S_name + pop·S_pop`.
|
package/lib/env.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Environment variables name the WOF SQLite artifacts this resolver opens
|
|
6
|
-
* and the development weights the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* and the development weights overlay that the linker materializes.
|
|
7
|
+
*
|
|
8
|
+
* CLI flags (`--resolve-db`, …) override these values at the call site.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { $public as corePublic, liveEnv } from "@mailwoman/core/env"
|
|
@@ -43,6 +43,18 @@ export const PublicWOFSQLiteEnvSchema = z.object({
|
|
|
43
43
|
title: "Development tokenizer",
|
|
44
44
|
description: "Path to the tokenizer artifact linked for local neural-weights development.",
|
|
45
45
|
}),
|
|
46
|
+
/**
|
|
47
|
+
* Set by GitHub Actions itself.
|
|
48
|
+
*
|
|
49
|
+
* The dev weights linker refuses to write the shared overlay under it.
|
|
50
|
+
* Release-kit's view extends this one and uses it as the predicate for npm `--provenance`,
|
|
51
|
+
* because npm can only mint an attestation from a CI provider it supports.
|
|
52
|
+
*/
|
|
53
|
+
GITHUB_ACTIONS: z.coerce.boolean().default(false).meta({
|
|
54
|
+
title: "GitHub Actions",
|
|
55
|
+
description:
|
|
56
|
+
"Whether the process is running under GitHub Actions. The dev weights linker then requires `MAILWOMAN_WEIGHTS_OVERLAY_ROOT`, and release publication enables npm provenance.",
|
|
57
|
+
}),
|
|
46
58
|
})
|
|
47
59
|
|
|
48
60
|
/**
|
package/lib/fst/builder.ts
CHANGED
|
@@ -20,8 +20,8 @@ import { readWOFSourceIdentity } from "#fst/freshness"
|
|
|
20
20
|
import type { FSTNode } from "#fst/matcher"
|
|
21
21
|
import { FSTMatcher, normalizeTokens } from "#fst/matcher"
|
|
22
22
|
import type { BuildFSTOpts, BuildFSTResult, FSTProvenance, PlaceEntry, PlacetypeID } from "#fst/types"
|
|
23
|
-
import { loadImportanceSplit } from "#place-importance-schema"
|
|
24
23
|
import type { WOFDatabase } from "#schema"
|
|
24
|
+
import { loadImportanceSplit } from "#schema/place-importance"
|
|
25
25
|
|
|
26
26
|
const DEFAULT_PLACETYPES: PlacetypeID[] = [
|
|
27
27
|
"country",
|
|
@@ -33,6 +33,8 @@ const DEFAULT_PLACETYPES: PlacetypeID[] = [
|
|
|
33
33
|
"neighbourhood",
|
|
34
34
|
]
|
|
35
35
|
|
|
36
|
+
// country-branch: an FST built with no country list holds the places of one country, the US.
|
|
37
|
+
// The commit that added the default recorded no reason, and a required `countries` option would replace it.
|
|
36
38
|
const DEFAULT_COUNTRIES = ["US"]
|
|
37
39
|
const DEFAULT_LANGUAGES = ["eng", ""]
|
|
38
40
|
/**
|
|
@@ -88,13 +90,13 @@ export async function buildFSTFromWOF(opts: BuildFSTOpts): Promise<{
|
|
|
88
90
|
progress("spr", `Loaded ${sprRows.length} places`)
|
|
89
91
|
|
|
90
92
|
// An FST ships in npm packages whose license cannot include the Open Database License,
|
|
91
|
-
// so no place from
|
|
93
|
+
// so no place the admin build added from Overture Divisions may reach one.
|
|
92
94
|
const overturePlaces = sprRows.filter((row) => row.id >= OVERTURE_ID_BASE && row.id < GEONAMES_ID_BASE).length
|
|
93
95
|
|
|
94
96
|
if (overturePlaces) {
|
|
95
97
|
throw new Error(
|
|
96
|
-
`buildFSTFromWOF: ${overturePlaces} of ${sprRows.length} places for [${countries}] come from
|
|
97
|
-
"Divisions
|
|
98
|
+
`buildFSTFromWOF: ${overturePlaces} of ${sprRows.length} places for [${countries}] come from Overture ` +
|
|
99
|
+
"Divisions, which is ODbL; build the FST from countries the admin build adds no Overture places for"
|
|
98
100
|
)
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -204,9 +206,9 @@ export async function buildFSTFromWOF(opts: BuildFSTOpts): Promise<{
|
|
|
204
206
|
|
|
205
207
|
const allLanguages = languages.includes("*")
|
|
206
208
|
|
|
207
|
-
// A WOF record can hold an alias the Overture
|
|
209
|
+
// A WOF record can hold an alias the Overture step added to it.
|
|
208
210
|
// A database built before `names.source` existed holds no such alias,
|
|
209
|
-
// because the
|
|
211
|
+
// because the Overture step then wrote only its own places.
|
|
210
212
|
const hasSource = allRows<{ name: string }>(db.prepare("SELECT name FROM pragma_table_info('names')")).some(
|
|
211
213
|
(column) => column.name === "source"
|
|
212
214
|
)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Serialization stays Node-only because it is a build-time operation.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { tryParsingJSON } from "@mailwoman/core/json"
|
|
14
|
+
import { tryParsingJSON } from "@mailwoman/core/values/json"
|
|
15
15
|
|
|
16
16
|
import { BinaryFSTMatcher } from "#fst/binary-matcher"
|
|
17
17
|
import { HEADER_SIZE, VERSION_WITH_METADATA } from "#fst/format"
|
package/lib/fst/freshness.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* Does an `fst-*.bin` still match the gazetteer it was built from?
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { md5File } from "@mailwoman/core/crypto/hash"
|
|
8
9
|
import { readFileRange, readLocalTextFile } from "@mailwoman/core/fs/readers"
|
|
9
10
|
import { pathExists, statPath } from "@mailwoman/core/fs/readers/stat"
|
|
10
11
|
import { writeLocalTextFile } from "@mailwoman/core/fs/writers"
|
|
11
|
-
import {
|
|
12
|
-
import { tryParsingJSON } from "@mailwoman/core/json"
|
|
12
|
+
import { tryParsingJSON } from "@mailwoman/core/values/json"
|
|
13
13
|
import { basename, resolvePath, type PathBuilderLike } from "path-ts"
|
|
14
14
|
|
|
15
15
|
import { FST_FORMAT_VERSION } from "#fst/format"
|
package/lib/fst/serialize.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* Presence bits keep a missing value distinct from a stored zero.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import { tryParsingJSON, stringifyJSON } from "@mailwoman/core/json"
|
|
26
|
+
import { tryParsingJSON, stringifyJSON } from "@mailwoman/core/values/json"
|
|
27
27
|
|
|
28
28
|
import {
|
|
29
29
|
decodePlaceEntry,
|
package/lib/fts/query.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Query shaping for the FTS5 lookup: placetype normalization and the match-expression sanitizer.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { FindPlaceQuery, WOFPlacetype } from "#types"
|
|
8
|
+
import type { FindPlaceQuery, WOFPlacetype } from "#lookup/types"
|
|
9
9
|
|
|
10
10
|
export function normalizePlacetypes(p: FindPlaceQuery["placetype"]): WOFPlacetype[] | null {
|
|
11
11
|
if (!p) return null
|
|
@@ -21,8 +21,8 @@ import { bboxAround } from "@mailwoman/spatial/bbox"
|
|
|
21
21
|
import type { DatabaseClient, SQLInputValue } from "@mailwoman/sqlite/client"
|
|
22
22
|
|
|
23
23
|
import { PLACE_BBOX_TABLE, PLACE_POPULATION_TABLE } from "#fts"
|
|
24
|
-
import type {
|
|
25
|
-
import type {
|
|
24
|
+
import type { FindPlaceQuery, WOFPlacetype } from "#lookup/types"
|
|
25
|
+
import type { RankingWeights } from "#ranking/weights"
|
|
26
26
|
/**
|
|
27
27
|
* Query length at or below which the FTS window is widened.
|
|
28
28
|
*
|