@mailwoman/resolver-wof-sqlite 10.0.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/lib/address/point/interpolation.ts +45 -39
- package/lib/address/point/schema.ts +17 -40
- package/lib/address/point.ts +316 -0
- package/lib/{address/index.ts → address.ts} +1 -1
- package/lib/ancestry/backfill.ts +20 -86
- package/lib/{ancestry/index.ts → ancestry.ts} +19 -15
- package/lib/build/candidate.ts +122 -174
- package/lib/build/population-corrections.ts +64 -0
- package/lib/build/slim.ts +44 -114
- package/lib/candidate/alias-bags.ts +16 -17
- package/lib/candidate/ancestors/schema.ts +77 -61
- package/lib/candidate/ancestors/sidecar.ts +15 -22
- package/lib/candidate/country-display-names.ts +6 -20
- package/lib/candidate/extract-fold.ts +10 -55
- package/lib/candidate/fts.ts +5 -23
- package/lib/candidate/importance.ts +65 -68
- package/lib/candidate/lookup.ts +124 -415
- package/lib/candidate/name-roles.ts +15 -33
- package/lib/candidate/own-name.ts +35 -32
- package/lib/candidate/place-attrs.ts +20 -13
- package/lib/candidate/schema.ts +29 -65
- package/lib/candidate/scoring.ts +54 -93
- package/lib/capital-schema.ts +21 -17
- package/lib/capitals.ts +29 -27
- package/lib/coincident-roles.ts +85 -55
- package/lib/convention/schema.ts +15 -16
- package/lib/convention.ts +144 -0
- package/lib/coverage-manifest-schema.ts +40 -45
- package/lib/currency-backfill.ts +34 -79
- package/lib/env.ts +1 -1
- package/lib/exact-match.ts +32 -21
- package/lib/extracts.ts +97 -74
- package/lib/fst/autocomplete.ts +54 -37
- package/lib/fst/builder.ts +37 -41
- package/lib/fst/deserialize-web.ts +16 -17
- package/lib/fst/format.ts +41 -23
- package/lib/fst/freshness.ts +43 -120
- package/lib/fst/matcher.ts +7 -5
- package/lib/fst/serialize.ts +54 -74
- package/lib/fst/types.ts +78 -75
- package/lib/{fst/index.ts → fst.ts} +1 -0
- package/lib/fts/query.ts +5 -36
- package/lib/fts.ts +280 -0
- package/lib/geonames/aliases.ts +73 -144
- package/lib/geonames/postal.ts +162 -71
- package/lib/index.ts +9 -8
- package/lib/interpolation.ts +48 -100
- package/lib/lookup.ts +155 -270
- package/lib/name-score.ts +9 -7
- package/lib/nsul/lookup.ts +37 -54
- package/lib/nsul/schema.ts +16 -43
- package/lib/paths.ts +159 -0
- package/lib/place-importance-schema.ts +62 -169
- package/lib/poi/lookup.ts +104 -121
- package/lib/poi/schema.ts +42 -26
- package/lib/polygon-schema.ts +10 -6
- package/lib/postal/city/alias/lookup.ts +22 -40
- package/lib/postal/city/alias/schema.ts +14 -10
- package/lib/postal/city/candidate-schema.ts +26 -20
- package/lib/postcode-point-lookup.ts +8 -27
- package/lib/primary-preference.ts +46 -126
- package/lib/proximity-rerank.ts +44 -33
- package/lib/ranking-weights.ts +105 -78
- package/lib/region-keys.ts +70 -42
- package/lib/reverse.ts +149 -86
- package/lib/schema.ts +73 -50
- package/lib/search-fetch.ts +90 -68
- package/lib/sqlite/convention-source.ts +15 -23
- package/lib/sqlite/utils.ts +19 -22
- package/lib/street/centroid/schema.ts +37 -42
- package/lib/street/{centroid/index.ts → centroid.ts} +16 -25
- package/lib/street/morphology/fst/builder.ts +60 -42
- package/lib/street/morphology/fst/loader.ts +40 -32
- package/lib/street/name-lookup.ts +45 -41
- package/lib/street/normalize.ts +88 -219
- package/lib/street/segment-schema.ts +116 -43
- package/lib/{street/index.ts → street.ts} +1 -1
- package/lib/types.ts +109 -150
- package/lib/unified-schema.ts +29 -29
- package/lib/uprn/existence.ts +30 -19
- package/lib/uprn/lookup.ts +29 -68
- package/lib/uprn/schema.ts +18 -40
- package/lib/weights-overlay-linker.ts +236 -252
- package/out/address/point/interpolation.d.ts +20 -23
- package/out/address/point/interpolation.d.ts.map +1 -1
- package/out/address/point/interpolation.js +42 -39
- package/out/address/point/interpolation.js.map +1 -1
- package/out/address/point/schema.d.ts +12 -35
- package/out/address/point/schema.d.ts.map +1 -1
- package/out/address/point/schema.js +3 -19
- package/out/address/point/schema.js.map +1 -1
- package/out/address/point.d.ts +57 -0
- package/out/address/point.d.ts.map +1 -0
- package/out/address/point.js +206 -0
- package/out/address/point.js.map +1 -0
- package/out/{address/index.js → address.d.ts} +2 -2
- package/out/address.d.ts.map +1 -0
- package/out/{address/index.d.ts → address.js} +2 -2
- package/out/address.js.map +1 -0
- package/out/ancestry/backfill.d.ts +11 -64
- package/out/ancestry/backfill.d.ts.map +1 -1
- package/out/ancestry/backfill.js +14 -74
- package/out/ancestry/backfill.js.map +1 -1
- package/out/ancestry.d.ts +49 -0
- package/out/ancestry.d.ts.map +1 -0
- package/out/ancestry.js +59 -0
- package/out/ancestry.js.map +1 -0
- package/out/build/candidate.d.ts +82 -112
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +17 -100
- package/out/build/candidate.js.map +1 -1
- package/out/build/population-corrections.d.ts +52 -0
- package/out/build/population-corrections.d.ts.map +1 -0
- package/out/build/population-corrections.js +40 -0
- package/out/build/population-corrections.js.map +1 -0
- package/out/build/slim.d.ts +8 -44
- package/out/build/slim.d.ts.map +1 -1
- package/out/build/slim.js +33 -94
- package/out/build/slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +6 -6
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +16 -17
- package/out/candidate/alias-bags.js.map +1 -1
- package/out/candidate/ancestors/schema.d.ts +73 -57
- package/out/candidate/ancestors/schema.d.ts.map +1 -1
- package/out/candidate/ancestors/schema.js +56 -48
- package/out/candidate/ancestors/schema.js.map +1 -1
- package/out/candidate/ancestors/sidecar.d.ts +3 -8
- package/out/candidate/ancestors/sidecar.d.ts.map +1 -1
- package/out/candidate/ancestors/sidecar.js +15 -22
- package/out/candidate/ancestors/sidecar.js.map +1 -1
- package/out/candidate/country-display-names.d.ts +5 -15
- package/out/candidate/country-display-names.d.ts.map +1 -1
- package/out/candidate/country-display-names.js +6 -20
- package/out/candidate/country-display-names.js.map +1 -1
- package/out/candidate/extract-fold.d.ts +7 -15
- package/out/candidate/extract-fold.d.ts.map +1 -1
- package/out/candidate/extract-fold.js +5 -47
- package/out/candidate/extract-fold.js.map +1 -1
- package/out/candidate/fts.d.ts +5 -23
- package/out/candidate/fts.d.ts.map +1 -1
- package/out/candidate/fts.js +5 -23
- package/out/candidate/fts.js.map +1 -1
- package/out/candidate/importance.d.ts +60 -65
- package/out/candidate/importance.d.ts.map +1 -1
- package/out/candidate/importance.js +56 -63
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/lookup.d.ts +18 -55
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +82 -385
- package/out/candidate/lookup.js.map +1 -1
- package/out/candidate/name-roles.d.ts +9 -21
- package/out/candidate/name-roles.d.ts.map +1 -1
- package/out/candidate/name-roles.js +15 -33
- package/out/candidate/name-roles.js.map +1 -1
- package/out/candidate/own-name.d.ts +23 -25
- package/out/candidate/own-name.d.ts.map +1 -1
- package/out/candidate/own-name.js +35 -32
- package/out/candidate/own-name.js.map +1 -1
- package/out/candidate/place-attrs.d.ts +20 -13
- package/out/candidate/place-attrs.d.ts.map +1 -1
- package/out/candidate/place-attrs.js +4 -5
- package/out/candidate/place-attrs.js.map +1 -1
- package/out/candidate/schema.d.ts +27 -62
- package/out/candidate/schema.d.ts.map +1 -1
- package/out/candidate/schema.js +10 -22
- package/out/candidate/schema.js.map +1 -1
- package/out/candidate/scoring.d.ts +7 -8
- package/out/candidate/scoring.d.ts.map +1 -1
- package/out/candidate/scoring.js +52 -89
- package/out/candidate/scoring.js.map +1 -1
- package/out/capital-schema.d.ts +21 -17
- package/out/capital-schema.d.ts.map +1 -1
- package/out/capital-schema.js +17 -15
- package/out/capital-schema.js.map +1 -1
- package/out/capitals.d.ts +27 -25
- package/out/capitals.d.ts.map +1 -1
- package/out/capitals.js +23 -21
- package/out/capitals.js.map +1 -1
- package/out/coincident-roles.d.ts +60 -43
- package/out/coincident-roles.d.ts.map +1 -1
- package/out/coincident-roles.js +72 -50
- package/out/coincident-roles.js.map +1 -1
- package/out/convention/schema.d.ts +14 -14
- package/out/convention/schema.d.ts.map +1 -1
- package/out/convention/schema.js +6 -4
- package/out/convention/schema.js.map +1 -1
- package/out/convention.d.ts +97 -0
- package/out/convention.d.ts.map +1 -0
- package/out/convention.js +81 -0
- package/out/convention.js.map +1 -0
- package/out/coverage-manifest-schema.d.ts +34 -39
- package/out/coverage-manifest-schema.d.ts.map +1 -1
- package/out/coverage-manifest-schema.js +25 -34
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/currency-backfill.d.ts +16 -38
- package/out/currency-backfill.d.ts.map +1 -1
- package/out/currency-backfill.js +19 -46
- package/out/currency-backfill.js.map +1 -1
- package/out/env.d.ts +1 -1
- package/out/env.js +1 -1
- package/out/exact-match.d.ts +19 -10
- package/out/exact-match.d.ts.map +1 -1
- package/out/exact-match.js +32 -21
- package/out/exact-match.js.map +1 -1
- package/out/extracts.d.ts +66 -55
- package/out/extracts.d.ts.map +1 -1
- package/out/extracts.js +63 -55
- package/out/extracts.js.map +1 -1
- package/out/fst/autocomplete.d.ts +29 -21
- package/out/fst/autocomplete.d.ts.map +1 -1
- package/out/fst/autocomplete.js +39 -28
- package/out/fst/autocomplete.js.map +1 -1
- package/out/fst/builder.d.ts.map +1 -1
- package/out/fst/builder.js +37 -41
- package/out/fst/builder.js.map +1 -1
- package/out/fst/deserialize-web.d.ts +4 -4
- package/out/fst/deserialize-web.d.ts.map +1 -1
- package/out/fst/deserialize-web.js +15 -16
- package/out/fst/deserialize-web.js.map +1 -1
- package/out/fst/format.d.ts +41 -23
- package/out/fst/format.d.ts.map +1 -1
- package/out/fst/format.js +41 -23
- package/out/fst/format.js.map +1 -1
- package/out/fst/freshness.d.ts +19 -81
- package/out/fst/freshness.d.ts.map +1 -1
- package/out/fst/freshness.js +31 -94
- package/out/fst/freshness.js.map +1 -1
- package/out/fst/matcher.d.ts +5 -4
- package/out/fst/matcher.d.ts.map +1 -1
- package/out/fst/matcher.js +2 -2
- package/out/fst/matcher.js.map +1 -1
- package/out/fst/serialize.d.ts +28 -28
- package/out/fst/serialize.d.ts.map +1 -1
- package/out/fst/serialize.js +53 -71
- package/out/fst/serialize.js.map +1 -1
- package/out/fst/types.d.ts +78 -74
- package/out/fst/types.d.ts.map +1 -1
- package/out/fst/types.js +1 -4
- package/out/fst/types.js.map +1 -1
- package/out/{fst/index.js → fst.d.ts} +2 -1
- package/out/fst.d.ts.map +1 -0
- package/out/{fst/index.d.ts → fst.js} +2 -1
- package/out/fst.js.map +1 -0
- package/out/fts/query.d.ts +2 -27
- package/out/fts/query.d.ts.map +1 -1
- package/out/fts/query.js +5 -36
- package/out/fts/query.js.map +1 -1
- package/out/fts.d.ts +126 -0
- package/out/fts.d.ts.map +1 -0
- package/out/fts.js +188 -0
- package/out/fts.js.map +1 -0
- package/out/geonames/aliases.d.ts +26 -62
- package/out/geonames/aliases.d.ts.map +1 -1
- package/out/geonames/aliases.js +45 -117
- package/out/geonames/aliases.js.map +1 -1
- package/out/geonames/postal.d.ts +84 -44
- package/out/geonames/postal.d.ts.map +1 -1
- package/out/geonames/postal.js +115 -73
- package/out/geonames/postal.js.map +1 -1
- package/out/{geonames/index.js → geonames.d.ts} +1 -1
- package/out/geonames.d.ts.map +1 -0
- package/out/{geonames/index.d.ts → geonames.js} +1 -1
- package/out/geonames.js.map +1 -0
- package/out/index.d.ts +9 -8
- package/out/index.d.ts.map +1 -1
- package/out/index.js +6 -5
- package/out/index.js.map +1 -1
- package/out/interpolation.d.ts +18 -55
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +27 -69
- package/out/interpolation.js.map +1 -1
- package/out/lookup.d.ts +23 -51
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +136 -234
- package/out/lookup.js.map +1 -1
- package/out/name-score.d.ts +2 -2
- package/out/name-score.d.ts.map +1 -1
- package/out/name-score.js +9 -7
- package/out/name-score.js.map +1 -1
- package/out/nsul/lookup.d.ts +33 -34
- package/out/nsul/lookup.d.ts.map +1 -1
- package/out/nsul/lookup.js +26 -40
- package/out/nsul/lookup.js.map +1 -1
- package/out/nsul/schema.d.ts +16 -43
- package/out/nsul/schema.d.ts.map +1 -1
- package/out/nsul/schema.js +9 -35
- package/out/nsul/schema.js.map +1 -1
- package/out/{nsul/index.d.ts → nsul.d.ts} +1 -1
- package/out/nsul.d.ts.map +1 -0
- package/out/{nsul/index.js → nsul.js} +1 -1
- package/out/nsul.js.map +1 -0
- package/out/paths.d.ts +124 -0
- package/out/paths.d.ts.map +1 -0
- package/out/paths.js +104 -0
- package/out/paths.js.map +1 -0
- package/out/place-importance-schema.d.ts +51 -143
- package/out/place-importance-schema.d.ts.map +1 -1
- package/out/place-importance-schema.js +28 -143
- package/out/place-importance-schema.js.map +1 -1
- package/out/poi/lookup.d.ts +40 -47
- package/out/poi/lookup.d.ts.map +1 -1
- package/out/poi/lookup.js +69 -96
- package/out/poi/lookup.js.map +1 -1
- package/out/poi/schema.d.ts +41 -25
- package/out/poi/schema.d.ts.map +1 -1
- package/out/poi/schema.js +25 -17
- package/out/poi/schema.js.map +1 -1
- package/out/{poi/index.js → poi.d.ts} +1 -1
- package/out/poi.d.ts.map +1 -0
- package/out/{poi/index.d.ts → poi.js} +1 -1
- package/out/poi.js.map +1 -0
- package/out/polygon-schema.d.ts +10 -6
- package/out/polygon-schema.d.ts.map +1 -1
- package/out/polygon-schema.js +2 -2
- package/out/polygon-schema.js.map +1 -1
- package/out/postal/city/alias/lookup.d.ts +20 -23
- package/out/postal/city/alias/lookup.d.ts.map +1 -1
- package/out/postal/city/alias/lookup.js +17 -30
- package/out/postal/city/alias/lookup.js.map +1 -1
- package/out/postal/city/alias/schema.d.ts +14 -10
- package/out/postal/city/alias/schema.d.ts.map +1 -1
- package/out/postal/city/alias/schema.js +10 -8
- package/out/postal/city/alias/schema.js.map +1 -1
- package/out/postal/city/candidate-schema.d.ts +25 -19
- package/out/postal/city/candidate-schema.d.ts.map +1 -1
- package/out/postal/city/candidate-schema.js +21 -17
- package/out/postal/city/candidate-schema.js.map +1 -1
- package/out/{postal/index.d.ts → postal.d.ts} +1 -1
- package/out/postal.d.ts.map +1 -0
- package/out/{postal/index.js → postal.js} +1 -1
- package/out/postal.js.map +1 -0
- package/out/postcode-point-lookup.d.ts +6 -24
- package/out/postcode-point-lookup.d.ts.map +1 -1
- package/out/postcode-point-lookup.js +5 -17
- package/out/postcode-point-lookup.js.map +1 -1
- package/out/primary-preference.d.ts +38 -92
- package/out/primary-preference.d.ts.map +1 -1
- package/out/primary-preference.js +15 -99
- package/out/primary-preference.js.map +1 -1
- package/out/proximity-rerank.d.ts +41 -30
- package/out/proximity-rerank.d.ts.map +1 -1
- package/out/proximity-rerank.js +38 -29
- package/out/proximity-rerank.js.map +1 -1
- package/out/ranking-weights.d.ts +98 -64
- package/out/ranking-weights.d.ts.map +1 -1
- package/out/ranking-weights.js +26 -25
- package/out/ranking-weights.js.map +1 -1
- package/out/region-keys.d.ts +50 -31
- package/out/region-keys.d.ts.map +1 -1
- package/out/region-keys.js +68 -40
- package/out/region-keys.js.map +1 -1
- package/out/reverse.d.ts +78 -50
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +98 -61
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +72 -49
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +4 -5
- package/out/schema.js.map +1 -1
- package/out/search-fetch.d.ts +16 -12
- package/out/search-fetch.d.ts.map +1 -1
- package/out/search-fetch.js +83 -63
- package/out/search-fetch.js.map +1 -1
- package/out/sqlite/convention-source.d.ts +12 -16
- package/out/sqlite/convention-source.d.ts.map +1 -1
- package/out/sqlite/convention-source.js +13 -22
- package/out/sqlite/convention-source.js.map +1 -1
- package/out/sqlite/utils.d.ts +19 -19
- package/out/sqlite/utils.d.ts.map +1 -1
- package/out/sqlite/utils.js +14 -15
- package/out/sqlite/utils.js.map +1 -1
- package/out/street/centroid/schema.d.ts +37 -42
- package/out/street/centroid/schema.d.ts.map +1 -1
- package/out/street/centroid/schema.js +9 -21
- package/out/street/centroid/schema.js.map +1 -1
- package/out/street/centroid.d.ts +30 -0
- package/out/street/centroid.d.ts.map +1 -0
- package/out/street/{centroid/index.js → centroid.js} +13 -24
- package/out/street/centroid.js.map +1 -0
- package/out/street/morphology/fst/builder.d.ts +20 -10
- package/out/street/morphology/fst/builder.d.ts.map +1 -1
- package/out/street/morphology/fst/builder.js +44 -34
- package/out/street/morphology/fst/builder.js.map +1 -1
- package/out/street/morphology/fst/loader.d.ts +33 -26
- package/out/street/morphology/fst/loader.d.ts.map +1 -1
- package/out/street/morphology/fst/loader.js +23 -22
- package/out/street/morphology/fst/loader.js.map +1 -1
- package/out/street/name-lookup.d.ts +24 -18
- package/out/street/name-lookup.d.ts.map +1 -1
- package/out/street/name-lookup.js +34 -35
- package/out/street/name-lookup.js.map +1 -1
- package/out/street/normalize.d.ts +35 -136
- package/out/street/normalize.d.ts.map +1 -1
- package/out/street/normalize.js +77 -194
- package/out/street/normalize.js.map +1 -1
- package/out/street/segment-schema.d.ts +79 -39
- package/out/street/segment-schema.d.ts.map +1 -1
- package/out/street/segment-schema.js +71 -21
- package/out/street/segment-schema.js.map +1 -1
- package/out/{street/index.js → street.d.ts} +2 -2
- package/out/street.d.ts.map +1 -0
- package/out/{street/index.d.ts → street.js} +2 -2
- package/out/street.js.map +1 -0
- package/out/types.d.ts +84 -149
- package/out/types.d.ts.map +1 -1
- package/out/types.js +0 -6
- package/out/types.js.map +1 -1
- package/out/unified-schema.d.ts +8 -12
- package/out/unified-schema.d.ts.map +1 -1
- package/out/unified-schema.js +29 -29
- package/out/unified-schema.js.map +1 -1
- package/out/uprn/existence.d.ts +28 -17
- package/out/uprn/existence.d.ts.map +1 -1
- package/out/uprn/existence.js +26 -16
- package/out/uprn/existence.js.map +1 -1
- package/out/uprn/lookup.d.ts +14 -44
- package/out/uprn/lookup.d.ts.map +1 -1
- package/out/uprn/lookup.js +21 -57
- package/out/uprn/lookup.js.map +1 -1
- package/out/uprn/schema.d.ts +18 -40
- package/out/uprn/schema.d.ts.map +1 -1
- package/out/uprn/schema.js +10 -32
- package/out/uprn/schema.js.map +1 -1
- package/out/{uprn/index.d.ts → uprn.d.ts} +1 -1
- package/out/uprn.d.ts.map +1 -0
- package/out/{uprn/index.js → uprn.js} +1 -1
- package/out/uprn.js.map +1 -0
- package/out/weights-overlay-linker.d.ts +138 -144
- package/out/weights-overlay-linker.d.ts.map +1 -1
- package/out/weights-overlay-linker.js +105 -159
- package/out/weights-overlay-linker.js.map +1 -1
- package/package.json +91 -596
- package/lib/address/point/index.ts +0 -328
- package/lib/convention/index.ts +0 -154
- package/lib/fts/index.ts +0 -361
- package/out/address/index.d.ts.map +0 -1
- package/out/address/index.js.map +0 -1
- package/out/address/point/index.d.ts +0 -53
- package/out/address/point/index.d.ts.map +0 -1
- package/out/address/point/index.js +0 -222
- package/out/address/point/index.js.map +0 -1
- package/out/ancestry/index.d.ts +0 -45
- package/out/ancestry/index.d.ts.map +0 -1
- package/out/ancestry/index.js +0 -55
- package/out/ancestry/index.js.map +0 -1
- package/out/convention/index.d.ts +0 -106
- package/out/convention/index.d.ts.map +0 -1
- package/out/convention/index.js +0 -93
- package/out/convention/index.js.map +0 -1
- package/out/fst/index.d.ts.map +0 -1
- package/out/fst/index.js.map +0 -1
- package/out/fts/index.d.ts +0 -184
- package/out/fts/index.d.ts.map +0 -1
- package/out/fts/index.js +0 -277
- package/out/fts/index.js.map +0 -1
- package/out/geonames/index.d.ts.map +0 -1
- package/out/geonames/index.js.map +0 -1
- package/out/nsul/index.d.ts.map +0 -1
- package/out/nsul/index.js.map +0 -1
- package/out/poi/index.d.ts.map +0 -1
- package/out/poi/index.js.map +0 -1
- package/out/postal/index.d.ts.map +0 -1
- package/out/postal/index.js.map +0 -1
- package/out/street/centroid/index.d.ts +0 -40
- package/out/street/centroid/index.d.ts.map +0 -1
- package/out/street/centroid/index.js.map +0 -1
- package/out/street/index.d.ts.map +0 -1
- package/out/street/index.js.map +0 -1
- package/out/uprn/index.d.ts.map +0 -1
- package/out/uprn/index.js.map +0 -1
- /package/lib/{geonames/index.ts → geonames.ts} +0 -0
- /package/lib/{nsul/index.ts → nsul.ts} +0 -0
- /package/lib/{poi/index.ts → poi.ts} +0 -0
- /package/lib/{postal/index.ts → postal.ts} +0 -0
- /package/lib/{uprn/index.ts → uprn.ts} +0 -0
|
@@ -2,31 +2,24 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* `SqliteConventionSource` — a `ConventionSource` backed by the build-from-source convention asset
|
|
7
|
-
* (#290, Direction E). Conventions live in a read-only, provenance-stamped `address_convention`
|
|
8
|
-
* table keyed by WOF polygon id; this source queries them ON DEMAND by id (one indexed lookup,
|
|
9
|
-
* memoized) rather than paging the whole table into memory as a code constant — the deliberate
|
|
10
|
-
* counter to the Pelias "giant dictionary in RAM, no provenance" pattern (see the operator design
|
|
11
|
-
* value in memory `feedback-no-irrelevant-trivia`).
|
|
12
|
-
*
|
|
13
|
-
* The asset is the queryable, distributable artifact; the strategy IMPLEMENTATIONS stay in code. An
|
|
14
|
-
* unknown strategy NAME is surfaced loudly at dispatch (see `lookup.ts`), not silently
|
|
15
|
-
* swallowed.
|
|
16
5
|
*/
|
|
17
6
|
import { tryParsingJSON } from "@mailwoman/core/json";
|
|
18
|
-
import { ADDRESS_CONVENTION_TABLE } from "#convention
|
|
7
|
+
import { ADDRESS_CONVENTION_TABLE } from "#convention";
|
|
8
|
+
/**
|
|
9
|
+
* Reads per-place address conventions from the convention table in an attached
|
|
10
|
+
* SQLite schema, caching each lookup, including misses.
|
|
11
|
+
*
|
|
12
|
+
* A missing table or unparseable row reads as no convention rather than throwing.
|
|
13
|
+
*/
|
|
19
14
|
export class SqliteConventionSource {
|
|
20
15
|
#db;
|
|
21
16
|
#schema;
|
|
22
|
-
/**
|
|
23
|
-
* Memoize per-id lookups (including misses, as `null`) so a hot ancestor chain is queried once.
|
|
24
|
-
*/
|
|
25
17
|
#cache = new Map();
|
|
26
18
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
19
|
+
* Creates a source over an open database that is, or has attached, the convention asset.
|
|
20
|
+
*
|
|
21
|
+
* @param db The open database handle.
|
|
22
|
+
* @param schema The schema that holds the convention table, either `main` or an attached extract's name.
|
|
30
23
|
*/
|
|
31
24
|
constructor(db, schema) {
|
|
32
25
|
this.#db = db;
|
|
@@ -35,7 +28,7 @@ export class SqliteConventionSource {
|
|
|
35
28
|
get(wofID) {
|
|
36
29
|
const cached = this.#cache.get(wofID);
|
|
37
30
|
if (cached !== undefined)
|
|
38
|
-
return cached
|
|
31
|
+
return cached;
|
|
39
32
|
let value = null;
|
|
40
33
|
try {
|
|
41
34
|
const row = this.#db
|
|
@@ -46,12 +39,10 @@ export class SqliteConventionSource {
|
|
|
46
39
|
}
|
|
47
40
|
}
|
|
48
41
|
catch {
|
|
49
|
-
// A missing table → treat as no override (the chain falls back to WORLD_DEFAULT); malformed
|
|
50
|
-
// JSON already nulls out above. The build script validates structure, so this is purely defensive.
|
|
51
42
|
value = null;
|
|
52
43
|
}
|
|
53
44
|
this.#cache.set(wofID, value);
|
|
54
|
-
return value
|
|
45
|
+
return value;
|
|
55
46
|
}
|
|
56
47
|
}
|
|
57
48
|
//# sourceMappingURL=convention-source.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convention-source.js","sourceRoot":"","sources":["../../lib/sqlite/convention-source.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"convention-source.js","sourceRoot":"","sources":["../../lib/sqlite/convention-source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,EAAE,wBAAwB,EAA0C,MAAM,aAAa,CAAA;AAE9F;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IACzB,GAAG,CAAoB;IACvB,OAAO,CAAQ;IAEf,MAAM,GAAG,IAAI,GAAG,EAA6B,CAAA;IAEtD;;;;;OAKG;IACH,YAAY,EAAsB,EAAE,MAAc;QACjD,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,GAAG,CAAC,KAAa;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAErC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAA;QACvC,IAAI,KAAK,GAAsB,IAAI,CAAA;QAEnC,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG;iBAClB,OAAO,CAAC,0BAA0B,IAAI,CAAC,OAAO,IAAI,wBAAwB,mBAAmB,CAAC;iBAC9F,GAAG,CAAC,KAAK,CAAuC,CAAA;YAElD,IAAI,GAAG,EAAE,UAAU,EAAE,CAAC;gBACrB,KAAK,GAAG,cAAc,CAAa,GAAG,CAAC,UAAU,CAAC,CAAA;YACnD,CAAC;QACF,CAAC;QAAC,MAAM,CAAC;YACR,KAAK,GAAG,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAE7B,OAAO,KAAK,CAAA;IACb,CAAC;CACD"}
|
package/out/sqlite/utils.d.ts
CHANGED
|
@@ -2,44 +2,44 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Small shared helpers for the SQLite-backed lookups.
|
|
5
|
+
* @file Shared helpers for the SQLite-backed lookups.
|
|
7
6
|
*/
|
|
8
7
|
import type { DatabaseClient, SQLInputValue } from "@mailwoman/sqlite/client";
|
|
9
8
|
/**
|
|
10
|
-
* A prepared single-row query whose parameter tuple
|
|
11
|
-
*
|
|
9
|
+
* A prepared single-row query whose parameter tuple stays visible to TypeScript.
|
|
10
|
+
*
|
|
11
|
+
* `StatementSync` accepts any `SQLInputValue[]`, which would erase tagged key types at the call site.
|
|
12
12
|
*/
|
|
13
|
-
export type PreparedGet<Parameters extends SQLInputValue[], Row> = (...parameters: Parameters) => Row |
|
|
13
|
+
export type PreparedGet<Parameters extends SQLInputValue[], Row> = (...parameters: Parameters) => Row | null;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Prepares a single-row query with a typed parameter tuple.
|
|
16
16
|
*/
|
|
17
17
|
export declare function prepareGet<Parameters extends SQLInputValue[], Row, DB>(db: DatabaseClient<DB>, sql: string): PreparedGet<Parameters, Row>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* The multi-row counterpart to {@link PreparedGet}.
|
|
20
20
|
*/
|
|
21
21
|
export type PreparedAll<Parameters extends SQLInputValue[], Row> = (...parameters: Parameters) => Row[];
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Prepares a multi-row query with a typed parameter tuple.
|
|
24
24
|
*/
|
|
25
25
|
export declare function prepareAll<Parameters extends SQLInputValue[], Row, DB>(db: DatabaseClient<DB>, sql: string): PreparedAll<Parameters, Row>;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* Returns true when `name` is a table in the open database.
|
|
28
|
+
* Returns false when the check itself fails.
|
|
29
|
+
*
|
|
30
|
+
* The street-level lookups call it so that an empty extract, such as an interrupted build
|
|
31
|
+
* or a zero-byte file, makes every lookup miss instead of throwing `no such table`.
|
|
31
32
|
*/
|
|
32
33
|
export declare function hasTable<DB>(db: DatabaseClient<DB>, name: string): boolean;
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* Returns true when `table` exists in the open database and has `column`.
|
|
35
36
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* construction and shape the query — `table_info` is a PRAGMA, so it must not sit on a per-query path.
|
|
37
|
+
* An artifact built before a column was added is still valid, so readers call this once
|
|
38
|
+
* at construction and leave the column out of their queries when it is missing.
|
|
39
|
+
* Avoid calling it per query, because it runs a pragma.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* The pragma does not accept bound parameters, so `table` is interpolated into the SQL.
|
|
42
|
+
* Pass only constants.
|
|
43
43
|
*/
|
|
44
44
|
export declare function hasColumn<DB>(db: DatabaseClient<DB>, table: string, column: string): boolean;
|
|
45
45
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/sqlite/utils.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/sqlite/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAG7E;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,UAAU,SAAS,aAAa,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,UAAU,EAAE,UAAU,KAAK,GAAG,GAAG,IAAI,CAAA;AAE5G;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,SAAS,aAAa,EAAE,EAAE,GAAG,EAAE,EAAE,EACrE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EACtB,GAAG,EAAE,MAAM,GACT,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAI9B;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,UAAU,SAAS,aAAa,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,UAAU,EAAE,UAAU,KAAK,GAAG,EAAE,CAAA;AAEvG;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,SAAS,aAAa,EAAE,EAAE,GAAG,EAAE,EAAE,EACrE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EACtB,GAAG,EAAE,MAAM,GACT,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAI9B;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAM5F"}
|
package/out/sqlite/utils.js
CHANGED
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Small shared helpers for the SQLite-backed lookups.
|
|
5
|
+
* @file Shared helpers for the SQLite-backed lookups.
|
|
7
6
|
*/
|
|
8
7
|
import { allRows, getRow } from "@mailwoman/core/utils";
|
|
9
8
|
import { hasColumn as columnExists, tableExists } from "@mailwoman/sqlite/introspection";
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
10
|
+
* Prepares a single-row query with a typed parameter tuple.
|
|
12
11
|
*/
|
|
13
12
|
export function prepareGet(db, sql) {
|
|
14
13
|
const statement = db.prepare(sql);
|
|
15
14
|
return (...parameters) => getRow(statement, ...parameters);
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Prepares a multi-row query with a typed parameter tuple.
|
|
19
18
|
*/
|
|
20
19
|
export function prepareAll(db, sql) {
|
|
21
20
|
const statement = db.prepare(sql);
|
|
22
21
|
return (...parameters) => allRows(statement, ...parameters);
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* Returns true when `name` is a table in the open database.
|
|
25
|
+
* Returns false when the check itself fails.
|
|
26
|
+
*
|
|
27
|
+
* The street-level lookups call it so that an empty extract, such as an interrupted build
|
|
28
|
+
* or a zero-byte file, makes every lookup miss instead of throwing `no such table`.
|
|
29
29
|
*/
|
|
30
30
|
export function hasTable(db, name) {
|
|
31
31
|
try {
|
|
@@ -36,15 +36,14 @@ export function hasTable(db, name) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Returns true when `table` exists in the open database and has `column`.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* construction and shape the query — `table_info` is a PRAGMA, so it must not sit on a per-query path.
|
|
41
|
+
* An artifact built before a column was added is still valid, so readers call this once
|
|
42
|
+
* at construction and leave the column out of their queries when it is missing.
|
|
43
|
+
* Avoid calling it per query, because it runs a pragma.
|
|
45
44
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* The pragma does not accept bound parameters, so `table` is interpolated into the SQL.
|
|
46
|
+
* Pass only constants.
|
|
48
47
|
*/
|
|
49
48
|
export function hasColumn(db, table, column) {
|
|
50
49
|
try {
|
package/out/sqlite/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/sqlite/utils.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/sqlite/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AASxF;;GAEG;AACH,MAAM,UAAU,UAAU,CACzB,EAAsB,EACtB,GAAW;IAEX,MAAM,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAEjC,OAAO,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,MAAM,CAAM,SAAS,EAAE,GAAG,UAAU,CAAC,CAAA;AAChE,CAAC;AAOD;;GAEG;AACH,MAAM,UAAU,UAAU,CACzB,EAAsB,EACtB,GAAW;IAEX,MAAM,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAEjC,OAAO,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,OAAO,CAAM,SAAS,EAAE,GAAG,UAAU,CAAC,CAAA;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAK,EAAsB,EAAE,IAAY;IAChE,IAAI,CAAC;QACJ,OAAO,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAC7B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAK,EAAsB,EAAE,KAAa,EAAE,MAAc;IAClF,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC"}
|
|
@@ -3,49 +3,41 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* `ban/scripts/build-street-centroid-extract.ts` — the #1042 street-level tier behind "street-only
|
|
8
|
-
* FR queries deserve a street-level answer"). The extract is a `GROUP BY street` roll-up of the
|
|
9
|
-
* sealed rooftop address-point extract: one row per (street, postcode, commune) carrying the street's
|
|
10
|
-
* CENTROID + bounding-box EXTENT + member-point count. No new data source — a derived artifact.
|
|
11
|
-
*
|
|
12
|
-
* Single source of truth for the columns shared by the BUILDER (a positional prepared INSERT for
|
|
13
|
-
* throughput) and the READER ({@link StreetCentroidSqliteLookup}), so a column rename in one is a
|
|
14
|
-
* compile error in the other — the same discipline as `address-point-schema.ts`.
|
|
15
|
-
*
|
|
16
|
-
* Probe scopes (most-selective first): by `postcode`, else by `locality_base` (the
|
|
17
|
-
* arrondissement-stripped commune — see `stripArrondissement`; BAN names Paris/Lyon/Marseille rows
|
|
18
|
-
* per arrondissement, but a query names the base commune). The reader WEIGHTED-aggregates across the
|
|
19
|
-
* matched rows (by `point_count`) so a locality-scope probe returns the street's grand centroid over
|
|
20
|
-
* every postcode/arrondissement it spans.
|
|
6
|
+
* Schema for the street-centroid extract. It groups address-point rows by street.
|
|
21
7
|
*/
|
|
22
8
|
import type { Kysely } from "kysely";
|
|
23
9
|
import type { NameKey, StreetKey } from "#street/normalize";
|
|
24
10
|
/**
|
|
25
|
-
* One
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
11
|
+
* One row per street, postcode and commune.
|
|
12
|
+
*
|
|
13
|
+
* The tuple `(street_norm, postcode, locality_base)` is unique.
|
|
14
|
+
* The reader combines rows by `SUM(lat * point_count) / SUM(point_count)` to get a
|
|
15
|
+
* street's centroid across every postcode and arrondissement it spans.
|
|
16
|
+
*
|
|
17
|
+
* It converts the bounding-box diagonal from the `min_*` and `max_*` columns into `uncertainty_m`.
|
|
29
18
|
*/
|
|
30
19
|
export interface StreetCentroidTable {
|
|
31
20
|
/**
|
|
32
|
-
*
|
|
21
|
+
* The street key from `normalizeStreetForKeyLocale`, which both the builder and the reader use.
|
|
33
22
|
*/
|
|
34
23
|
street_norm: StreetKey;
|
|
35
24
|
/**
|
|
36
|
-
* The
|
|
25
|
+
* The postcode of this group, or null when the source row has none.
|
|
37
26
|
*/
|
|
38
27
|
postcode: string | null;
|
|
39
28
|
/**
|
|
40
|
-
*
|
|
29
|
+
* The commune key with any arrondissement removed.
|
|
30
|
+
*
|
|
31
|
+
* BAN stores Paris, Lyon and Marseille per arrondissement, but a query usually gives the base commune.
|
|
32
|
+
* The reader uses this column when the query has no postcode.
|
|
41
33
|
*/
|
|
42
34
|
locality_base: NameKey;
|
|
43
35
|
/**
|
|
44
|
-
*
|
|
36
|
+
* The mean latitude of the group's member address points.
|
|
45
37
|
*/
|
|
46
38
|
lat: number;
|
|
47
39
|
/**
|
|
48
|
-
*
|
|
40
|
+
* The mean longitude of the group's member address points.
|
|
49
41
|
*/
|
|
50
42
|
lon: number;
|
|
51
43
|
min_lat: number;
|
|
@@ -53,31 +45,32 @@ export interface StreetCentroidTable {
|
|
|
53
45
|
min_lon: number;
|
|
54
46
|
max_lon: number;
|
|
55
47
|
/**
|
|
56
|
-
*
|
|
48
|
+
* The number of member address points.
|
|
49
|
+
* This value weights the cross-row centroid.
|
|
57
50
|
*/
|
|
58
51
|
point_count: number;
|
|
59
52
|
/**
|
|
60
|
-
*
|
|
53
|
+
* One street name as it appeared in the source, kept for display and debugging.
|
|
61
54
|
*/
|
|
62
55
|
street_raw: string;
|
|
63
56
|
/**
|
|
64
|
-
*
|
|
57
|
+
* The source register, such as `ban:fr`.
|
|
65
58
|
*/
|
|
66
59
|
source: string;
|
|
67
60
|
/**
|
|
68
|
-
* The
|
|
61
|
+
* The data release that the member points came from.
|
|
69
62
|
*/
|
|
70
63
|
release: string;
|
|
71
64
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
65
|
+
* The value of `foldStreetSurface(street_raw)`, used by {@link StreetLocalityEvidence}
|
|
66
|
+
* to check that a street name exists.
|
|
67
|
+
*
|
|
68
|
+
* The name-evidence rerank folds the model's street text with the same function, so this
|
|
69
|
+
* column must use `foldStreetSurface` and must not follow the `street_norm` normalizer.
|
|
70
|
+
* The type is a plain string because `foldStreetSurface` differs from the
|
|
71
|
+
* {@link NameKey} fold that other `name_key` columns use.
|
|
77
72
|
*
|
|
78
|
-
*
|
|
79
|
-
* {@link NameKey} one every other `name_key` column carries, and giving it that brand would invite exactly the
|
|
80
|
-
* cross-fold probe the brands exist to stop.
|
|
73
|
+
* A `NameKey` type would allow a probe with the wrong fold.
|
|
81
74
|
*/
|
|
82
75
|
name_key: string;
|
|
83
76
|
}
|
|
@@ -88,18 +81,20 @@ export interface StreetCentroidDatabase {
|
|
|
88
81
|
street_centroid: StreetCentroidTable;
|
|
89
82
|
}
|
|
90
83
|
/**
|
|
91
|
-
* The `street_centroid` columns in
|
|
92
|
-
*
|
|
84
|
+
* The `street_centroid` columns in insert order.
|
|
85
|
+
*
|
|
86
|
+
* The builder derives the placeholders of its positional insert from this list.
|
|
93
87
|
*/
|
|
94
88
|
export declare const STREET_CENTROID_COLUMNS: readonly ["street_norm", "postcode", "locality_base", "lat", "lon", "min_lat", "max_lat", "min_lon", "max_lon", "point_count", "street_raw", "source", "release", "name_key"];
|
|
95
89
|
/**
|
|
96
|
-
*
|
|
90
|
+
* Creates the `street_centroid` table before the bulk load.
|
|
97
91
|
*/
|
|
98
92
|
export declare function createStreetCentroidTable(db: Kysely<StreetCentroidDatabase>): Promise<void>;
|
|
99
93
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
94
|
+
* Creates the postcode and locality indexes that the reader probes, plus `idx_sc_name`.
|
|
95
|
+
*
|
|
96
|
+
* The `idx_sc_name` index serves the unscoped `name_key = ?` lookup.
|
|
97
|
+
* Without it, SQLite would skip-scan `idx_sc_postcode`.
|
|
103
98
|
*/
|
|
104
99
|
export declare function createStreetCentroidIndexes(db: Kysely<StreetCentroidDatabase>): Promise<void>;
|
|
105
100
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../lib/street/centroid/schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../lib/street/centroid/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,WAAW,EAAE,SAAS,CAAA;IACtB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB;;;;;OAKG;IACH,aAAa,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,eAAe,EAAE,mBAAmB,CAAA;CACpC;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,YACnC,aAAa,EACb,UAAU,EACV,eAAe,EACf,KAAK,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,UAAU,CACD,CAAA;AAEV;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,MAAM,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBjG;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAAC,EAAE,EAAE,MAAM,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnG"}
|
|
@@ -3,25 +3,12 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* `ban/scripts/build-street-centroid-extract.ts` — the #1042 street-level tier behind "street-only
|
|
8
|
-
* FR queries deserve a street-level answer"). The extract is a `GROUP BY street` roll-up of the
|
|
9
|
-
* sealed rooftop address-point extract: one row per (street, postcode, commune) carrying the street's
|
|
10
|
-
* CENTROID + bounding-box EXTENT + member-point count. No new data source — a derived artifact.
|
|
11
|
-
*
|
|
12
|
-
* Single source of truth for the columns shared by the BUILDER (a positional prepared INSERT for
|
|
13
|
-
* throughput) and the READER ({@link StreetCentroidSqliteLookup}), so a column rename in one is a
|
|
14
|
-
* compile error in the other — the same discipline as `address-point-schema.ts`.
|
|
15
|
-
*
|
|
16
|
-
* Probe scopes (most-selective first): by `postcode`, else by `locality_base` (the
|
|
17
|
-
* arrondissement-stripped commune — see `stripArrondissement`; BAN names Paris/Lyon/Marseille rows
|
|
18
|
-
* per arrondissement, but a query names the base commune). The reader WEIGHTED-aggregates across the
|
|
19
|
-
* matched rows (by `point_count`) so a locality-scope probe returns the street's grand centroid over
|
|
20
|
-
* every postcode/arrondissement it spans.
|
|
6
|
+
* Schema for the street-centroid extract. It groups address-point rows by street.
|
|
21
7
|
*/
|
|
22
8
|
/**
|
|
23
|
-
* The `street_centroid` columns in
|
|
24
|
-
*
|
|
9
|
+
* The `street_centroid` columns in insert order.
|
|
10
|
+
*
|
|
11
|
+
* The builder derives the placeholders of its positional insert from this list.
|
|
25
12
|
*/
|
|
26
13
|
export const STREET_CENTROID_COLUMNS = [
|
|
27
14
|
"street_norm",
|
|
@@ -40,7 +27,7 @@ export const STREET_CENTROID_COLUMNS = [
|
|
|
40
27
|
"name_key",
|
|
41
28
|
];
|
|
42
29
|
/**
|
|
43
|
-
*
|
|
30
|
+
* Creates the `street_centroid` table before the bulk load.
|
|
44
31
|
*/
|
|
45
32
|
export async function createStreetCentroidTable(db) {
|
|
46
33
|
await db.schema
|
|
@@ -62,9 +49,10 @@ export async function createStreetCentroidTable(db) {
|
|
|
62
49
|
.execute();
|
|
63
50
|
}
|
|
64
51
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
52
|
+
* Creates the postcode and locality indexes that the reader probes, plus `idx_sc_name`.
|
|
53
|
+
*
|
|
54
|
+
* The `idx_sc_name` index serves the unscoped `name_key = ?` lookup.
|
|
55
|
+
* Without it, SQLite would skip-scan `idx_sc_postcode`.
|
|
68
56
|
*/
|
|
69
57
|
export async function createStreetCentroidIndexes(db) {
|
|
70
58
|
await db.schema.createIndex("idx_sc_postcode").on("street_centroid").columns(["postcode", "street_norm"]).execute();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../lib/street/centroid/schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../lib/street/centroid/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiFH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,aAAa;IACb,UAAU;IACV,eAAe;IACf,KAAK;IACL,KAAK;IACL,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,UAAU;CACD,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAAkC;IACjF,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,iBAAiB,CAAC;SAC9B,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACpD,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;SAC7B,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACtD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC5C,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC5C,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAChD,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAChD,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAChD,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAChD,SAAS,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACvD,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACnD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/C,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAChD,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACjD,OAAO,EAAE,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAAkC;IACnF,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;IAEnH,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,iBAAiB,CAAC;SAC9B,EAAE,CAAC,iBAAiB,CAAC;SACrB,OAAO,CAAC,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;SACzC,OAAO,EAAE,CAAA;IAEX,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;AACjG,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file SQLite implementation of core's `StreetCentroidLookup`.
|
|
6
|
+
*/
|
|
7
|
+
import type { StreetCentroidHit, StreetCentroidLookup } from "@mailwoman/core/resolver";
|
|
8
|
+
import type { PathBuilderLike } from "path-ts";
|
|
9
|
+
import { type StreetLocale } from "#street/normalize";
|
|
10
|
+
/**
|
|
11
|
+
* Finds a street's centroid and extent-based uncertainty by street name,
|
|
12
|
+
* scoped by postcode and then by base commune.
|
|
13
|
+
*/
|
|
14
|
+
export declare class StreetCentroidSqliteLookup implements StreetCentroidLookup {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* The extract defaults to the `fr` street-normalization locale.
|
|
18
|
+
* A mismatch with the extract's locale makes every key miss.
|
|
19
|
+
*/
|
|
20
|
+
constructor(dbPath: PathBuilderLike, opts?: {
|
|
21
|
+
streetLocale?: StreetLocale;
|
|
22
|
+
});
|
|
23
|
+
find(query: {
|
|
24
|
+
street: string;
|
|
25
|
+
postcode?: string;
|
|
26
|
+
locality?: string;
|
|
27
|
+
}): StreetCentroidHit | null;
|
|
28
|
+
[Symbol.dispose](): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=centroid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"centroid.d.ts","sourceRoot":"","sources":["../../lib/street/centroid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAGvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,EAMN,KAAK,YAAY,EAEjB,MAAM,mBAAmB,CAAA;AAkC1B;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,oBAAoB;;IAMtE;;;OAGG;IACH,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,GAAE;QAAE,YAAY,CAAC,EAAE,YAAY,CAAA;KAAO,EAgB9E;IAED,IAAI,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,iBAAiB,GAAG,IAAI,CA0B9F;IAED,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAEvB;CACD"}
|
|
@@ -2,54 +2,43 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* SQLite implementation of core's `StreetCentroidLookup` (#1042): the street-level tier BELOW the
|
|
7
|
-
* exact address-point tier and ABOVE admin-centroid resolution. Given a street name (no house
|
|
8
|
-
* number) plus a postcode/commune scope, it returns the street's CENTROID + an honest extent-derived
|
|
9
|
-
* uncertainty from the derived `street-centroids-<cc>.db` roll-up.
|
|
10
|
-
*
|
|
11
|
-
* Query-side normalization is THE shared normalizer (`street-normalize.ts`), selected per the extract's
|
|
12
|
-
* `streetLocale`, so build-side and probe-side keys agree by construction. The commune scope folds
|
|
13
|
-
* through `normalizeLocalityForKey` + `stripArrondissement` (BAN names Paris/Lyon/Marseille per
|
|
14
|
-
* arrondissement; a query names the base commune).
|
|
15
|
-
*
|
|
16
|
-
* Scope order is most-selective first: `postcode`, then the base commune. Each scope WEIGHTED-
|
|
17
|
-
* aggregates (by `point_count`) across the matched rows in SQL, so a commune-scope probe returns the
|
|
18
|
-
* street's grand centroid over every postcode/arrondissement it spans — one row, one hit. Matching is
|
|
19
|
-
* exact-after-normalization only (no fuzzy street matching in this tier).
|
|
5
|
+
* @file SQLite implementation of core's `StreetCentroidLookup`.
|
|
20
6
|
*/
|
|
21
7
|
import { haversineKm } from "@mailwoman/spatial";
|
|
22
8
|
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
23
9
|
import { hasTable, prepareGet } from "#sqlite-utils";
|
|
24
10
|
import { normalizeLocalityForKey, normalizeStreetForKeyLocale, streetLocaleForSurface, stripArrondissement, } from "#street/normalize";
|
|
25
11
|
/**
|
|
26
|
-
*
|
|
12
|
+
* The aggregate columns that weight each row's centroid by `point_count` to
|
|
13
|
+
* reconstruct the combined centroid.
|
|
27
14
|
*/
|
|
28
15
|
const AGG_SELECT = "SUM(lat * point_count) / SUM(point_count) AS lat, " +
|
|
29
16
|
"SUM(lon * point_count) / SUM(point_count) AS lon, " +
|
|
30
17
|
"MIN(min_lat) AS min_lat, MAX(max_lat) AS max_lat, MIN(min_lon) AS min_lon, MAX(max_lon) AS max_lon, " +
|
|
31
18
|
"MAX(source) AS source, MAX(release) AS release";
|
|
32
19
|
/**
|
|
33
|
-
* Half the
|
|
20
|
+
* Half the bounding-box diagonal in meters, used as a coarse uncertainty radius for a street centroid.
|
|
34
21
|
*/
|
|
35
22
|
function extentRadiusM(minLat, maxLat, minLon, maxLon) {
|
|
36
23
|
return Math.round(haversineKm(minLat, minLon, maxLat, maxLon) * 500);
|
|
37
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Finds a street's centroid and extent-based uncertainty by street name,
|
|
27
|
+
* scoped by postcode and then by base commune.
|
|
28
|
+
*/
|
|
38
29
|
export class StreetCentroidSqliteLookup {
|
|
39
30
|
#db;
|
|
40
31
|
#locale;
|
|
41
32
|
#byPostcode;
|
|
42
33
|
#byLocality;
|
|
43
34
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* misses. Defaults to `"fr"` (BAN is the French national register; the tier is FR-only today).
|
|
35
|
+
* The extract defaults to the `fr` street-normalization locale.
|
|
36
|
+
* A mismatch with the extract's locale makes every key miss.
|
|
47
37
|
*/
|
|
48
38
|
constructor(dbPath, opts = {}) {
|
|
49
39
|
this.#db = new DatabaseClient(dbPath, { readOnly: true });
|
|
50
40
|
this.#locale = opts.streetLocale ?? "fr";
|
|
51
|
-
//
|
|
52
|
-
// `street_centroid` table this lookup is a no-op miss, not a crash (mirrors the address-point reader).
|
|
41
|
+
// An extract without a `street_centroid` table makes every lookup miss.
|
|
53
42
|
if (hasTable(this.#db, "street_centroid")) {
|
|
54
43
|
this.#byPostcode = prepareGet(this.#db, `SELECT ${AGG_SELECT} FROM street_centroid WHERE postcode = ? AND street_norm = ?`);
|
|
55
44
|
this.#byLocality = prepareGet(this.#db, `SELECT ${AGG_SELECT} FROM street_centroid WHERE locality_base = ? AND street_norm = ?`);
|
|
@@ -61,7 +50,7 @@ export class StreetCentroidSqliteLookup {
|
|
|
61
50
|
const streetNorm = normalizeStreetForKeyLocale(query.street, streetLocaleForSurface(query.street, this.#locale));
|
|
62
51
|
if (!streetNorm)
|
|
63
52
|
return null;
|
|
64
|
-
let row;
|
|
53
|
+
let row = null;
|
|
65
54
|
if (query.postcode?.trim()) {
|
|
66
55
|
row = this.#byPostcode(query.postcode.trim(), streetNorm);
|
|
67
56
|
}
|
|
@@ -83,4 +72,4 @@ export class StreetCentroidSqliteLookup {
|
|
|
83
72
|
this.#db[Symbol.dispose]();
|
|
84
73
|
}
|
|
85
74
|
}
|
|
86
|
-
//# sourceMappingURL=
|
|
75
|
+
//# sourceMappingURL=centroid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"centroid.js","sourceRoot":"","sources":["../../lib/street/centroid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAA;AAEtE,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAG3B,sBAAsB,EAEtB,mBAAmB,GACnB,MAAM,mBAAmB,CAAA;AAiB1B;;;GAGG;AACH,MAAM,UAAU,GACf,oDAAoD;IACpD,oDAAoD;IACpD,sGAAsG;IACtG,gDAAgD,CAAA;AAEjD;;GAEG;AACH,SAAS,aAAa,CAAC,MAAc,EAAE,MAAc,EAAE,MAAc,EAAE,MAAc;IACpF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,CAAA;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IAC7B,GAAG,CAAwC;IAC3C,OAAO,CAAc;IACrB,WAAW,CAAwE;IACnF,WAAW,CAAyE;IAE7F;;;OAGG;IACH,YAAY,MAAuB,EAAE,IAAI,GAAoC,EAAE;QAC9E,IAAI,CAAC,GAAG,GAAG,IAAI,cAAc,CAAyB,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;QACjF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAA;QAExC,wEAAwE;QACxE,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,WAAW,GAAG,UAAU,CAC5B,IAAI,CAAC,GAAG,EACR,UAAU,UAAU,8DAA8D,CAClF,CAAA;YAED,IAAI,CAAC,WAAW,GAAG,UAAU,CAC5B,IAAI,CAAC,GAAG,EACR,UAAU,UAAU,mEAAmE,CACvF,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,CAAC,KAA+D;QACnE,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAA;QACvD,MAAM,UAAU,GAAG,2BAA2B,CAAC,KAAK,CAAC,MAAM,EAAE,sBAAsB,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEhH,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAA;QAE5B,IAAI,GAAG,GAAkB,IAAI,CAAA;QAE7B,IAAI,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;YAC5B,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,CAAA;QAC1D,CAAC;QAED,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;YACzD,MAAM,IAAI,GAAG,mBAAmB,CAAC,uBAAuB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;YACzE,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;QACzC,CAAC;QAED,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI;YAAE,OAAO,IAAI,CAAA;QAE3D,OAAO;YACN,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,YAAY,EAAE,aAAa,CAAC,GAAG,CAAC,OAAQ,EAAE,GAAG,CAAC,OAAQ,EAAE,GAAG,CAAC,OAAQ,EAAE,GAAG,CAAC,OAAQ,CAAC;YACnF,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE;YACxB,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE;SAC1B,CAAA;IACF,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACf,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;IAC3B,CAAC;CACD"}
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Build a street-morphology FST from libpostal's street_types dictionaries. The morphology FST maps
|
|
7
7
|
* street-typing affixes (Street/Avenue/rue/Calle/Straße/...) to a single synthetic placetype
|
|
8
|
-
* `"street_affix"
|
|
8
|
+
* `"street_affix"`. Its source data and purpose differ from the admin FST.
|
|
9
|
+
* It also produces a separate binary artifact.
|
|
9
10
|
*
|
|
10
11
|
* The morphology FST closes the inference-time vacuum identified by the v0.6.1 postmortem: street
|
|
11
12
|
* tokens have no admin-FST anchor, so synth-street training pushed the model toward over-emitting
|
|
12
13
|
* `dependent_locality` on subcomponents. With the morphology FST, the neural decoder gets
|
|
13
14
|
* positive evidence for street-typing affixes and the adjacent name tokens, plus negative
|
|
14
|
-
* evidence away from `dependent_locality` on the same
|
|
15
|
+
* evidence away from `dependent_locality` on the same neighbors.
|
|
15
16
|
*
|
|
16
17
|
* Design rationale + the four-layer street-supplement architecture lives in
|
|
17
18
|
* `docs/articles/concepts/street-supplement-architecture.md`.
|
|
@@ -22,25 +23,34 @@
|
|
|
22
23
|
* Output: an `FSTMatcher` ready to serialize via `serializeFST` to e.g.
|
|
23
24
|
* `fst-street-morphology.bin`.
|
|
24
25
|
*/
|
|
26
|
+
import { type PathBuilderLike } from "path-ts";
|
|
25
27
|
import { FSTMatcher } from "#fst/matcher";
|
|
26
28
|
import type { FSTProvenance } from "#fst/types";
|
|
27
29
|
export interface BuildStreetMorphologyFSTOpts {
|
|
28
30
|
/**
|
|
29
31
|
* Path to the `core/data/libpostal/dictionaries` directory containing per-locale subfolders.
|
|
30
32
|
*/
|
|
31
|
-
dictionariesDir:
|
|
33
|
+
dictionariesDir: PathBuilderLike;
|
|
32
34
|
/**
|
|
33
|
-
* Optional locale filter — only ingest these locale subfolders.
|
|
35
|
+
* Optional locale filter — only ingest these locale subfolders.
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue all that have a `street_types.txt`.
|
|
34
38
|
*/
|
|
35
39
|
locales?: string[];
|
|
36
40
|
/**
|
|
37
|
-
* Minimum length (in characters, post-normalization) of variant surface forms to insert into the trie.
|
|
41
|
+
* Minimum length (in characters, post-normalization) of variant surface forms to insert into the trie.
|
|
42
|
+
*
|
|
43
|
+
* Rationale: libpostal's street_types dictionaries contain 1-2 character abbreviations
|
|
44
|
+
* (`a`, `b`, `av`, `bd`, `br`, ...) that collide with non-affix tokens at parse time,
|
|
45
|
+
* including US state abbreviations (`or`, `CA`, `ND`, `NY`).
|
|
46
|
+
* Single-letter unit designators and other short tokens also collide.
|
|
47
|
+
*
|
|
48
|
+
* Empirically these collisions push the morphology prior to mis-tag state
|
|
49
|
+
* abbreviations as `street_suffix`.
|
|
50
|
+
*
|
|
51
|
+
* A minimum length of 3 retains useful forms (`ave`, `blvd`, `rue`, `str`) while filtering out the noise.
|
|
38
52
|
*
|
|
39
|
-
*
|
|
40
|
-
* ...) that collide with non-affix tokens at parse time — notably US state abbreviations (`OR`, `CA`, `ND`, `NY`),
|
|
41
|
-
* single-letter unit designators, and arbitrary short tokens. Empirically these collisions push the morphology prior
|
|
42
|
-
* to mis-tag state abbreviations as `street_suffix`. A minimum length of 3 retains useful forms (`ave`, `blvd`,
|
|
43
|
-
* `rue`, `str`) while filtering out the noise.
|
|
53
|
+
* @defaultValue `3`
|
|
44
54
|
*/
|
|
45
55
|
minVariantLength?: number;
|
|
46
56
|
/**
|