@mailwoman/resolver-wof-sqlite 9.1.0 → 9.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 +36 -20
- package/lib/address/index.ts +9 -0
- package/{address-point-interpolation.ts → lib/address/point-interpolation.ts} +40 -28
- package/{address-point-schema.ts → lib/address/point-schema.ts} +34 -8
- package/lib/address/point.ts +280 -0
- package/{ancestry-backfill.ts → lib/ancestry/backfill.ts} +14 -19
- package/{ancestry.ts → lib/ancestry/index.ts} +13 -8
- package/{build-candidate.ts → lib/build-candidate.ts} +243 -199
- package/{build-slim.ts → lib/build-slim.ts} +153 -168
- package/lib/candidate/alias-bags.ts +56 -0
- package/lib/candidate/ancestors-sidecar.ts +204 -0
- package/lib/candidate/country-display-names.ts +79 -0
- package/lib/candidate/extract-fold.ts +138 -0
- package/lib/candidate/name-roles.ts +238 -0
- package/lib/candidate/own-name.ts +146 -0
- package/lib/candidate/place-attrs.ts +44 -0
- package/lib/candidate-ancestors-schema.ts +195 -0
- package/{candidate-fts.ts → lib/candidate-fts.ts} +7 -5
- package/{candidate-importance.ts → lib/candidate-importance.ts} +54 -57
- package/lib/candidate-lookup.ts +976 -0
- package/{candidate-schema.ts → lib/candidate-schema.ts} +34 -6
- package/lib/candidate-scoring.ts +261 -0
- package/lib/capital-schema.ts +89 -0
- package/lib/capitals.ts +148 -0
- package/{coincident-roles.ts → lib/coincident-roles.ts} +75 -19
- package/{convention.ts → lib/convention/index.ts} +5 -5
- package/lib/convention/schema.ts +72 -0
- package/{coverage-manifest-schema.ts → lib/coverage-manifest-schema.ts} +15 -16
- package/lib/currency-backfill.ts +334 -0
- package/lib/env.ts +50 -0
- package/lib/exact-match.ts +113 -0
- package/{sharding.ts → lib/extracts.ts} +63 -60
- package/lib/fst/autocomplete.ts +176 -0
- package/{fst-builder.ts → lib/fst/builder.ts} +30 -27
- package/{fst-deserialize-web.ts → lib/fst/deserialize-web.ts} +27 -87
- package/lib/fst/format.ts +106 -0
- package/{fst-freshness.ts → lib/fst/freshness.ts} +42 -75
- package/lib/fst/index.ts +14 -0
- package/{fst-matcher.ts → lib/fst/matcher.ts} +1 -1
- package/{fst-serialize.ts → lib/fst/serialize.ts} +37 -115
- package/{fst-types.ts → lib/fst/types.ts} +4 -2
- package/{fts.ts → lib/fts/index.ts} +28 -23
- package/{fts-query.ts → lib/fts/query.ts} +2 -2
- package/{geonames-aliases.ts → lib/geonames/aliases.ts} +13 -13
- package/lib/geonames/index.ts +8 -0
- package/{geonames-postal.ts → lib/geonames/postal.ts} +16 -15
- package/{index.ts → lib/index.ts} +52 -48
- package/{interpolation.ts → lib/interpolation.ts} +137 -41
- package/lib/lookup.ts +861 -0
- package/{name-score.ts → lib/name-score.ts} +6 -4
- package/lib/nsul/index.ts +8 -0
- package/lib/nsul/lookup.ts +144 -0
- package/lib/nsul/schema.ts +130 -0
- package/{place-importance-schema.ts → lib/place-importance-schema.ts} +70 -22
- package/lib/poi/index.ts +8 -0
- package/{poi-lookup.ts → lib/poi/lookup.ts} +32 -39
- package/{poi-schema.ts → lib/poi/schema.ts} +10 -6
- package/lib/polygon-schema.ts +47 -0
- package/{postal-city-alias-lookup.ts → lib/postal/city-alias-lookup.ts} +15 -21
- package/{postal-city-candidate-schema.ts → lib/postal/city-candidate-schema.ts} +4 -2
- package/lib/postal/index.ts +9 -0
- package/{postcode-point-lookup.ts → lib/postcode-point-lookup.ts} +17 -15
- package/lib/primary-preference.ts +226 -0
- package/lib/proximity-rerank.ts +120 -0
- package/{ranking-weights.ts → lib/ranking-weights.ts} +30 -4
- package/lib/region-keys.ts +144 -0
- package/{reverse.ts → lib/reverse.ts} +45 -56
- package/{schema.ts → lib/schema.ts} +11 -1
- package/lib/search-fetch.ts +257 -0
- package/{sqlite-convention-source.ts → lib/sqlite-convention-source.ts} +9 -10
- package/lib/sqlite-utils.ts +83 -0
- package/{street-centroid-schema.ts → lib/street/centroid-schema.ts} +12 -6
- package/{street-centroid.ts → lib/street/centroid.ts} +26 -28
- package/lib/street/index.ts +13 -0
- package/{street-morphology-fst-builder.ts → lib/street/morphology-fst-builder.ts} +24 -14
- package/{street-morphology-fst-loader.ts → lib/street/morphology-fst-loader.ts} +14 -12
- package/{street-name-lookup.ts → lib/street/name-lookup.ts} +14 -30
- package/lib/street/normalize.ts +572 -0
- package/{street-segment-schema.ts → lib/street/segment-schema.ts} +13 -8
- package/{types.ts → lib/types.ts} +49 -9
- package/{unified-schema.ts → lib/unified-schema.ts} +21 -25
- package/lib/uprn/existence.ts +84 -0
- package/lib/uprn/index.ts +9 -0
- package/lib/uprn/lookup.ts +206 -0
- package/lib/uprn/schema.ts +124 -0
- package/lib/weights-overlay-linker.ts +878 -0
- package/out/address/index.d.ts +9 -0
- package/out/address/index.d.ts.map +1 -0
- package/out/address/index.js +9 -0
- package/out/address/index.js.map +1 -0
- package/out/{address-point-interpolation.d.ts → address/point-interpolation.d.ts} +11 -10
- package/out/address/point-interpolation.d.ts.map +1 -0
- package/out/{address-point-interpolation.js → address/point-interpolation.js} +29 -23
- package/out/address/point-interpolation.js.map +1 -0
- package/out/{address-point-schema.d.ts → address/point-schema.d.ts} +30 -10
- package/out/address/point-schema.d.ts.map +1 -0
- package/out/{address-point-schema.js → address/point-schema.js} +7 -3
- package/out/address/point-schema.js.map +1 -0
- package/out/{address-point.d.ts → address/point.d.ts} +16 -8
- package/out/address/point.d.ts.map +1 -0
- package/out/address/point.js +191 -0
- package/out/address/point.js.map +1 -0
- package/out/{ancestry-backfill.d.ts → ancestry/backfill.d.ts} +7 -5
- package/out/ancestry/backfill.d.ts.map +1 -0
- package/out/{ancestry-backfill.js → ancestry/backfill.js} +12 -16
- package/out/ancestry/backfill.js.map +1 -0
- package/out/{ancestry.d.ts → ancestry/index.d.ts} +6 -5
- package/out/ancestry/index.d.ts.map +1 -0
- package/out/{ancestry.js → ancestry/index.js} +7 -7
- package/out/ancestry/index.js.map +1 -0
- package/out/build-candidate.d.ts +88 -7
- package/out/build-candidate.d.ts.map +1 -1
- package/out/build-candidate.js +145 -149
- package/out/build-candidate.js.map +1 -1
- package/out/build-slim.d.ts +5 -5
- package/out/build-slim.d.ts.map +1 -1
- package/out/build-slim.js +127 -142
- package/out/build-slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +19 -0
- package/out/candidate/alias-bags.d.ts.map +1 -0
- package/out/candidate/alias-bags.js +39 -0
- package/out/candidate/alias-bags.js.map +1 -0
- package/out/candidate/ancestors-sidecar.d.ts +32 -0
- package/out/candidate/ancestors-sidecar.d.ts.map +1 -0
- package/out/candidate/ancestors-sidecar.js +140 -0
- package/out/candidate/ancestors-sidecar.js.map +1 -0
- package/out/candidate/country-display-names.d.ts +35 -0
- package/out/candidate/country-display-names.d.ts.map +1 -0
- package/out/candidate/country-display-names.js +59 -0
- package/out/candidate/country-display-names.js.map +1 -0
- package/out/candidate/extract-fold.d.ts +32 -0
- package/out/candidate/extract-fold.d.ts.map +1 -0
- package/out/candidate/extract-fold.js +104 -0
- package/out/candidate/extract-fold.js.map +1 -0
- package/out/candidate/name-roles.d.ts +57 -0
- package/out/candidate/name-roles.d.ts.map +1 -0
- package/out/candidate/name-roles.js +166 -0
- package/out/candidate/name-roles.js.map +1 -0
- package/out/candidate/own-name.d.ts +50 -0
- package/out/candidate/own-name.d.ts.map +1 -0
- package/out/candidate/own-name.js +132 -0
- package/out/candidate/own-name.js.map +1 -0
- package/out/candidate/place-attrs.d.ts +43 -0
- package/out/candidate/place-attrs.d.ts.map +1 -0
- package/out/candidate/place-attrs.js +15 -0
- package/out/candidate/place-attrs.js.map +1 -0
- package/out/candidate-ancestors-schema.d.ts +150 -0
- package/out/candidate-ancestors-schema.d.ts.map +1 -0
- package/out/candidate-ancestors-schema.js +123 -0
- package/out/candidate-ancestors-schema.js.map +1 -0
- package/out/candidate-fts.d.ts +7 -5
- package/out/candidate-fts.d.ts.map +1 -1
- package/out/candidate-fts.js +5 -3
- package/out/candidate-fts.js.map +1 -1
- package/out/candidate-importance.d.ts +16 -16
- package/out/candidate-importance.d.ts.map +1 -1
- package/out/candidate-importance.js +47 -52
- package/out/candidate-importance.js.map +1 -1
- package/out/candidate-lookup.d.ts +31 -52
- package/out/candidate-lookup.d.ts.map +1 -1
- package/out/candidate-lookup.js +380 -172
- package/out/candidate-lookup.js.map +1 -1
- package/out/candidate-schema.d.ts +31 -7
- package/out/candidate-schema.d.ts.map +1 -1
- package/out/candidate-schema.js +3 -0
- package/out/candidate-schema.js.map +1 -1
- package/out/candidate-scoring.d.ts +34 -0
- package/out/candidate-scoring.d.ts.map +1 -0
- package/out/candidate-scoring.js +196 -0
- package/out/candidate-scoring.js.map +1 -0
- package/out/capital-schema.d.ts +51 -0
- package/out/capital-schema.d.ts.map +1 -0
- package/out/capital-schema.js +63 -0
- package/out/capital-schema.js.map +1 -0
- package/out/capitals.d.ts +69 -0
- package/out/capitals.d.ts.map +1 -0
- package/out/capitals.js +98 -0
- package/out/capitals.js.map +1 -0
- package/out/coincident-roles.d.ts +12 -4
- package/out/coincident-roles.d.ts.map +1 -1
- package/out/coincident-roles.js +43 -11
- package/out/coincident-roles.js.map +1 -1
- package/out/{convention.d.ts → convention/index.d.ts} +5 -5
- package/out/convention/index.d.ts.map +1 -0
- package/out/{convention.js → convention/index.js} +4 -4
- package/out/convention/index.js.map +1 -0
- package/out/convention/schema.d.ts +51 -0
- package/out/convention/schema.d.ts.map +1 -0
- package/out/convention/schema.js +34 -0
- package/out/convention/schema.js.map +1 -0
- package/out/coverage-manifest-schema.d.ts +8 -8
- package/out/coverage-manifest-schema.d.ts.map +1 -1
- package/out/coverage-manifest-schema.js +6 -10
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/currency-backfill.d.ts +90 -0
- package/out/currency-backfill.d.ts.map +1 -0
- package/out/currency-backfill.js +196 -0
- package/out/currency-backfill.js.map +1 -0
- package/out/env.d.ts +43 -0
- package/out/env.d.ts.map +1 -0
- package/out/env.js +48 -0
- package/out/env.js.map +1 -0
- package/out/exact-match.d.ts +25 -0
- package/out/exact-match.d.ts.map +1 -0
- package/out/exact-match.js +88 -0
- package/out/exact-match.js.map +1 -0
- package/out/extracts.d.ts +114 -0
- package/out/extracts.d.ts.map +1 -0
- package/out/{sharding.js → extracts.js} +38 -38
- package/out/extracts.js.map +1 -0
- package/out/{fst-autocomplete.d.ts → fst/autocomplete.d.ts} +13 -13
- package/out/fst/autocomplete.d.ts.map +1 -0
- package/out/fst/autocomplete.js +113 -0
- package/out/fst/autocomplete.js.map +1 -0
- package/out/{fst-builder.d.ts → fst/builder.d.ts} +5 -5
- package/out/fst/builder.d.ts.map +1 -0
- package/out/{fst-builder.js → fst/builder.js} +24 -24
- package/out/fst/builder.js.map +1 -0
- package/out/{fst-deserialize-web.d.ts → fst/deserialize-web.d.ts} +3 -3
- package/out/fst/deserialize-web.d.ts.map +1 -0
- package/out/{fst-deserialize-web.js → fst/deserialize-web.js} +10 -74
- package/out/fst/deserialize-web.js.map +1 -0
- package/out/fst/format.d.ts +80 -0
- package/out/fst/format.d.ts.map +1 -0
- package/out/fst/format.js +91 -0
- package/out/fst/format.js.map +1 -0
- package/out/{fst-freshness.d.ts → fst/freshness.d.ts} +11 -14
- package/out/fst/freshness.d.ts.map +1 -0
- package/out/{fst-freshness.js → fst/freshness.js} +42 -74
- package/out/fst/freshness.js.map +1 -0
- package/out/fst/index.d.ts +14 -0
- package/out/fst/index.d.ts.map +1 -0
- package/out/fst/index.js +14 -0
- package/out/fst/index.js.map +1 -0
- package/out/{fst-matcher.d.ts → fst/matcher.d.ts} +2 -2
- package/out/fst/matcher.d.ts.map +1 -0
- package/out/{fst-matcher.js → fst/matcher.js} +1 -1
- package/out/fst/matcher.js.map +1 -0
- package/out/{fst-serialize.d.ts → fst/serialize.d.ts} +5 -10
- package/out/fst/serialize.d.ts.map +1 -0
- package/out/{fst-serialize.js → fst/serialize.js} +18 -98
- package/out/fst/serialize.js.map +1 -0
- package/out/{fst-types.d.ts → fst/types.d.ts} +4 -3
- package/out/fst/types.d.ts.map +1 -0
- package/out/{fst-types.js → fst/types.js} +1 -1
- package/out/fst/types.js.map +1 -0
- package/out/{fts.d.ts → fts/index.d.ts} +20 -13
- package/out/fts/index.d.ts.map +1 -0
- package/out/{fts.js → fts/index.js} +20 -15
- package/out/fts/index.js.map +1 -0
- package/out/{fts-query.d.ts → fts/query.d.ts} +2 -2
- package/out/fts/query.d.ts.map +1 -0
- package/out/{fts-query.js → fts/query.js} +2 -2
- package/out/fts/query.js.map +1 -0
- package/out/{geonames-aliases.d.ts → geonames/aliases.d.ts} +8 -6
- package/out/geonames/aliases.d.ts.map +1 -0
- package/out/{geonames-aliases.js → geonames/aliases.js} +7 -7
- package/out/geonames/aliases.js.map +1 -0
- package/out/geonames/index.d.ts +8 -0
- package/out/geonames/index.d.ts.map +1 -0
- package/out/geonames/index.js +8 -0
- package/out/geonames/index.js.map +1 -0
- package/out/{geonames-postal.d.ts → geonames/postal.d.ts} +12 -10
- package/out/geonames/postal.d.ts.map +1 -0
- package/out/{geonames-postal.js → geonames/postal.js} +11 -11
- package/out/geonames/postal.js.map +1 -0
- package/out/index.d.ts +32 -31
- package/out/index.d.ts.map +1 -1
- package/out/index.js +24 -24
- package/out/index.js.map +1 -1
- package/out/interpolation.d.ts +18 -9
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +108 -36
- package/out/interpolation.js.map +1 -1
- package/out/lookup.d.ts +25 -25
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +174 -558
- package/out/lookup.js.map +1 -1
- package/out/name-score.d.ts +0 -10
- package/out/name-score.d.ts.map +1 -1
- package/out/name-score.js +6 -4
- package/out/name-score.js.map +1 -1
- package/out/nsul/index.d.ts +8 -0
- package/out/nsul/index.d.ts.map +1 -0
- package/out/nsul/index.js +8 -0
- package/out/nsul/index.js.map +1 -0
- package/out/nsul/lookup.d.ts +83 -0
- package/out/nsul/lookup.d.ts.map +1 -0
- package/out/nsul/lookup.js +80 -0
- package/out/nsul/lookup.js.map +1 -0
- package/out/nsul/schema.d.ts +100 -0
- package/out/nsul/schema.d.ts.map +1 -0
- package/out/nsul/schema.js +78 -0
- package/out/nsul/schema.js.map +1 -0
- package/out/place-importance-schema.d.ts +47 -10
- package/out/place-importance-schema.d.ts.map +1 -1
- package/out/place-importance-schema.js +56 -10
- package/out/place-importance-schema.js.map +1 -1
- package/out/poi/index.d.ts +8 -0
- package/out/poi/index.d.ts.map +1 -0
- package/out/poi/index.js +8 -0
- package/out/poi/index.js.map +1 -0
- package/out/{poi-lookup.d.ts → poi/lookup.d.ts} +8 -10
- package/out/poi/lookup.d.ts.map +1 -0
- package/out/{poi-lookup.js → poi/lookup.js} +24 -29
- package/out/poi/lookup.js.map +1 -0
- package/out/{poi-schema.d.ts → poi/schema.d.ts} +10 -6
- package/out/poi/schema.d.ts.map +1 -0
- package/out/{poi-schema.js → poi/schema.js} +1 -1
- package/out/poi/schema.js.map +1 -0
- package/out/polygon-schema.d.ts +37 -0
- package/out/polygon-schema.d.ts.map +1 -0
- package/out/polygon-schema.js +23 -0
- package/out/polygon-schema.js.map +1 -0
- package/out/{postal-city-alias-lookup.d.ts → postal/city-alias-lookup.d.ts} +7 -6
- package/out/postal/city-alias-lookup.d.ts.map +1 -0
- package/out/{postal-city-alias-lookup.js → postal/city-alias-lookup.js} +12 -16
- package/out/postal/city-alias-lookup.js.map +1 -0
- package/out/{postal-city-alias-schema.d.ts → postal/city-alias-schema.d.ts} +1 -1
- package/out/{postal-city-alias-schema.d.ts.map → postal/city-alias-schema.d.ts.map} +1 -1
- package/out/{postal-city-alias-schema.js → postal/city-alias-schema.js} +1 -1
- package/out/{postal-city-alias-schema.js.map → postal/city-alias-schema.js.map} +1 -1
- package/out/{postal-city-candidate-schema.d.ts → postal/city-candidate-schema.d.ts} +4 -3
- package/out/postal/city-candidate-schema.d.ts.map +1 -0
- package/out/{postal-city-candidate-schema.js → postal/city-candidate-schema.js} +2 -2
- package/out/{postal-city-candidate-schema.js.map → postal/city-candidate-schema.js.map} +1 -1
- package/out/postal/index.d.ts +9 -0
- package/out/postal/index.d.ts.map +1 -0
- package/out/postal/index.js +9 -0
- package/out/postal/index.js.map +1 -0
- package/out/postcode-point-lookup.d.ts +10 -10
- package/out/postcode-point-lookup.d.ts.map +1 -1
- package/out/postcode-point-lookup.js +13 -13
- package/out/postcode-point-lookup.js.map +1 -1
- package/out/primary-preference.d.ts +133 -0
- package/out/primary-preference.d.ts.map +1 -0
- package/out/primary-preference.js +146 -0
- package/out/primary-preference.js.map +1 -0
- package/out/proximity-rerank.d.ts +77 -0
- package/out/proximity-rerank.d.ts.map +1 -0
- package/out/proximity-rerank.js +86 -0
- package/out/proximity-rerank.js.map +1 -0
- package/out/ranking-weights.d.ts +15 -3
- package/out/ranking-weights.d.ts.map +1 -1
- package/out/ranking-weights.js +21 -3
- package/out/ranking-weights.js.map +1 -1
- package/out/region-keys.d.ts +47 -0
- package/out/region-keys.d.ts.map +1 -0
- package/out/region-keys.js +121 -0
- package/out/region-keys.js.map +1 -0
- package/out/reverse.d.ts +6 -6
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +23 -35
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +10 -1
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js.map +1 -1
- package/out/search-fetch.d.ts +59 -0
- package/out/search-fetch.d.ts.map +1 -0
- package/out/search-fetch.js +184 -0
- package/out/search-fetch.js.map +1 -0
- package/out/sqlite-convention-source.d.ts +7 -7
- package/out/sqlite-convention-source.d.ts.map +1 -1
- package/out/sqlite-convention-source.js +5 -5
- package/out/sqlite-convention-source.js.map +1 -1
- package/out/sqlite-utils.d.ts +24 -6
- package/out/sqlite-utils.d.ts.map +1 -1
- package/out/sqlite-utils.js +24 -7
- package/out/sqlite-utils.js.map +1 -1
- package/out/{street-centroid-schema.d.ts → street/centroid-schema.d.ts} +12 -7
- package/out/street/centroid-schema.d.ts.map +1 -0
- package/out/{street-centroid-schema.js → street/centroid-schema.js} +5 -5
- package/out/{street-centroid-schema.js.map → street/centroid-schema.js.map} +1 -1
- package/out/{street-centroid.d.ts → street/centroid.d.ts} +6 -6
- package/out/street/centroid.d.ts.map +1 -0
- package/out/{street-centroid.js → street/centroid.js} +18 -24
- package/out/street/centroid.js.map +1 -0
- package/out/street/index.d.ts +13 -0
- package/out/street/index.d.ts.map +1 -0
- package/out/street/index.js +13 -0
- package/out/street/index.js.map +1 -0
- package/out/{street-morphology-fst-builder.d.ts → street/morphology-fst-builder.d.ts} +4 -4
- package/out/street/morphology-fst-builder.d.ts.map +1 -0
- package/out/{street-morphology-fst-builder.js → street/morphology-fst-builder.js} +18 -13
- package/out/street/morphology-fst-builder.js.map +1 -0
- package/out/{street-morphology-fst-loader.d.ts → street/morphology-fst-loader.d.ts} +5 -5
- package/out/street/morphology-fst-loader.d.ts.map +1 -0
- package/out/{street-morphology-fst-loader.js → street/morphology-fst-loader.js} +11 -10
- package/out/street/morphology-fst-loader.js.map +1 -0
- package/out/{street-name-lookup.d.ts → street/name-lookup.d.ts} +4 -7
- package/out/street/name-lookup.d.ts.map +1 -0
- package/out/{street-name-lookup.js → street/name-lookup.js} +9 -23
- package/out/street/name-lookup.js.map +1 -0
- package/out/street/normalize.d.ts +179 -0
- package/out/street/normalize.d.ts.map +1 -0
- package/out/street/normalize.js +457 -0
- package/out/street/normalize.js.map +1 -0
- package/out/{street-segment-schema.d.ts → street/segment-schema.d.ts} +13 -9
- package/out/street/segment-schema.d.ts.map +1 -0
- package/out/{street-segment-schema.js → street/segment-schema.js} +4 -4
- package/out/{street-segment-schema.js.map → street/segment-schema.js.map} +1 -1
- package/out/types.d.ts +49 -9
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/out/unified-schema.d.ts +6 -5
- package/out/unified-schema.d.ts.map +1 -1
- package/out/unified-schema.js +16 -19
- package/out/unified-schema.js.map +1 -1
- package/out/uprn/existence.d.ts +53 -0
- package/out/uprn/existence.d.ts.map +1 -0
- package/out/uprn/existence.js +61 -0
- package/out/uprn/existence.js.map +1 -0
- package/out/uprn/index.d.ts +9 -0
- package/out/uprn/index.d.ts.map +1 -0
- package/out/uprn/index.js +9 -0
- package/out/uprn/index.js.map +1 -0
- package/out/uprn/lookup.d.ts +85 -0
- package/out/uprn/lookup.d.ts.map +1 -0
- package/out/uprn/lookup.js +149 -0
- package/out/uprn/lookup.js.map +1 -0
- package/out/uprn/schema.d.ts +93 -0
- package/out/uprn/schema.d.ts.map +1 -0
- package/out/uprn/schema.js +78 -0
- package/out/uprn/schema.js.map +1 -0
- package/out/weights-overlay-linker.d.ts +299 -0
- package/out/weights-overlay-linker.d.ts.map +1 -0
- package/out/weights-overlay-linker.js +511 -0
- package/out/weights-overlay-linker.js.map +1 -0
- package/package.json +622 -154
- package/address-point.ts +0 -125
- package/candidate-lookup.ts +0 -720
- package/fst-autocomplete.ts +0 -204
- package/geo.ts +0 -121
- package/lookup.ts +0 -1354
- package/out/address-point-interpolation.d.ts.map +0 -1
- package/out/address-point-interpolation.js.map +0 -1
- package/out/address-point-schema.d.ts.map +0 -1
- package/out/address-point-schema.js.map +0 -1
- package/out/address-point.d.ts.map +0 -1
- package/out/address-point.js +0 -84
- package/out/address-point.js.map +0 -1
- package/out/ancestry-backfill.d.ts.map +0 -1
- package/out/ancestry-backfill.js.map +0 -1
- package/out/ancestry.d.ts.map +0 -1
- package/out/ancestry.js.map +0 -1
- package/out/convention.d.ts.map +0 -1
- package/out/convention.js.map +0 -1
- package/out/fst-autocomplete.d.ts.map +0 -1
- package/out/fst-autocomplete.js +0 -130
- package/out/fst-autocomplete.js.map +0 -1
- package/out/fst-builder.d.ts.map +0 -1
- package/out/fst-builder.js.map +0 -1
- package/out/fst-deserialize-web.d.ts.map +0 -1
- package/out/fst-deserialize-web.js.map +0 -1
- package/out/fst-freshness.d.ts.map +0 -1
- package/out/fst-freshness.js.map +0 -1
- package/out/fst-matcher.d.ts.map +0 -1
- package/out/fst-matcher.js.map +0 -1
- package/out/fst-serialize.d.ts.map +0 -1
- package/out/fst-serialize.js.map +0 -1
- package/out/fst-types.d.ts.map +0 -1
- package/out/fst-types.js.map +0 -1
- package/out/fts-query.d.ts.map +0 -1
- package/out/fts-query.js.map +0 -1
- package/out/fts.d.ts.map +0 -1
- package/out/fts.js.map +0 -1
- package/out/geo.d.ts +0 -74
- package/out/geo.d.ts.map +0 -1
- package/out/geo.js +0 -71
- package/out/geo.js.map +0 -1
- package/out/geonames-aliases.d.ts.map +0 -1
- package/out/geonames-aliases.js.map +0 -1
- package/out/geonames-postal.d.ts.map +0 -1
- package/out/geonames-postal.js.map +0 -1
- package/out/poi-lookup.d.ts.map +0 -1
- package/out/poi-lookup.js.map +0 -1
- package/out/poi-schema.d.ts.map +0 -1
- package/out/poi-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-candidate-schema.d.ts.map +0 -1
- package/out/sharding.d.ts +0 -114
- package/out/sharding.d.ts.map +0 -1
- package/out/sharding.js.map +0 -1
- package/out/street-centroid-schema.d.ts.map +0 -1
- package/out/street-centroid.d.ts.map +0 -1
- package/out/street-centroid.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 -95
- package/out/street-normalize.d.ts.map +0 -1
- package/out/street-normalize.js +0 -272
- package/out/street-normalize.js.map +0 -1
- package/out/street-segment-schema.d.ts.map +0 -1
- package/sqlite-utils.ts +0 -46
- package/street-normalize.ts +0 -318
- /package/{postal-city-alias-schema.ts → lib/postal/city-alias-schema.ts} +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The OWN-NAME VARIANT predicate (#1882): is an alias surface the holder's own primary name in
|
|
7
|
+
* another orthography — a romanization (`Брэст` → `brest`), a spacing/diacritic variant
|
|
8
|
+
* (`George Town` → `georgetown`), an abbreviation expansion (`St. George's` → `Saint George's`)
|
|
9
|
+
* — rather than a different name that merely shares the folded key?
|
|
10
|
+
*
|
|
11
|
+
* The comparator is `levenshteinSimilarity`, NOT Jaro-Winkler: JW's common-prefix bonus scores
|
|
12
|
+
* the required NEGATIVE case (`chanchun` vs `cancun`, 0.925) above real positives
|
|
13
|
+
* (`saint george s` vs `st georges` expanded, 0.914), so no JW threshold separates them.
|
|
14
|
+
* Measured on the #1882 census contests, edit similarity separates every case with margin:
|
|
15
|
+
*
|
|
16
|
+
* - IN: `brest`/`brest` 1.0 · `george town`/`georgetown` 0.909 · `saint george s`/`saint georges`
|
|
17
|
+
* 0.929 · `adamovka`/`adamowka` 0.875
|
|
18
|
+
* - OUT: `lievin`/`levin` 0.833 (Liévin FR vs Levin NZ — different places with near-identical
|
|
19
|
+
* names; the panel's `41 Weraroa Road, Levin` row needs this side) · `chanchun`/`cancun` 0.75 ·
|
|
20
|
+
* `augsburg`/`augusta` 0.375 · `west bay`/`west end` 0.625 · `derry`/`londonderry` 0.455
|
|
21
|
+
* (Derry/Londonderry is a DUAL NAME, not a variant — its own follow-up on #1882)
|
|
22
|
+
*
|
|
23
|
+
* An unhandled script (Arabic, Hebrew, CJK — the romanizer covers Cyrillic only) answers NULL,
|
|
24
|
+
* never "different name": absence of a verdict must not stamp anything (the meaning-of-zero rule).
|
|
25
|
+
* The #1882 census counted 396 demoted Arabic/Hebrew-primary aliases left unclassified by this.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Edit-similarity floor for the variant verdict. The measured band: nearest admitted pair 0.875
|
|
29
|
+
* (`adamovka`/`adamowka`), nearest refused pair 0.833 (`lievin`/`levin`).
|
|
30
|
+
*/
|
|
31
|
+
export declare const VARIANT_SIMILARITY_MIN = 0.85;
|
|
32
|
+
/**
|
|
33
|
+
* Expand the whole-word abbreviations above.
|
|
34
|
+
*/
|
|
35
|
+
export declare function expandNameAbbreviations(key: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Romanize a folded name key to the a–z0–9/space alphabet. `null` when characters outside the covered scripts remain —
|
|
38
|
+
* an unhandled script is NO VERDICT, not a mismatch.
|
|
39
|
+
*/
|
|
40
|
+
export declare function romanizeNameKey(key: string): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Edit similarity between a holder's primary name key and one of its alias keys, both romanized and
|
|
43
|
+
* abbreviation-expanded. `null` when either side's script is uncovered.
|
|
44
|
+
*/
|
|
45
|
+
export declare function ownNameSimilarity(primaryKey: string, aliasKey: string): number | null;
|
|
46
|
+
/**
|
|
47
|
+
* The stamp predicate: the alias surface is the holder's own name in another orthography.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isOwnNameVariant(primaryKey: string, aliasKey: string): boolean;
|
|
50
|
+
//# sourceMappingURL=own-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"own-name.d.ts","sourceRoot":"","sources":["../../lib/candidate/own-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;GAGG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAA;AA2D1C;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ3D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI9E"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The OWN-NAME VARIANT predicate (#1882): is an alias surface the holder's own primary name in
|
|
7
|
+
* another orthography — a romanization (`Брэст` → `brest`), a spacing/diacritic variant
|
|
8
|
+
* (`George Town` → `georgetown`), an abbreviation expansion (`St. George's` → `Saint George's`)
|
|
9
|
+
* — rather than a different name that merely shares the folded key?
|
|
10
|
+
*
|
|
11
|
+
* The comparator is `levenshteinSimilarity`, NOT Jaro-Winkler: JW's common-prefix bonus scores
|
|
12
|
+
* the required NEGATIVE case (`chanchun` vs `cancun`, 0.925) above real positives
|
|
13
|
+
* (`saint george s` vs `st georges` expanded, 0.914), so no JW threshold separates them.
|
|
14
|
+
* Measured on the #1882 census contests, edit similarity separates every case with margin:
|
|
15
|
+
*
|
|
16
|
+
* - IN: `brest`/`brest` 1.0 · `george town`/`georgetown` 0.909 · `saint george s`/`saint georges`
|
|
17
|
+
* 0.929 · `adamovka`/`adamowka` 0.875
|
|
18
|
+
* - OUT: `lievin`/`levin` 0.833 (Liévin FR vs Levin NZ — different places with near-identical
|
|
19
|
+
* names; the panel's `41 Weraroa Road, Levin` row needs this side) · `chanchun`/`cancun` 0.75 ·
|
|
20
|
+
* `augsburg`/`augusta` 0.375 · `west bay`/`west end` 0.625 · `derry`/`londonderry` 0.455
|
|
21
|
+
* (Derry/Londonderry is a DUAL NAME, not a variant — its own follow-up on #1882)
|
|
22
|
+
*
|
|
23
|
+
* An unhandled script (Arabic, Hebrew, CJK — the romanizer covers Cyrillic only) answers NULL,
|
|
24
|
+
* never "different name": absence of a verdict must not stamp anything (the meaning-of-zero rule).
|
|
25
|
+
* The #1882 census counted 396 demoted Arabic/Hebrew-primary aliases left unclassified by this.
|
|
26
|
+
*/
|
|
27
|
+
import { levenshteinSimilarity } from "@mailwoman/match/comparators";
|
|
28
|
+
/**
|
|
29
|
+
* Edit-similarity floor for the variant verdict. The measured band: nearest admitted pair 0.875
|
|
30
|
+
* (`adamovka`/`adamowka`), nearest refused pair 0.833 (`lievin`/`levin`).
|
|
31
|
+
*/
|
|
32
|
+
export const VARIANT_SIMILARITY_MIN = 0.85;
|
|
33
|
+
/**
|
|
34
|
+
* BGN/PCGN-flavored Cyrillic romanization, folded to the name-key alphabet. Digraph outputs (zh, kh, ts, ch, sh, shch,
|
|
35
|
+
* yu, ya) match the dominant transliteration conventions the gazetteer's Latin aliases actually use; the `w`/`v` and
|
|
36
|
+
* `kh`/`h` style variance between systems is what the edit-similarity threshold absorbs.
|
|
37
|
+
*/
|
|
38
|
+
const CYRILLIC_TO_LATIN = {
|
|
39
|
+
а: "a",
|
|
40
|
+
б: "b",
|
|
41
|
+
в: "v",
|
|
42
|
+
г: "g",
|
|
43
|
+
д: "d",
|
|
44
|
+
е: "e",
|
|
45
|
+
ё: "e",
|
|
46
|
+
ж: "zh",
|
|
47
|
+
з: "z",
|
|
48
|
+
и: "i",
|
|
49
|
+
і: "i",
|
|
50
|
+
й: "i",
|
|
51
|
+
к: "k",
|
|
52
|
+
л: "l",
|
|
53
|
+
м: "m",
|
|
54
|
+
н: "n",
|
|
55
|
+
о: "o",
|
|
56
|
+
п: "p",
|
|
57
|
+
р: "r",
|
|
58
|
+
с: "s",
|
|
59
|
+
т: "t",
|
|
60
|
+
у: "u",
|
|
61
|
+
ў: "u",
|
|
62
|
+
ф: "f",
|
|
63
|
+
х: "kh",
|
|
64
|
+
ц: "ts",
|
|
65
|
+
ч: "ch",
|
|
66
|
+
ш: "sh",
|
|
67
|
+
щ: "shch",
|
|
68
|
+
ъ: "",
|
|
69
|
+
ы: "y",
|
|
70
|
+
ь: "",
|
|
71
|
+
э: "e",
|
|
72
|
+
ю: "yu",
|
|
73
|
+
я: "ya",
|
|
74
|
+
ґ: "g",
|
|
75
|
+
є: "e",
|
|
76
|
+
ї: "i",
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Leading-word abbreviations expanded BEFORE comparison, so `st georges` meets `saint george s` inside the edit
|
|
80
|
+
* threshold. Whole-word only — `st` inside `stanley` never expands.
|
|
81
|
+
*/
|
|
82
|
+
const NAME_ABBREVIATIONS = [
|
|
83
|
+
[/\bst\b/g, "saint"],
|
|
84
|
+
[/\bste\b/g, "sainte"],
|
|
85
|
+
[/\bmt\b/g, "mount"],
|
|
86
|
+
[/\bft\b/g, "fort"],
|
|
87
|
+
];
|
|
88
|
+
/**
|
|
89
|
+
* Expand the whole-word abbreviations above.
|
|
90
|
+
*/
|
|
91
|
+
export function expandNameAbbreviations(key) {
|
|
92
|
+
let out = key;
|
|
93
|
+
for (const [pattern, replacement] of NAME_ABBREVIATIONS) {
|
|
94
|
+
out = out.replaceAll(pattern, replacement);
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Romanize a folded name key to the a–z0–9/space alphabet. `null` when characters outside the covered scripts remain —
|
|
100
|
+
* an unhandled script is NO VERDICT, not a mismatch.
|
|
101
|
+
*/
|
|
102
|
+
export function romanizeNameKey(key) {
|
|
103
|
+
let out = "";
|
|
104
|
+
for (const ch of key.toLowerCase()) {
|
|
105
|
+
out += CYRILLIC_TO_LATIN[ch] ?? ch;
|
|
106
|
+
}
|
|
107
|
+
out = out
|
|
108
|
+
.normalize("NFD")
|
|
109
|
+
.replaceAll(/[̀-ͯ]/g, "")
|
|
110
|
+
.replaceAll(/\s+/g, " ")
|
|
111
|
+
.trim();
|
|
112
|
+
return /^[a-z0-9 ]*$/.test(out) ? out : null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Edit similarity between a holder's primary name key and one of its alias keys, both romanized and
|
|
116
|
+
* abbreviation-expanded. `null` when either side's script is uncovered.
|
|
117
|
+
*/
|
|
118
|
+
export function ownNameSimilarity(primaryKey, aliasKey) {
|
|
119
|
+
const primary = romanizeNameKey(primaryKey);
|
|
120
|
+
const alias = romanizeNameKey(aliasKey);
|
|
121
|
+
if (primary == null || alias == null || !primary || !alias)
|
|
122
|
+
return null;
|
|
123
|
+
return levenshteinSimilarity(expandNameAbbreviations(primary), expandNameAbbreviations(alias));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The stamp predicate: the alias surface is the holder's own name in another orthography.
|
|
127
|
+
*/
|
|
128
|
+
export function isOwnNameVariant(primaryKey, aliasKey) {
|
|
129
|
+
const similarity = ownNameSimilarity(primaryKey, aliasKey);
|
|
130
|
+
return similarity != null && similarity >= VARIANT_SIMILARITY_MIN;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=own-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"own-name.js","sourceRoot":"","sources":["../../lib/candidate/own-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEpE;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAA;AAE1C;;;;GAIG;AACH,MAAM,iBAAiB,GAA2B;IACjD,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;CACN,CAAA;AAED;;;GAGG;AACH,MAAM,kBAAkB,GAAoC;IAC3D,CAAC,SAAS,EAAE,OAAO,CAAC;IACpB,CAAC,UAAU,EAAE,QAAQ,CAAC;IACtB,CAAC,SAAS,EAAE,OAAO,CAAC;IACpB,CAAC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW;IAClD,IAAI,GAAG,GAAG,GAAG,CAAA;IAEb,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,kBAAkB,EAAE,CAAC;QACzD,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;IAC3C,CAAC;IAED,OAAO,GAAG,CAAA;AACX,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IAC1C,IAAI,GAAG,GAAG,EAAE,CAAA;IAEZ,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;QACpC,GAAG,IAAI,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAA;IACnC,CAAC;IAED,GAAG,GAAG,GAAG;SACP,SAAS,CAAC,KAAK,CAAC;SAChB,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;SACxB,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC;SACvB,IAAI,EAAE,CAAA;IAER,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB,EAAE,QAAgB;IACrE,MAAM,OAAO,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;IAC3C,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAEvC,IAAI,OAAO,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvE,OAAO,qBAAqB,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAA;AAC/F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB,EAAE,QAAgB;IACpE,MAAM,UAAU,GAAG,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAE1D,OAAO,UAAU,IAAI,IAAI,IAAI,UAAU,IAAI,sBAAsB,CAAA;AAClE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file The per-place record every candidate-staging pass writes its rows from.
|
|
6
|
+
*
|
|
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 folds) discovers
|
|
9
|
+
* ADDITIONAL name keys for a place already in that map and stages a row against the same record.
|
|
10
|
+
* That is what keeps each candidate row denormalized without re-reading the source, and it is why
|
|
11
|
+
* a pass needs exactly four things to stage: the key it found, the place, the id the row hangs on,
|
|
12
|
+
* and whether the key is the place's canonical name.
|
|
13
|
+
*/
|
|
14
|
+
export interface PlaceAttrs {
|
|
15
|
+
cid: number;
|
|
16
|
+
rid: number;
|
|
17
|
+
ptid: number;
|
|
18
|
+
name: string;
|
|
19
|
+
lat: number;
|
|
20
|
+
lon: number;
|
|
21
|
+
mnLat: number;
|
|
22
|
+
mnLon: number;
|
|
23
|
+
mxLat: number;
|
|
24
|
+
mxLon: number;
|
|
25
|
+
pop: number;
|
|
26
|
+
neg: number;
|
|
27
|
+
pkey: string;
|
|
28
|
+
/**
|
|
29
|
+
* The place's toponym-fame score, or null when the score source has no measurement for it (#28). A property of the
|
|
30
|
+
* PLACE, so it rides {@link StageRow} onto the alias and abbrev rows too — that is how a bare `Moscow` reaches
|
|
31
|
+
* Москва's score through the alias row that carries the key.
|
|
32
|
+
*/
|
|
33
|
+
imp: number | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Stage one candidate row: a normalized name key, the place it belongs to, the source id the row hangs on, and whether
|
|
37
|
+
* the key is that place's canonical name (`is_primary`).
|
|
38
|
+
*
|
|
39
|
+
* `sid` is passed separately rather than read off the place because a extract fold and the alias pass stage rows for
|
|
40
|
+
* ids the admin `attrs` map never held.
|
|
41
|
+
*/
|
|
42
|
+
export type StageRow = (k: string, a: PlaceAttrs, sid: number, isPrimary: number) => void;
|
|
43
|
+
//# sourceMappingURL=place-attrs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place-attrs.d.ts","sourceRoot":"","sources":["../../lib/candidate/place-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,UAAU;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAClB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file The per-place record every candidate-staging pass writes its rows from.
|
|
6
|
+
*
|
|
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 folds) discovers
|
|
9
|
+
* ADDITIONAL name keys for a place already in that map and stages a row against the same record.
|
|
10
|
+
* That is what keeps each candidate row denormalized without re-reading the source, and it is why
|
|
11
|
+
* a pass needs exactly four things to stage: the key it found, the place, the id the row hangs on,
|
|
12
|
+
* and whether the key is the place's canonical name.
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=place-attrs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place-attrs.js","sourceRoot":"","sources":["../../lib/candidate/place-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Typed schema for the candidate gazetteer's ANCESTORS sidecar (`candidate_ancestor` +
|
|
7
|
+
* `candidate_interval`) — the containment lineage the candidate table itself cannot answer, built
|
|
8
|
+
* into the same `candidate.db` by `build-candidate.ts` and read by
|
|
9
|
+
* {@link WOFCandidateTableLookup.ancestors}.
|
|
10
|
+
*
|
|
11
|
+
* ENCODING: closure-lite rows, denormalized — one row per (place, ancestor) edge carrying the
|
|
12
|
+
* parent's placetype, display name and folded key — rather than a fixed-slot id chain on the
|
|
13
|
+
* candidate row. Decided by the two consumers:
|
|
14
|
+
*
|
|
15
|
+
* 1. The admin-coherence check needs the WINNER's chain as (placetype, name) pairs in one probe.
|
|
16
|
+
* A fixed-slot `[id;8]` chain answers with ids, and every id then needs a name lookup the
|
|
17
|
+
* artifact has no per-id table for — up to 8 indirections where the closure row has zero.
|
|
18
|
+
* 2. The account layer needs EVERY candidate under a `name_key` enumerable WITH its chain from
|
|
19
|
+
* one artifact probe ("present-but-outranked, discriminated by containment"). That is the
|
|
20
|
+
* candidate probe (contiguous) followed by one `spr_id`-clustered closure probe per candidate
|
|
21
|
+
* — each a handful of adjacent pages.
|
|
22
|
+
*
|
|
23
|
+
* Denormalizing the parent onto the edge is the same discipline as the candidate table itself:
|
|
24
|
+
* this artifact is read over HTTP byte ranges, where a join to a dimension table scatters page
|
|
25
|
+
* fetches, and a `WITHOUT ROWID` B-tree clustered on `(spr_id, depth)` keeps a whole chain in
|
|
26
|
+
* 1-2 pages. The repeated parent strings are the price of the zero-join read, paid at build time.
|
|
27
|
+
*
|
|
28
|
+
* `depth` is 1 for the NEAREST ancestor (deepest containment tier), increasing outward to the
|
|
29
|
+
* country — the same nearest-first order `ancestry.ts` serves for the FTS backend, so the two
|
|
30
|
+
* backends' `ancestors()` agree by construction. The order within a place is deterministic:
|
|
31
|
+
* containment depth descending (`placetypeDepth`), then ancestor id ascending, capped at
|
|
32
|
+
* {@link MAX_ANCESTOR_DEPTH}. `parent_name_key` is the SHARED {@link normalizeLocalityForKey}
|
|
33
|
+
* fold — the same fold `candidate.name_key` is built with, so a chain entry and a candidate key
|
|
34
|
+
* compare under one normalizer.
|
|
35
|
+
*
|
|
36
|
+
* `candidate_interval` carries pre/post-order labels over the CANONICAL-PARENT FOREST, assigned
|
|
37
|
+
* at build time: `a` contains `d` ⟺ `a.pre <= d.pre AND d.post <= a.post` — O(1) in either
|
|
38
|
+
* direction with no chain scan and no knowledge of either side's tier — and the descendants of
|
|
39
|
+
* `a` are the contiguous range `pre BETWEEN a.pre AND a.post`. Interval labels are classically
|
|
40
|
+
* avoided for their relabel-on-update cost; this database is a sealed read-only artifact rebuilt
|
|
41
|
+
* whole, which is exactly the regime where that cost is void.
|
|
42
|
+
*
|
|
43
|
+
* THE DAG CAVEAT, and the recorded choice: WOF places can carry more than one parent (multiple
|
|
44
|
+
* hierarchies, ambiguous boundaries). `candidate_ancestor` keeps EVERY parent — the closure rows
|
|
45
|
+
* are the complete containment record. A single interval pair can only encode a tree, so the
|
|
46
|
+
* interval forest links each place to ONE canonical parent: its depth-1 edge — the finest
|
|
47
|
+
* containment tier, lowest ancestor id — the same MIN-stability convention the candidate table's
|
|
48
|
+
* `region_id` stamp uses. A containment question about a NON-canonical hierarchy must consult the
|
|
49
|
+
* closure rows; the interval answer for it is `false`, which is why interval verdicts are
|
|
50
|
+
* "contained along the canonical hierarchy", never "not contained at all".
|
|
51
|
+
*
|
|
52
|
+
* ABSENCE SEMANTICS (meaning-of-zero): a place with no `candidate_interval` row has no recorded
|
|
53
|
+
* ancestry in the source (extract-fed postcodes and localities, isolated places, cycle-skipped
|
|
54
|
+
* rows). Absence is UNVERIFIABLE, never a containment verdict.
|
|
55
|
+
*/
|
|
56
|
+
import { type Kysely } from "kysely";
|
|
57
|
+
import type { CandidateDatabase } from "#candidate-schema";
|
|
58
|
+
import type { NameKey } from "#street/normalize";
|
|
59
|
+
/**
|
|
60
|
+
* The deepest chain the sidecar stores per place. WOF containment within the resolvable placetypes (country …
|
|
61
|
+
* microhood) never legitimately exceeds this; anything past it is source noise the build drops (and counts) rather than
|
|
62
|
+
* stores.
|
|
63
|
+
*/
|
|
64
|
+
export declare const MAX_ANCESTOR_DEPTH = 8;
|
|
65
|
+
/**
|
|
66
|
+
* The closure-row table's name — probed with `hasTable` by the reader, so an artifact predating the sidecar degrades to
|
|
67
|
+
* "no ancestors capability" rather than `no such table`.
|
|
68
|
+
*/
|
|
69
|
+
export declare const CANDIDATE_ANCESTOR_TABLE = "candidate_ancestor";
|
|
70
|
+
/**
|
|
71
|
+
* The interval-label table's name — the closure table's seal-time sibling; existence-restricted the same way.
|
|
72
|
+
*/
|
|
73
|
+
export declare const CANDIDATE_INTERVAL_TABLE = "candidate_interval";
|
|
74
|
+
/**
|
|
75
|
+
* One (place, ancestor) edge, denormalized so a chain read is a single clustered probe (no join).
|
|
76
|
+
*/
|
|
77
|
+
export interface CandidateAncestorTable {
|
|
78
|
+
/**
|
|
79
|
+
* WOF id of the place whose chain this row belongs to — the same `spr_id` the candidate table resolves to.
|
|
80
|
+
*/
|
|
81
|
+
spr_id: number;
|
|
82
|
+
/**
|
|
83
|
+
* 1 = nearest ancestor, increasing outward to the country. Deterministic within a place (containment depth
|
|
84
|
+
* descending, then ancestor id ascending), so `(spr_id, depth)` is a stable primary key across rebuilds.
|
|
85
|
+
*/
|
|
86
|
+
depth: number;
|
|
87
|
+
/**
|
|
88
|
+
* WOF id of the ancestor.
|
|
89
|
+
*/
|
|
90
|
+
parent_spr_id: number;
|
|
91
|
+
/**
|
|
92
|
+
* Small int from the shared `placetype_codes` dictionary (the same one the candidate table uses).
|
|
93
|
+
*/
|
|
94
|
+
parent_placetype_id: number;
|
|
95
|
+
/**
|
|
96
|
+
* The ancestor's canonical display name — what {@link Ancestor.name} serves, matching the FTS backend's register.
|
|
97
|
+
*/
|
|
98
|
+
parent_name: string;
|
|
99
|
+
/**
|
|
100
|
+
* The SHARED {@link normalizeLocalityForKey} fold of `parent_name` — comparable against `candidate.name_key` and
|
|
101
|
+
* against a query-side fold under one normalizer, by construction.
|
|
102
|
+
*/
|
|
103
|
+
parent_name_key: NameKey;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Pre/post-order labels over the canonical-parent forest — one row per place WITH recorded ancestry (see the module
|
|
107
|
+
* docstring for absence semantics). `pre < post` always; labels are unique across the artifact.
|
|
108
|
+
*/
|
|
109
|
+
export interface CandidateIntervalTable {
|
|
110
|
+
spr_id: number;
|
|
111
|
+
pre: number;
|
|
112
|
+
post: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The sidecar tables, for a `Kysely` view over the candidate DB. `CandidateDatabase` (candidate-schema.ts) extends
|
|
116
|
+
* this, so the builder's one typed client sees both families.
|
|
117
|
+
*/
|
|
118
|
+
export interface CandidateAncestorsDatabase {
|
|
119
|
+
candidate_ancestor: CandidateAncestorTable;
|
|
120
|
+
candidate_interval: CandidateIntervalTable;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The `candidate_ancestor` columns in clustered-key order — the first two ARE the primary key, and the builder's
|
|
124
|
+
* positional `INSERT` binds by this order. Keep in sync with {@link CandidateAncestorTable}.
|
|
125
|
+
*/
|
|
126
|
+
export declare const CANDIDATE_ANCESTOR_COLUMNS: readonly ["spr_id", "depth", "parent_spr_id", "parent_placetype_id", "parent_name", "parent_name_key"];
|
|
127
|
+
/**
|
|
128
|
+
* Create the clustered closure table. The builder inserts in `(spr_id, depth)` order so the B-tree leaves are
|
|
129
|
+
* contiguous per place — the byte-range read discipline.
|
|
130
|
+
*/
|
|
131
|
+
export declare function createCandidateAncestorTable(db: Kysely<CandidateDatabase>): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Create the interval-label table. Small rows probed by primary key — the `WITHOUT ROWID` win case.
|
|
134
|
+
*/
|
|
135
|
+
export declare function createCandidateIntervalTable(db: Kysely<CandidateDatabase>): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* One place's interval label — the shape both sides of a containment comparison read.
|
|
138
|
+
*/
|
|
139
|
+
export interface IntervalLabel {
|
|
140
|
+
pre: number;
|
|
141
|
+
post: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Does `outer` contain `inner` along the canonical hierarchy? Reflexive: a place contains itself (containment
|
|
145
|
+
* degenerates to identity, the same reading the admin-coherence check gives a self-match). The shared FUNCTION for
|
|
146
|
+
* every consumer of the labels — a re-derived comparison risks disagreeing at exactly the strict/inclusive boundary
|
|
147
|
+
* this line settles.
|
|
148
|
+
*/
|
|
149
|
+
export declare function intervalContains(outer: IntervalLabel, inner: IntervalLabel): boolean;
|
|
150
|
+
//# sourceMappingURL=candidate-ancestors-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-ancestors-schema.d.ts","sourceRoot":"","sources":["../lib/candidate-ancestors-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,wBAAwB,uBAAuB,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAM,wBAAwB,uBAAuB,CAAA;AAE5D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAA;IAC3B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAA;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C,kBAAkB,EAAE,sBAAsB,CAAA;IAC1C,kBAAkB,EAAE,sBAAsB,CAAA;CAC1C;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,wGAO7B,CAAA;AAEV;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAa/F;AAED;;GAEG;AACH,wBAAsB,4BAA4B,CAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ/F;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACZ;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAEpF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Typed schema for the candidate gazetteer's ANCESTORS sidecar (`candidate_ancestor` +
|
|
7
|
+
* `candidate_interval`) — the containment lineage the candidate table itself cannot answer, built
|
|
8
|
+
* into the same `candidate.db` by `build-candidate.ts` and read by
|
|
9
|
+
* {@link WOFCandidateTableLookup.ancestors}.
|
|
10
|
+
*
|
|
11
|
+
* ENCODING: closure-lite rows, denormalized — one row per (place, ancestor) edge carrying the
|
|
12
|
+
* parent's placetype, display name and folded key — rather than a fixed-slot id chain on the
|
|
13
|
+
* candidate row. Decided by the two consumers:
|
|
14
|
+
*
|
|
15
|
+
* 1. The admin-coherence check needs the WINNER's chain as (placetype, name) pairs in one probe.
|
|
16
|
+
* A fixed-slot `[id;8]` chain answers with ids, and every id then needs a name lookup the
|
|
17
|
+
* artifact has no per-id table for — up to 8 indirections where the closure row has zero.
|
|
18
|
+
* 2. The account layer needs EVERY candidate under a `name_key` enumerable WITH its chain from
|
|
19
|
+
* one artifact probe ("present-but-outranked, discriminated by containment"). That is the
|
|
20
|
+
* candidate probe (contiguous) followed by one `spr_id`-clustered closure probe per candidate
|
|
21
|
+
* — each a handful of adjacent pages.
|
|
22
|
+
*
|
|
23
|
+
* Denormalizing the parent onto the edge is the same discipline as the candidate table itself:
|
|
24
|
+
* this artifact is read over HTTP byte ranges, where a join to a dimension table scatters page
|
|
25
|
+
* fetches, and a `WITHOUT ROWID` B-tree clustered on `(spr_id, depth)` keeps a whole chain in
|
|
26
|
+
* 1-2 pages. The repeated parent strings are the price of the zero-join read, paid at build time.
|
|
27
|
+
*
|
|
28
|
+
* `depth` is 1 for the NEAREST ancestor (deepest containment tier), increasing outward to the
|
|
29
|
+
* country — the same nearest-first order `ancestry.ts` serves for the FTS backend, so the two
|
|
30
|
+
* backends' `ancestors()` agree by construction. The order within a place is deterministic:
|
|
31
|
+
* containment depth descending (`placetypeDepth`), then ancestor id ascending, capped at
|
|
32
|
+
* {@link MAX_ANCESTOR_DEPTH}. `parent_name_key` is the SHARED {@link normalizeLocalityForKey}
|
|
33
|
+
* fold — the same fold `candidate.name_key` is built with, so a chain entry and a candidate key
|
|
34
|
+
* compare under one normalizer.
|
|
35
|
+
*
|
|
36
|
+
* `candidate_interval` carries pre/post-order labels over the CANONICAL-PARENT FOREST, assigned
|
|
37
|
+
* at build time: `a` contains `d` ⟺ `a.pre <= d.pre AND d.post <= a.post` — O(1) in either
|
|
38
|
+
* direction with no chain scan and no knowledge of either side's tier — and the descendants of
|
|
39
|
+
* `a` are the contiguous range `pre BETWEEN a.pre AND a.post`. Interval labels are classically
|
|
40
|
+
* avoided for their relabel-on-update cost; this database is a sealed read-only artifact rebuilt
|
|
41
|
+
* whole, which is exactly the regime where that cost is void.
|
|
42
|
+
*
|
|
43
|
+
* THE DAG CAVEAT, and the recorded choice: WOF places can carry more than one parent (multiple
|
|
44
|
+
* hierarchies, ambiguous boundaries). `candidate_ancestor` keeps EVERY parent — the closure rows
|
|
45
|
+
* are the complete containment record. A single interval pair can only encode a tree, so the
|
|
46
|
+
* interval forest links each place to ONE canonical parent: its depth-1 edge — the finest
|
|
47
|
+
* containment tier, lowest ancestor id — the same MIN-stability convention the candidate table's
|
|
48
|
+
* `region_id` stamp uses. A containment question about a NON-canonical hierarchy must consult the
|
|
49
|
+
* closure rows; the interval answer for it is `false`, which is why interval verdicts are
|
|
50
|
+
* "contained along the canonical hierarchy", never "not contained at all".
|
|
51
|
+
*
|
|
52
|
+
* ABSENCE SEMANTICS (meaning-of-zero): a place with no `candidate_interval` row has no recorded
|
|
53
|
+
* ancestry in the source (extract-fed postcodes and localities, isolated places, cycle-skipped
|
|
54
|
+
* rows). Absence is UNVERIFIABLE, never a containment verdict.
|
|
55
|
+
*/
|
|
56
|
+
import { sql } from "kysely";
|
|
57
|
+
/**
|
|
58
|
+
* The deepest chain the sidecar stores per place. WOF containment within the resolvable placetypes (country …
|
|
59
|
+
* microhood) never legitimately exceeds this; anything past it is source noise the build drops (and counts) rather than
|
|
60
|
+
* stores.
|
|
61
|
+
*/
|
|
62
|
+
export const MAX_ANCESTOR_DEPTH = 8;
|
|
63
|
+
/**
|
|
64
|
+
* The closure-row table's name — probed with `hasTable` by the reader, so an artifact predating the sidecar degrades to
|
|
65
|
+
* "no ancestors capability" rather than `no such table`.
|
|
66
|
+
*/
|
|
67
|
+
export const CANDIDATE_ANCESTOR_TABLE = "candidate_ancestor";
|
|
68
|
+
/**
|
|
69
|
+
* The interval-label table's name — the closure table's seal-time sibling; existence-restricted the same way.
|
|
70
|
+
*/
|
|
71
|
+
export const CANDIDATE_INTERVAL_TABLE = "candidate_interval";
|
|
72
|
+
/**
|
|
73
|
+
* The `candidate_ancestor` columns in clustered-key order — the first two ARE the primary key, and the builder's
|
|
74
|
+
* positional `INSERT` binds by this order. Keep in sync with {@link CandidateAncestorTable}.
|
|
75
|
+
*/
|
|
76
|
+
export const CANDIDATE_ANCESTOR_COLUMNS = [
|
|
77
|
+
"spr_id",
|
|
78
|
+
"depth",
|
|
79
|
+
"parent_spr_id",
|
|
80
|
+
"parent_placetype_id",
|
|
81
|
+
"parent_name",
|
|
82
|
+
"parent_name_key",
|
|
83
|
+
];
|
|
84
|
+
/**
|
|
85
|
+
* Create the clustered closure table. The builder inserts in `(spr_id, depth)` order so the B-tree leaves are
|
|
86
|
+
* contiguous per place — the byte-range read discipline.
|
|
87
|
+
*/
|
|
88
|
+
export async function createCandidateAncestorTable(db) {
|
|
89
|
+
await db.schema
|
|
90
|
+
.createTable(CANDIDATE_ANCESTOR_TABLE)
|
|
91
|
+
.addColumn("spr_id", "integer", (c) => c.notNull())
|
|
92
|
+
.addColumn("depth", "integer", (c) => c.notNull())
|
|
93
|
+
.addColumn("parent_spr_id", "integer", (c) => c.notNull())
|
|
94
|
+
.addColumn("parent_placetype_id", "integer", (c) => c.notNull())
|
|
95
|
+
.addColumn("parent_name", "text", (c) => c.notNull())
|
|
96
|
+
.addColumn("parent_name_key", "text", (c) => c.notNull())
|
|
97
|
+
.addPrimaryKeyConstraint("candidate_ancestor_pk", ["spr_id", "depth"])
|
|
98
|
+
// `WITHOUT ROWID` has no first-class builder; the raw modifier is the idiomatic fallback.
|
|
99
|
+
.modifyEnd(sql `without rowid`)
|
|
100
|
+
.execute();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create the interval-label table. Small rows probed by primary key — the `WITHOUT ROWID` win case.
|
|
104
|
+
*/
|
|
105
|
+
export async function createCandidateIntervalTable(db) {
|
|
106
|
+
await db.schema
|
|
107
|
+
.createTable(CANDIDATE_INTERVAL_TABLE)
|
|
108
|
+
.addColumn("spr_id", "integer", (c) => c.primaryKey())
|
|
109
|
+
.addColumn("pre", "integer", (c) => c.notNull())
|
|
110
|
+
.addColumn("post", "integer", (c) => c.notNull())
|
|
111
|
+
.modifyEnd(sql `without rowid`)
|
|
112
|
+
.execute();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Does `outer` contain `inner` along the canonical hierarchy? Reflexive: a place contains itself (containment
|
|
116
|
+
* degenerates to identity, the same reading the admin-coherence check gives a self-match). The shared FUNCTION for
|
|
117
|
+
* every consumer of the labels — a re-derived comparison risks disagreeing at exactly the strict/inclusive boundary
|
|
118
|
+
* this line settles.
|
|
119
|
+
*/
|
|
120
|
+
export function intervalContains(outer, inner) {
|
|
121
|
+
return outer.pre <= inner.pre && inner.post <= outer.post;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=candidate-ancestors-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate-ancestors-schema.js","sourceRoot":"","sources":["../lib/candidate-ancestors-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAE,GAAG,EAAe,MAAM,QAAQ,CAAA;AAQzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAA;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAA;AAqD5D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACzC,QAAQ;IACR,OAAO;IACP,eAAe;IACf,qBAAqB;IACrB,aAAa;IACb,iBAAiB;CACR,CAAA;AAEV;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EAA6B;IAC/E,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,wBAAwB,CAAC;SACrC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAClD,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACjD,SAAS,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACzD,SAAS,CAAC,qBAAqB,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/D,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACpD,SAAS,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACxD,uBAAuB,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtE,0FAA0F;SACzF,SAAS,CAAC,GAAG,CAAA,eAAe,CAAC;SAC7B,OAAO,EAAE,CAAA;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EAA6B;IAC/E,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,wBAAwB,CAAC;SACrC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;SACrD,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/C,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAChD,SAAS,CAAC,GAAG,CAAA,eAAe,CAAC;SAC7B,OAAO,EAAE,CAAA;AACZ,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAoB,EAAE,KAAoB;IAC1E,OAAO,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAA;AAC1D,CAAC"}
|
package/out/candidate-fts.d.ts
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* raw `name`), so a diacritic-stripped query (`munchen`) trigram-matches the stored `munchen`
|
|
10
10
|
* rather than missing a raw `München`. The trigram tokenizer makes MATCH a substring/fuzzy
|
|
11
11
|
* operation; the reader ({@link WOFCandidateTableLookup}) OR's the query's trigrams to fetch a
|
|
12
|
-
* loose set, then re-ranks
|
|
13
|
-
*
|
|
12
|
+
* loose set, then re-ranks it with a WORD-level similarity. The trigram index is the candidate
|
|
13
|
+
* GENERATOR, not the scorer — trigram Jaccard scores a true transposition correction BELOW a wrong
|
|
14
|
+
* answer, because shared generic suffixes count as evidence and transpositions count against it.
|
|
15
|
+
* The receipts are on `candidate-lookup.ts`'s `FUZZY_FETCH` and `WORD_FUZZY_MIN`.
|
|
14
16
|
*
|
|
15
17
|
* This is what unifies the two gazetteers: the candidate B-tree stays the common,
|
|
16
18
|
* byte-range-optimal fast path (the browser's contiguous probe), and FTS5 is consulted ONLY on an
|
|
@@ -22,14 +24,14 @@
|
|
|
22
24
|
* (a name_key fans out to many candidate rows — placetypes, regions, aliases — but the fuzzy
|
|
23
25
|
* fallback only needs to recover the name_key, then re-probes the B-tree for its rows).
|
|
24
26
|
*/
|
|
25
|
-
import type {
|
|
27
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
26
28
|
/**
|
|
27
|
-
* Name of the FTS5 trigram virtual table this module owns. The reader
|
|
29
|
+
* Name of the FTS5 trigram virtual table this module owns. The reader conditions its fuzzy fallback on it.
|
|
28
30
|
*/
|
|
29
31
|
export declare const CANDIDATE_FTS_TABLE = "candidate_fts";
|
|
30
32
|
/**
|
|
31
33
|
* Build (or rebuild) {@link CANDIDATE_FTS_TABLE} from the materialized `candidate` table. Call after the candidate
|
|
32
34
|
* B-tree is populated (build pipeline) or against an existing candidate DB (migration).
|
|
33
35
|
*/
|
|
34
|
-
export declare function createCandidateFTS(db:
|
|
36
|
+
export declare function createCandidateFTS<DB>(db: DatabaseClient<DB>): void;
|
|
35
37
|
//# sourceMappingURL=candidate-fts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate-fts.d.ts","sourceRoot":"","sources":["../candidate-fts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"candidate-fts.d.ts","sourceRoot":"","sources":["../lib/candidate-fts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D;;GAEG;AACH,eAAO,MAAM,mBAAmB,kBAAkB,CAAA;AAElD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,IAAI,CAOnE"}
|
package/out/candidate-fts.js
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* raw `name`), so a diacritic-stripped query (`munchen`) trigram-matches the stored `munchen`
|
|
10
10
|
* rather than missing a raw `München`. The trigram tokenizer makes MATCH a substring/fuzzy
|
|
11
11
|
* operation; the reader ({@link WOFCandidateTableLookup}) OR's the query's trigrams to fetch a
|
|
12
|
-
* loose set, then re-ranks
|
|
13
|
-
*
|
|
12
|
+
* loose set, then re-ranks it with a WORD-level similarity. The trigram index is the candidate
|
|
13
|
+
* GENERATOR, not the scorer — trigram Jaccard scores a true transposition correction BELOW a wrong
|
|
14
|
+
* answer, because shared generic suffixes count as evidence and transpositions count against it.
|
|
15
|
+
* The receipts are on `candidate-lookup.ts`'s `FUZZY_FETCH` and `WORD_FUZZY_MIN`.
|
|
14
16
|
*
|
|
15
17
|
* This is what unifies the two gazetteers: the candidate B-tree stays the common,
|
|
16
18
|
* byte-range-optimal fast path (the browser's contiguous probe), and FTS5 is consulted ONLY on an
|
|
@@ -23,7 +25,7 @@
|
|
|
23
25
|
* fallback only needs to recover the name_key, then re-probes the B-tree for its rows).
|
|
24
26
|
*/
|
|
25
27
|
/**
|
|
26
|
-
* Name of the FTS5 trigram virtual table this module owns. The reader
|
|
28
|
+
* Name of the FTS5 trigram virtual table this module owns. The reader conditions its fuzzy fallback on it.
|
|
27
29
|
*/
|
|
28
30
|
export const CANDIDATE_FTS_TABLE = "candidate_fts";
|
|
29
31
|
/**
|
package/out/candidate-fts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate-fts.js","sourceRoot":"","sources":["../candidate-fts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"candidate-fts.js","sourceRoot":"","sources":["../lib/candidate-fts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAA;AAElD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAK,EAAsB;IAC5D,EAAE,CAAC,IAAI,CAAC,wBAAwB,mBAAmB,EAAE,CAAC,CAAA;IACtD,EAAE,CAAC,IAAI,CAAC,wBAAwB,mBAAmB,2CAA2C,CAAC,CAAA;IAE/F,EAAE,CAAC,IAAI,CACN,eAAe,mBAAmB,+EAA+E,CACjH,CAAA;AACF,CAAC"}
|