@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
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The primary-name preference re-rank: a place whose primary name is the query outranks a place
|
|
6
|
+
* that lists it as an alias, unless the alias row's population exceeds it by a stated log10 margin.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { latLonBoundsContain } from "@mailwoman/spatial/bbox"
|
|
10
|
+
|
|
4
11
|
import type { CandidateTable } from "#candidate/schema"
|
|
5
12
|
|
|
6
13
|
/**
|
|
@@ -20,6 +27,40 @@ export type PrimaryPreferenceRow = Pick<CandidateTable, "neg_rank"> &
|
|
|
20
27
|
*/
|
|
21
28
|
export const PRIMARY_PREFERENCE_LOG10 = 1
|
|
22
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The alias penalty inside a stated region, larger than any log10 population gap.
|
|
32
|
+
*
|
|
33
|
+
* A query that states the region (`Junction, IL`) has already chosen among the world's namesakes,
|
|
34
|
+
* so a place whose primary name equals the query outranks a different place that lists it as an alias.
|
|
35
|
+
* WOF `und` variant names include former names of absorbed communities, such as `Junction` on West
|
|
36
|
+
* Chicago, and a population gap between the two places is no evidence of which one the query means.
|
|
37
|
+
*/
|
|
38
|
+
export const REGION_PRIMARY_PREFERENCE_LOG10 = 100
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The alias penalty inside a stated region for one alias row against the top primary row.
|
|
42
|
+
*
|
|
43
|
+
* A primary row inside the alias row's extent records the same place twice,
|
|
44
|
+
* as the Setauket hamlet inside the Setauket-East Setauket census place,
|
|
45
|
+
* so the worldwide margin applies and population decides.
|
|
46
|
+
* A primary row outside it is a different place, and the region margin applies.
|
|
47
|
+
*/
|
|
48
|
+
export function regionAliasMargin(
|
|
49
|
+
alias: Partial<Pick<CandidateTable, "min_lat" | "min_lon" | "max_lat" | "max_lon">>,
|
|
50
|
+
primary: Partial<Pick<CandidateTable, "latitude" | "longitude">>
|
|
51
|
+
): number {
|
|
52
|
+
const { min_lat: minLat, min_lon: minLon, max_lat: maxLat, max_lon: maxLon } = alias
|
|
53
|
+
const { latitude, longitude } = primary
|
|
54
|
+
|
|
55
|
+
if (minLat == null || minLon == null || maxLat == null || maxLon == null || latitude == null || longitude == null) {
|
|
56
|
+
return REGION_PRIMARY_PREFERENCE_LOG10
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return latLonBoundsContain({ minLat, minLon, maxLat, maxLon }, latitude, longitude)
|
|
60
|
+
? PRIMARY_PREFERENCE_LOG10
|
|
61
|
+
: REGION_PRIMARY_PREFERENCE_LOG10
|
|
62
|
+
}
|
|
63
|
+
|
|
23
64
|
const SEAT_PLACETYPE = "locality"
|
|
24
65
|
|
|
25
66
|
/**
|
|
@@ -80,6 +121,7 @@ export type RankedRow<R> = R & {
|
|
|
80
121
|
* Re-ranks population-ordered candidate rows.
|
|
81
122
|
*
|
|
82
123
|
* An alias must beat the top primary by `delta` in log10 population, in any country.
|
|
124
|
+
* A `delta` function returns the margin for one alias row against the top primary row.
|
|
83
125
|
* The function returns the top `limit` rows.
|
|
84
126
|
*
|
|
85
127
|
* When `placetypes` is given, an exact tie prefers a populated `locality`.
|
|
@@ -88,7 +130,7 @@ export type RankedRow<R> = R & {
|
|
|
88
130
|
export function rankByPrimaryPreference<R extends PrimaryPreferenceRow>(
|
|
89
131
|
rows: readonly R[],
|
|
90
132
|
limit: number,
|
|
91
|
-
delta = PRIMARY_PREFERENCE_LOG10,
|
|
133
|
+
delta: number | ((alias: R, primary: R) => number) = PRIMARY_PREFERENCE_LOG10,
|
|
92
134
|
placetypes?: ReadonlyMap<number, string>,
|
|
93
135
|
exemptVariantAliases = false
|
|
94
136
|
): Array<RankedRow<R>> {
|
|
@@ -105,7 +147,8 @@ export function rankByPrimaryPreference<R extends PrimaryPreferenceRow>(
|
|
|
105
147
|
const annotate = (r: R): RankedRow<R> => {
|
|
106
148
|
const exempted = exemptVariantAliases && r.name_role === "variant" && isAliasOfPrimary(r)
|
|
107
149
|
const penalized = isAliasOfPrimary(r) && !exempted
|
|
108
|
-
const
|
|
150
|
+
const margin = penalized ? (typeof delta === "number" ? delta : delta(r, topPrimary!)) : 0
|
|
151
|
+
const effectiveNegRank = r.neg_rank + margin
|
|
109
152
|
|
|
110
153
|
return {
|
|
111
154
|
...r,
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Which admin database an importance build was made from.
|
|
6
|
+
*
|
|
7
|
+
* `mailwoman gazetteer importance` copies an admin database and adds `place_importance` to the copy.
|
|
8
|
+
* It stamps the admin file's md5 and size into the copy's `importance_source` table, the same
|
|
9
|
+
* identity an FST stamps as `sourceDBMD5` and `sourceDBBytes` ({@linkcode readWOFSourceIdentity}).
|
|
10
|
+
*
|
|
11
|
+
* The copy is written beside the admin database at {@linkcode importanceDatabasePath},
|
|
12
|
+
* a name derived from the admin md5, so the candidate build finds the importance build for
|
|
13
|
+
* its admin database by hashing that database, and checks the stamp before reading a score.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { pathExists } from "@mailwoman/core/fs/readers/stat"
|
|
17
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
18
|
+
import { tableExists } from "@mailwoman/sqlite/introspection"
|
|
19
|
+
import type { Kysely } from "kysely"
|
|
20
|
+
import { basename, dirname, resolvePathBuilder, type PathBuilderLike } from "path-ts"
|
|
21
|
+
|
|
22
|
+
import { type FSTSourceIdentity, readWOFSourceIdentity } from "#fst/freshness"
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The one row of `importance_source`: the admin database the importance build copied.
|
|
26
|
+
*/
|
|
27
|
+
export interface ImportanceSourceTable {
|
|
28
|
+
/**
|
|
29
|
+
* The admin path as the importance build was given it.
|
|
30
|
+
*/
|
|
31
|
+
admin_path: string
|
|
32
|
+
/**
|
|
33
|
+
* The admin file's md5 as lowercase hex.
|
|
34
|
+
*/
|
|
35
|
+
admin_md5: string
|
|
36
|
+
/**
|
|
37
|
+
* The admin file's size in bytes.
|
|
38
|
+
*/
|
|
39
|
+
admin_bytes: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ImportanceSourceDatabase {
|
|
43
|
+
importance_source: ImportanceSourceTable
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The admin database an importance build records, read back from its stamp.
|
|
48
|
+
*/
|
|
49
|
+
export interface ImportanceAdminSource extends FSTSourceIdentity {
|
|
50
|
+
path: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The count of md5 hex characters in the importance file name.
|
|
55
|
+
* The stamp inside the file holds the whole digest.
|
|
56
|
+
*/
|
|
57
|
+
const NAME_DIGEST_LENGTH = 12
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Where the importance build for an admin database lives: beside it,
|
|
61
|
+
* under a name built from the admin's md5.
|
|
62
|
+
*
|
|
63
|
+
* `admin-global-priority.db` with md5 `6a0c2736…` gives `admin-global-priority-importance-6a0c2736xxxx.db`.
|
|
64
|
+
*/
|
|
65
|
+
export function importanceDatabasePath(adminDB: PathBuilderLike, adminMD5: string): string {
|
|
66
|
+
const name = basename(adminDB.toString(), ".db")
|
|
67
|
+
|
|
68
|
+
return resolvePathBuilder(dirname(adminDB.toString()))(
|
|
69
|
+
`${name}-importance-${adminMD5.slice(0, NAME_DIGEST_LENGTH)}.db`
|
|
70
|
+
).toString()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create `importance_source` and write the admin identity into it, replacing any earlier row.
|
|
75
|
+
*/
|
|
76
|
+
export async function writeImportanceSource(
|
|
77
|
+
db: Kysely<ImportanceSourceDatabase>,
|
|
78
|
+
source: ImportanceAdminSource
|
|
79
|
+
): Promise<void> {
|
|
80
|
+
await db.schema.dropTable("importance_source").ifExists().execute()
|
|
81
|
+
|
|
82
|
+
await db.schema
|
|
83
|
+
.createTable("importance_source")
|
|
84
|
+
.addColumn("admin_path", "text", (c) => c.notNull())
|
|
85
|
+
.addColumn("admin_md5", "text", (c) => c.notNull())
|
|
86
|
+
.addColumn("admin_bytes", "integer", (c) => c.notNull())
|
|
87
|
+
.execute()
|
|
88
|
+
|
|
89
|
+
await db
|
|
90
|
+
.insertInto("importance_source")
|
|
91
|
+
.values({ admin_path: source.path, admin_md5: source.md5, admin_bytes: source.bytes })
|
|
92
|
+
.execute()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Read the admin identity an importance build stamped.
|
|
97
|
+
*
|
|
98
|
+
* Returns `null` only when the file has no `importance_source` table.
|
|
99
|
+
* Such a file is an importance build that predates the stamp.
|
|
100
|
+
*
|
|
101
|
+
* @throws When the file is missing, or when the table holds other than one row.
|
|
102
|
+
*/
|
|
103
|
+
export async function readImportanceSource(importanceDB: PathBuilderLike): Promise<ImportanceAdminSource | null> {
|
|
104
|
+
if (!(await pathExists(importanceDB))) {
|
|
105
|
+
throw new Error(`importance source: ${importanceDB} not found`)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
using db = new DatabaseClient<ImportanceSourceDatabase>(importanceDB, { readOnly: true })
|
|
109
|
+
|
|
110
|
+
if (!tableExists(db, "importance_source")) return null
|
|
111
|
+
|
|
112
|
+
const rows = await db.selectFrom("importance_source").selectAll().execute()
|
|
113
|
+
|
|
114
|
+
if (rows.length !== 1) {
|
|
115
|
+
throw new Error(`importance source: ${importanceDB} holds ${rows.length} importance_source rows, expected 1`)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const [row] = rows
|
|
119
|
+
|
|
120
|
+
return { path: row!.admin_path, md5: row!.admin_md5, bytes: Number(row!.admin_bytes) }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The importance build a reader uses, with its own md5 for a manifest or a report.
|
|
125
|
+
*/
|
|
126
|
+
export interface ResolvedImportance {
|
|
127
|
+
path: string
|
|
128
|
+
md5: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A refusal from {@linkcode resolveImportanceForAdmin}.
|
|
133
|
+
* Its message gives the admin path and the importance path.
|
|
134
|
+
*/
|
|
135
|
+
export class ImportanceSourceError extends Error {
|
|
136
|
+
constructor(message: string) {
|
|
137
|
+
super(message)
|
|
138
|
+
|
|
139
|
+
this.name = "ImportanceSourceError"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Find the importance build that belongs with `adminDB` and check its stamp.
|
|
145
|
+
*
|
|
146
|
+
* Every reader of importance scores finds its file here, from the admin database it reads.
|
|
147
|
+
* Without `importanceDB` the file is the one {@linkcode importanceDatabasePath} gives for the admin md5.
|
|
148
|
+
* A given `importanceDB` is checked the same way.
|
|
149
|
+
*
|
|
150
|
+
* @throws {ImportanceSourceError} When no importance build exists for the admin database,
|
|
151
|
+
* when the file has no `importance_source` stamp, or when its stamp records another admin database.
|
|
152
|
+
*/
|
|
153
|
+
export async function resolveImportanceForAdmin(
|
|
154
|
+
adminDB: PathBuilderLike,
|
|
155
|
+
importanceDB?: PathBuilderLike
|
|
156
|
+
): Promise<ResolvedImportance> {
|
|
157
|
+
if (!(await pathExists(adminDB))) {
|
|
158
|
+
throw new ImportanceSourceError(`admin ${adminDB} does not exist, so no importance build can be matched to it.`)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const admin = await readWOFSourceIdentity(adminDB)
|
|
162
|
+
const path = (importanceDB ?? importanceDatabasePath(adminDB, admin.md5)).toString()
|
|
163
|
+
const rebuild = `mailwoman gazetteer importance --admin ${adminDB}`
|
|
164
|
+
|
|
165
|
+
if (!(await pathExists(path))) {
|
|
166
|
+
throw new ImportanceSourceError(
|
|
167
|
+
`no importance build for admin ${adminDB} (md5 ${admin.md5}): ${path} does not exist. ` +
|
|
168
|
+
`Build it with \`${rebuild}\`.`
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const stamped = await readImportanceSource(path)
|
|
173
|
+
|
|
174
|
+
if (!stamped) {
|
|
175
|
+
throw new ImportanceSourceError(
|
|
176
|
+
`importance ${path} records no admin database (no importance_source table), so it cannot be ` +
|
|
177
|
+
`matched to admin ${adminDB} (md5 ${admin.md5}). Rebuild it with \`${rebuild}\`.`
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (stamped.md5 !== admin.md5 || stamped.bytes !== admin.bytes) {
|
|
182
|
+
throw new ImportanceSourceError(
|
|
183
|
+
`importance ${path} was built from admin ${stamped.path} (md5 ${stamped.md5}, ` +
|
|
184
|
+
`${stamped.bytes} bytes), not admin ${adminDB} (md5 ${admin.md5}, ${admin.bytes} bytes). ` +
|
|
185
|
+
`Rebuild it with \`${rebuild}\`.`
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return { path, md5: (await readWOFSourceIdentity(path)).md5 }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* {@linkcode resolveImportanceForAdmin} for a report that goes on without scores.
|
|
194
|
+
*
|
|
195
|
+
* A refusal comes back as its message, and the message gives both paths.
|
|
196
|
+
* The report states that message as the reason it read no scores.
|
|
197
|
+
*
|
|
198
|
+
* @throws Any error other than an {@linkcode ImportanceSourceError}.
|
|
199
|
+
*/
|
|
200
|
+
export async function resolveImportanceOrRefusal(
|
|
201
|
+
adminDB: PathBuilderLike
|
|
202
|
+
): Promise<(ResolvedImportance & { refusal: null }) | { path: null; md5: null; refusal: string }> {
|
|
203
|
+
try {
|
|
204
|
+
return { ...(await resolveImportanceForAdmin(adminDB)), refusal: null }
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (error instanceof ImportanceSourceError) return { path: null, md5: null, refusal: error.message }
|
|
207
|
+
|
|
208
|
+
throw error
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The `overture_wof_match` table: which Who's On First record each matched Overture division is.
|
|
6
|
+
*
|
|
7
|
+
* The admin gazetteer is a Collective Database.
|
|
8
|
+
* Its Overture Divisions part is ODbL-1.0, and the Overture step writes every division as its
|
|
9
|
+
* own row in the Overture id range rather than adding its names or Wikidata id to a WOF record.
|
|
10
|
+
*
|
|
11
|
+
* A lookup that returns each place once reads the match from this table
|
|
12
|
+
* instead of from an altered WOF row.
|
|
13
|
+
* The table is derived from Overture data, so it belongs to the Overture part
|
|
14
|
+
* and travels with that part's ODbL offer.
|
|
15
|
+
*
|
|
16
|
+
* The admin build writes it, the candidate build copies it into `candidate.db`,
|
|
17
|
+
* and the Overture part's offer file includes it.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
21
|
+
import type { Kysely } from "kysely"
|
|
22
|
+
|
|
23
|
+
import { hasTable } from "#sqlite-utils"
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The table name every writer and reader uses.
|
|
27
|
+
*/
|
|
28
|
+
export const OVERTURE_WOF_MATCH_TABLE = "overture_wof_match"
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One matched division: its Overture-part row and the WOF record it names.
|
|
32
|
+
*/
|
|
33
|
+
export interface OvertureWOFMatchTable {
|
|
34
|
+
/**
|
|
35
|
+
* The division's row id, inside the Overture id range.
|
|
36
|
+
*/
|
|
37
|
+
overture_id: number
|
|
38
|
+
/**
|
|
39
|
+
* The WOF record the division matched.
|
|
40
|
+
*/
|
|
41
|
+
wof_id: number
|
|
42
|
+
/**
|
|
43
|
+
* The evidence that matched them: `country`, `wikidata`, `geonames` or `name`.
|
|
44
|
+
*/
|
|
45
|
+
match_by: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface OvertureWOFMatchDatabase {
|
|
49
|
+
overture_wof_match: OvertureWOFMatchTable
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create the table, keyed by the Overture row so each division records at most one match.
|
|
54
|
+
*/
|
|
55
|
+
export async function createOvertureWOFMatchTable<DB extends OvertureWOFMatchDatabase>(db: Kysely<DB>): Promise<void> {
|
|
56
|
+
await db.schema
|
|
57
|
+
.createTable(OVERTURE_WOF_MATCH_TABLE)
|
|
58
|
+
.ifNotExists()
|
|
59
|
+
.addColumn("overture_id", "integer", (c) => c.primaryKey())
|
|
60
|
+
.addColumn("wof_id", "integer", (c) => c.notNull())
|
|
61
|
+
.addColumn("match_by", "text", (c) => c.notNull())
|
|
62
|
+
.execute()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Every recorded match, or `null` when the database predates the table.
|
|
67
|
+
*
|
|
68
|
+
* A database without the table was built before the Overture rows became an independent part,
|
|
69
|
+
* when a matched division wrote no row of its own, so its matches are unrecorded rather than zero.
|
|
70
|
+
*/
|
|
71
|
+
export function readOvertureWOFMatches<DB>(db: DatabaseClient<DB>): OvertureWOFMatchTable[] | null {
|
|
72
|
+
if (!hasTable(db, OVERTURE_WOF_MATCH_TABLE)) return null
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
db
|
|
76
|
+
.prepare(`SELECT overture_id, wof_id, match_by FROM ${OVERTURE_WOF_MATCH_TABLE} ORDER BY overture_id`)
|
|
77
|
+
.all() as Array<{ overture_id: number; wof_id: number; match_by: string }>
|
|
78
|
+
).map((row) => ({ overture_id: Number(row.overture_id), wof_id: Number(row.wof_id), match_by: String(row.match_by) }))
|
|
79
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The `place_importance` table of an admin gazetteer: its columns, its DDL, the referential
|
|
6
|
+
* score derived from population, and the blend of that score with the encyclopedic one.
|
|
7
|
+
*/
|
|
8
|
+
|
|
4
9
|
import { referentialFromPopulation } from "@mailwoman/core/resolver"
|
|
5
10
|
import { allRows } from "@mailwoman/core/utils"
|
|
6
11
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
@@ -72,6 +77,87 @@ export async function createPlaceImportanceTable(db: Kysely<PlaceImportanceDatab
|
|
|
72
77
|
.execute()
|
|
73
78
|
}
|
|
74
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Describes one row of the `place_population_estimate` table: a sub-locality's population estimated
|
|
82
|
+
* from the settlement that contains it, for a place the admin database records no population for.
|
|
83
|
+
*
|
|
84
|
+
* The estimate is the containing settlement's population divided by one more than the
|
|
85
|
+
* number of places of the same placetype that settlement contains.
|
|
86
|
+
* The `+ 1` keeps a share for the part of the settlement no recorded child covers,
|
|
87
|
+
* so an estimate is always smaller than its parent's population.
|
|
88
|
+
*/
|
|
89
|
+
export interface PlacePopulationEstimateTable {
|
|
90
|
+
id: number
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The point estimate.
|
|
94
|
+
*/
|
|
95
|
+
population: number
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The value the candidate table ranks the place by: the point estimate scaled by the lower decile
|
|
99
|
+
* of measured / estimated population over every sub-locality that has a measured population.
|
|
100
|
+
*
|
|
101
|
+
* A ranked estimate outranks a measured place only where nine in ten measured sub-localities would.
|
|
102
|
+
*/
|
|
103
|
+
rank_population: number
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The settlement whose population the estimate divides: the place's `parent_id`.
|
|
107
|
+
*/
|
|
108
|
+
parent_id: number
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The parent's current children with this place's placetype, the place included.
|
|
112
|
+
*/
|
|
113
|
+
siblings: number
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Types the `place_population_estimate` table of an importance database.
|
|
118
|
+
*/
|
|
119
|
+
export interface PlacePopulationEstimateDatabase {
|
|
120
|
+
place_population_estimate: PlacePopulationEstimateTable
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Drops and recreates the `place_population_estimate` table.
|
|
125
|
+
*/
|
|
126
|
+
export async function createPlacePopulationEstimateTable(db: Kysely<PlacePopulationEstimateDatabase>): Promise<void> {
|
|
127
|
+
await db.schema.dropTable("place_population_estimate").ifExists().execute()
|
|
128
|
+
|
|
129
|
+
await db.schema
|
|
130
|
+
.createTable("place_population_estimate")
|
|
131
|
+
.addColumn("id", "integer", (c) => c.primaryKey())
|
|
132
|
+
.addColumn("population", "real", (c) => c.notNull())
|
|
133
|
+
.addColumn("rank_population", "real", (c) => c.notNull())
|
|
134
|
+
.addColumn("parent_id", "integer", (c) => c.notNull())
|
|
135
|
+
.addColumn("siblings", "integer", (c) => c.notNull())
|
|
136
|
+
.execute()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Reads every estimate's ranking population (`rank_population`) from an
|
|
141
|
+
* importance database, keyed by WOF id.
|
|
142
|
+
*
|
|
143
|
+
* @throws When the database has no `place_population_estimate` table, because the
|
|
144
|
+
* importance build that wrote it ran without sub-locality estimates.
|
|
145
|
+
*/
|
|
146
|
+
export function loadPopulationEstimates<DB>(db: DatabaseClient<DB>): Map<number, number> {
|
|
147
|
+
if (!tableColumns(db, "place_population_estimate").has("rank_population")) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
"place_population_estimate: the importance database has no estimates table. " +
|
|
150
|
+
"Rebuild it with `mailwoman gazetteer importance --sub-locality-estimates`."
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const rows = allRows<{ id: number; rank_population: number }>(
|
|
155
|
+
db.prepare("SELECT id, rank_population FROM place_population_estimate")
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
return new Map(rows.map((row) => [Number(row.id), Number(row.rank_population)]))
|
|
159
|
+
}
|
|
160
|
+
|
|
75
161
|
/**
|
|
76
162
|
* Caps how far the encyclopedic score may raise a place's blended importance above its referential score.
|
|
77
163
|
*
|
package/lib/schema.ts
CHANGED
|
@@ -85,7 +85,7 @@ export interface SprTable {
|
|
|
85
85
|
*
|
|
86
86
|
* Real WOF dumps omit it.
|
|
87
87
|
* These are the aliases eligible to join the name-exact tier.
|
|
88
|
-
* See `unified
|
|
88
|
+
* See `schema/unified.ts` for the full interface.
|
|
89
89
|
*/
|
|
90
90
|
export interface NamesTable {
|
|
91
91
|
id: number
|
|
@@ -102,7 +102,7 @@ export interface NamesTable {
|
|
|
102
102
|
name: string
|
|
103
103
|
lastmodified: number
|
|
104
104
|
/**
|
|
105
|
-
* The dataset the row came from, one of `ROW_SOURCES` in `unified
|
|
105
|
+
* The dataset the row came from, one of `ROW_SOURCES` in `schema/unified.ts`.
|
|
106
106
|
*
|
|
107
107
|
* Databases built before the column existed have no such column.
|
|
108
108
|
*/
|
|
@@ -177,7 +177,7 @@ export interface ConcordancesTable {
|
|
|
177
177
|
other_source: string
|
|
178
178
|
lastmodified: number
|
|
179
179
|
/**
|
|
180
|
-
* The dataset the row came from, one of `ROW_SOURCES` in `unified
|
|
180
|
+
* The dataset the row came from, one of `ROW_SOURCES` in `schema/unified.ts`.
|
|
181
181
|
*
|
|
182
182
|
* Databases built before the column existed have no such column.
|
|
183
183
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
3
|
|
|
4
|
-
import { tryParsingJSON } from "@mailwoman/core/json"
|
|
4
|
+
import { tryParsingJSON } from "@mailwoman/core/values/json"
|
|
5
5
|
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
6
6
|
|
|
7
7
|
import { ADDRESS_CONVENTION_TABLE, type Convention, type ConventionSource } from "#convention"
|
package/lib/uprn/existence.ts
CHANGED
|
@@ -28,6 +28,8 @@ import { UPRN_COVERAGE_H3_RESOLUTION, UPRN_H3_RESOLUTION, uprnH3Cell } from "#up
|
|
|
28
28
|
*/
|
|
29
29
|
export const UPRN_EXISTENCE_FOLD = foldIdentity((s) => s)
|
|
30
30
|
|
|
31
|
+
// country-branch: OS Open UPRN is Ordnance Survey's product, and its coverage is Great Britain.
|
|
32
|
+
// The countries recorded in the layer's manifest would replace the list.
|
|
31
33
|
/**
|
|
32
34
|
* The countries OS Open uprn covers.
|
|
33
35
|
*
|