@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.
Files changed (501) hide show
  1. package/README.md +36 -20
  2. package/lib/address/index.ts +9 -0
  3. package/{address-point-interpolation.ts → lib/address/point-interpolation.ts} +40 -28
  4. package/{address-point-schema.ts → lib/address/point-schema.ts} +34 -8
  5. package/lib/address/point.ts +280 -0
  6. package/{ancestry-backfill.ts → lib/ancestry/backfill.ts} +14 -19
  7. package/{ancestry.ts → lib/ancestry/index.ts} +13 -8
  8. package/{build-candidate.ts → lib/build-candidate.ts} +243 -199
  9. package/{build-slim.ts → lib/build-slim.ts} +153 -168
  10. package/lib/candidate/alias-bags.ts +56 -0
  11. package/lib/candidate/ancestors-sidecar.ts +204 -0
  12. package/lib/candidate/country-display-names.ts +79 -0
  13. package/lib/candidate/extract-fold.ts +138 -0
  14. package/lib/candidate/name-roles.ts +238 -0
  15. package/lib/candidate/own-name.ts +146 -0
  16. package/lib/candidate/place-attrs.ts +44 -0
  17. package/lib/candidate-ancestors-schema.ts +195 -0
  18. package/{candidate-fts.ts → lib/candidate-fts.ts} +7 -5
  19. package/{candidate-importance.ts → lib/candidate-importance.ts} +54 -57
  20. package/lib/candidate-lookup.ts +976 -0
  21. package/{candidate-schema.ts → lib/candidate-schema.ts} +34 -6
  22. package/lib/candidate-scoring.ts +261 -0
  23. package/lib/capital-schema.ts +89 -0
  24. package/lib/capitals.ts +148 -0
  25. package/{coincident-roles.ts → lib/coincident-roles.ts} +75 -19
  26. package/{convention.ts → lib/convention/index.ts} +5 -5
  27. package/lib/convention/schema.ts +72 -0
  28. package/{coverage-manifest-schema.ts → lib/coverage-manifest-schema.ts} +15 -16
  29. package/lib/currency-backfill.ts +334 -0
  30. package/lib/env.ts +50 -0
  31. package/lib/exact-match.ts +113 -0
  32. package/{sharding.ts → lib/extracts.ts} +63 -60
  33. package/lib/fst/autocomplete.ts +176 -0
  34. package/{fst-builder.ts → lib/fst/builder.ts} +30 -27
  35. package/{fst-deserialize-web.ts → lib/fst/deserialize-web.ts} +27 -87
  36. package/lib/fst/format.ts +106 -0
  37. package/{fst-freshness.ts → lib/fst/freshness.ts} +42 -75
  38. package/lib/fst/index.ts +14 -0
  39. package/{fst-matcher.ts → lib/fst/matcher.ts} +1 -1
  40. package/{fst-serialize.ts → lib/fst/serialize.ts} +37 -115
  41. package/{fst-types.ts → lib/fst/types.ts} +4 -2
  42. package/{fts.ts → lib/fts/index.ts} +28 -23
  43. package/{fts-query.ts → lib/fts/query.ts} +2 -2
  44. package/{geonames-aliases.ts → lib/geonames/aliases.ts} +13 -13
  45. package/lib/geonames/index.ts +8 -0
  46. package/{geonames-postal.ts → lib/geonames/postal.ts} +16 -15
  47. package/{index.ts → lib/index.ts} +52 -48
  48. package/{interpolation.ts → lib/interpolation.ts} +137 -41
  49. package/lib/lookup.ts +861 -0
  50. package/{name-score.ts → lib/name-score.ts} +6 -4
  51. package/lib/nsul/index.ts +8 -0
  52. package/lib/nsul/lookup.ts +144 -0
  53. package/lib/nsul/schema.ts +130 -0
  54. package/{place-importance-schema.ts → lib/place-importance-schema.ts} +70 -22
  55. package/lib/poi/index.ts +8 -0
  56. package/{poi-lookup.ts → lib/poi/lookup.ts} +32 -39
  57. package/{poi-schema.ts → lib/poi/schema.ts} +10 -6
  58. package/lib/polygon-schema.ts +47 -0
  59. package/{postal-city-alias-lookup.ts → lib/postal/city-alias-lookup.ts} +15 -21
  60. package/{postal-city-candidate-schema.ts → lib/postal/city-candidate-schema.ts} +4 -2
  61. package/lib/postal/index.ts +9 -0
  62. package/{postcode-point-lookup.ts → lib/postcode-point-lookup.ts} +17 -15
  63. package/lib/primary-preference.ts +226 -0
  64. package/lib/proximity-rerank.ts +120 -0
  65. package/{ranking-weights.ts → lib/ranking-weights.ts} +30 -4
  66. package/lib/region-keys.ts +144 -0
  67. package/{reverse.ts → lib/reverse.ts} +45 -56
  68. package/{schema.ts → lib/schema.ts} +11 -1
  69. package/lib/search-fetch.ts +257 -0
  70. package/{sqlite-convention-source.ts → lib/sqlite-convention-source.ts} +9 -10
  71. package/lib/sqlite-utils.ts +83 -0
  72. package/{street-centroid-schema.ts → lib/street/centroid-schema.ts} +12 -6
  73. package/{street-centroid.ts → lib/street/centroid.ts} +26 -28
  74. package/lib/street/index.ts +13 -0
  75. package/{street-morphology-fst-builder.ts → lib/street/morphology-fst-builder.ts} +24 -14
  76. package/{street-morphology-fst-loader.ts → lib/street/morphology-fst-loader.ts} +14 -12
  77. package/{street-name-lookup.ts → lib/street/name-lookup.ts} +14 -30
  78. package/lib/street/normalize.ts +572 -0
  79. package/{street-segment-schema.ts → lib/street/segment-schema.ts} +13 -8
  80. package/{types.ts → lib/types.ts} +49 -9
  81. package/{unified-schema.ts → lib/unified-schema.ts} +21 -25
  82. package/lib/uprn/existence.ts +84 -0
  83. package/lib/uprn/index.ts +9 -0
  84. package/lib/uprn/lookup.ts +206 -0
  85. package/lib/uprn/schema.ts +124 -0
  86. package/lib/weights-overlay-linker.ts +878 -0
  87. package/out/address/index.d.ts +9 -0
  88. package/out/address/index.d.ts.map +1 -0
  89. package/out/address/index.js +9 -0
  90. package/out/address/index.js.map +1 -0
  91. package/out/{address-point-interpolation.d.ts → address/point-interpolation.d.ts} +11 -10
  92. package/out/address/point-interpolation.d.ts.map +1 -0
  93. package/out/{address-point-interpolation.js → address/point-interpolation.js} +29 -23
  94. package/out/address/point-interpolation.js.map +1 -0
  95. package/out/{address-point-schema.d.ts → address/point-schema.d.ts} +30 -10
  96. package/out/address/point-schema.d.ts.map +1 -0
  97. package/out/{address-point-schema.js → address/point-schema.js} +7 -3
  98. package/out/address/point-schema.js.map +1 -0
  99. package/out/{address-point.d.ts → address/point.d.ts} +16 -8
  100. package/out/address/point.d.ts.map +1 -0
  101. package/out/address/point.js +191 -0
  102. package/out/address/point.js.map +1 -0
  103. package/out/{ancestry-backfill.d.ts → ancestry/backfill.d.ts} +7 -5
  104. package/out/ancestry/backfill.d.ts.map +1 -0
  105. package/out/{ancestry-backfill.js → ancestry/backfill.js} +12 -16
  106. package/out/ancestry/backfill.js.map +1 -0
  107. package/out/{ancestry.d.ts → ancestry/index.d.ts} +6 -5
  108. package/out/ancestry/index.d.ts.map +1 -0
  109. package/out/{ancestry.js → ancestry/index.js} +7 -7
  110. package/out/ancestry/index.js.map +1 -0
  111. package/out/build-candidate.d.ts +88 -7
  112. package/out/build-candidate.d.ts.map +1 -1
  113. package/out/build-candidate.js +145 -149
  114. package/out/build-candidate.js.map +1 -1
  115. package/out/build-slim.d.ts +5 -5
  116. package/out/build-slim.d.ts.map +1 -1
  117. package/out/build-slim.js +127 -142
  118. package/out/build-slim.js.map +1 -1
  119. package/out/candidate/alias-bags.d.ts +19 -0
  120. package/out/candidate/alias-bags.d.ts.map +1 -0
  121. package/out/candidate/alias-bags.js +39 -0
  122. package/out/candidate/alias-bags.js.map +1 -0
  123. package/out/candidate/ancestors-sidecar.d.ts +32 -0
  124. package/out/candidate/ancestors-sidecar.d.ts.map +1 -0
  125. package/out/candidate/ancestors-sidecar.js +140 -0
  126. package/out/candidate/ancestors-sidecar.js.map +1 -0
  127. package/out/candidate/country-display-names.d.ts +35 -0
  128. package/out/candidate/country-display-names.d.ts.map +1 -0
  129. package/out/candidate/country-display-names.js +59 -0
  130. package/out/candidate/country-display-names.js.map +1 -0
  131. package/out/candidate/extract-fold.d.ts +32 -0
  132. package/out/candidate/extract-fold.d.ts.map +1 -0
  133. package/out/candidate/extract-fold.js +104 -0
  134. package/out/candidate/extract-fold.js.map +1 -0
  135. package/out/candidate/name-roles.d.ts +57 -0
  136. package/out/candidate/name-roles.d.ts.map +1 -0
  137. package/out/candidate/name-roles.js +166 -0
  138. package/out/candidate/name-roles.js.map +1 -0
  139. package/out/candidate/own-name.d.ts +50 -0
  140. package/out/candidate/own-name.d.ts.map +1 -0
  141. package/out/candidate/own-name.js +132 -0
  142. package/out/candidate/own-name.js.map +1 -0
  143. package/out/candidate/place-attrs.d.ts +43 -0
  144. package/out/candidate/place-attrs.d.ts.map +1 -0
  145. package/out/candidate/place-attrs.js +15 -0
  146. package/out/candidate/place-attrs.js.map +1 -0
  147. package/out/candidate-ancestors-schema.d.ts +150 -0
  148. package/out/candidate-ancestors-schema.d.ts.map +1 -0
  149. package/out/candidate-ancestors-schema.js +123 -0
  150. package/out/candidate-ancestors-schema.js.map +1 -0
  151. package/out/candidate-fts.d.ts +7 -5
  152. package/out/candidate-fts.d.ts.map +1 -1
  153. package/out/candidate-fts.js +5 -3
  154. package/out/candidate-fts.js.map +1 -1
  155. package/out/candidate-importance.d.ts +16 -16
  156. package/out/candidate-importance.d.ts.map +1 -1
  157. package/out/candidate-importance.js +47 -52
  158. package/out/candidate-importance.js.map +1 -1
  159. package/out/candidate-lookup.d.ts +31 -52
  160. package/out/candidate-lookup.d.ts.map +1 -1
  161. package/out/candidate-lookup.js +380 -172
  162. package/out/candidate-lookup.js.map +1 -1
  163. package/out/candidate-schema.d.ts +31 -7
  164. package/out/candidate-schema.d.ts.map +1 -1
  165. package/out/candidate-schema.js +3 -0
  166. package/out/candidate-schema.js.map +1 -1
  167. package/out/candidate-scoring.d.ts +34 -0
  168. package/out/candidate-scoring.d.ts.map +1 -0
  169. package/out/candidate-scoring.js +196 -0
  170. package/out/candidate-scoring.js.map +1 -0
  171. package/out/capital-schema.d.ts +51 -0
  172. package/out/capital-schema.d.ts.map +1 -0
  173. package/out/capital-schema.js +63 -0
  174. package/out/capital-schema.js.map +1 -0
  175. package/out/capitals.d.ts +69 -0
  176. package/out/capitals.d.ts.map +1 -0
  177. package/out/capitals.js +98 -0
  178. package/out/capitals.js.map +1 -0
  179. package/out/coincident-roles.d.ts +12 -4
  180. package/out/coincident-roles.d.ts.map +1 -1
  181. package/out/coincident-roles.js +43 -11
  182. package/out/coincident-roles.js.map +1 -1
  183. package/out/{convention.d.ts → convention/index.d.ts} +5 -5
  184. package/out/convention/index.d.ts.map +1 -0
  185. package/out/{convention.js → convention/index.js} +4 -4
  186. package/out/convention/index.js.map +1 -0
  187. package/out/convention/schema.d.ts +51 -0
  188. package/out/convention/schema.d.ts.map +1 -0
  189. package/out/convention/schema.js +34 -0
  190. package/out/convention/schema.js.map +1 -0
  191. package/out/coverage-manifest-schema.d.ts +8 -8
  192. package/out/coverage-manifest-schema.d.ts.map +1 -1
  193. package/out/coverage-manifest-schema.js +6 -10
  194. package/out/coverage-manifest-schema.js.map +1 -1
  195. package/out/currency-backfill.d.ts +90 -0
  196. package/out/currency-backfill.d.ts.map +1 -0
  197. package/out/currency-backfill.js +196 -0
  198. package/out/currency-backfill.js.map +1 -0
  199. package/out/env.d.ts +43 -0
  200. package/out/env.d.ts.map +1 -0
  201. package/out/env.js +48 -0
  202. package/out/env.js.map +1 -0
  203. package/out/exact-match.d.ts +25 -0
  204. package/out/exact-match.d.ts.map +1 -0
  205. package/out/exact-match.js +88 -0
  206. package/out/exact-match.js.map +1 -0
  207. package/out/extracts.d.ts +114 -0
  208. package/out/extracts.d.ts.map +1 -0
  209. package/out/{sharding.js → extracts.js} +38 -38
  210. package/out/extracts.js.map +1 -0
  211. package/out/{fst-autocomplete.d.ts → fst/autocomplete.d.ts} +13 -13
  212. package/out/fst/autocomplete.d.ts.map +1 -0
  213. package/out/fst/autocomplete.js +113 -0
  214. package/out/fst/autocomplete.js.map +1 -0
  215. package/out/{fst-builder.d.ts → fst/builder.d.ts} +5 -5
  216. package/out/fst/builder.d.ts.map +1 -0
  217. package/out/{fst-builder.js → fst/builder.js} +24 -24
  218. package/out/fst/builder.js.map +1 -0
  219. package/out/{fst-deserialize-web.d.ts → fst/deserialize-web.d.ts} +3 -3
  220. package/out/fst/deserialize-web.d.ts.map +1 -0
  221. package/out/{fst-deserialize-web.js → fst/deserialize-web.js} +10 -74
  222. package/out/fst/deserialize-web.js.map +1 -0
  223. package/out/fst/format.d.ts +80 -0
  224. package/out/fst/format.d.ts.map +1 -0
  225. package/out/fst/format.js +91 -0
  226. package/out/fst/format.js.map +1 -0
  227. package/out/{fst-freshness.d.ts → fst/freshness.d.ts} +11 -14
  228. package/out/fst/freshness.d.ts.map +1 -0
  229. package/out/{fst-freshness.js → fst/freshness.js} +42 -74
  230. package/out/fst/freshness.js.map +1 -0
  231. package/out/fst/index.d.ts +14 -0
  232. package/out/fst/index.d.ts.map +1 -0
  233. package/out/fst/index.js +14 -0
  234. package/out/fst/index.js.map +1 -0
  235. package/out/{fst-matcher.d.ts → fst/matcher.d.ts} +2 -2
  236. package/out/fst/matcher.d.ts.map +1 -0
  237. package/out/{fst-matcher.js → fst/matcher.js} +1 -1
  238. package/out/fst/matcher.js.map +1 -0
  239. package/out/{fst-serialize.d.ts → fst/serialize.d.ts} +5 -10
  240. package/out/fst/serialize.d.ts.map +1 -0
  241. package/out/{fst-serialize.js → fst/serialize.js} +18 -98
  242. package/out/fst/serialize.js.map +1 -0
  243. package/out/{fst-types.d.ts → fst/types.d.ts} +4 -3
  244. package/out/fst/types.d.ts.map +1 -0
  245. package/out/{fst-types.js → fst/types.js} +1 -1
  246. package/out/fst/types.js.map +1 -0
  247. package/out/{fts.d.ts → fts/index.d.ts} +20 -13
  248. package/out/fts/index.d.ts.map +1 -0
  249. package/out/{fts.js → fts/index.js} +20 -15
  250. package/out/fts/index.js.map +1 -0
  251. package/out/{fts-query.d.ts → fts/query.d.ts} +2 -2
  252. package/out/fts/query.d.ts.map +1 -0
  253. package/out/{fts-query.js → fts/query.js} +2 -2
  254. package/out/fts/query.js.map +1 -0
  255. package/out/{geonames-aliases.d.ts → geonames/aliases.d.ts} +8 -6
  256. package/out/geonames/aliases.d.ts.map +1 -0
  257. package/out/{geonames-aliases.js → geonames/aliases.js} +7 -7
  258. package/out/geonames/aliases.js.map +1 -0
  259. package/out/geonames/index.d.ts +8 -0
  260. package/out/geonames/index.d.ts.map +1 -0
  261. package/out/geonames/index.js +8 -0
  262. package/out/geonames/index.js.map +1 -0
  263. package/out/{geonames-postal.d.ts → geonames/postal.d.ts} +12 -10
  264. package/out/geonames/postal.d.ts.map +1 -0
  265. package/out/{geonames-postal.js → geonames/postal.js} +11 -11
  266. package/out/geonames/postal.js.map +1 -0
  267. package/out/index.d.ts +32 -31
  268. package/out/index.d.ts.map +1 -1
  269. package/out/index.js +24 -24
  270. package/out/index.js.map +1 -1
  271. package/out/interpolation.d.ts +18 -9
  272. package/out/interpolation.d.ts.map +1 -1
  273. package/out/interpolation.js +108 -36
  274. package/out/interpolation.js.map +1 -1
  275. package/out/lookup.d.ts +25 -25
  276. package/out/lookup.d.ts.map +1 -1
  277. package/out/lookup.js +174 -558
  278. package/out/lookup.js.map +1 -1
  279. package/out/name-score.d.ts +0 -10
  280. package/out/name-score.d.ts.map +1 -1
  281. package/out/name-score.js +6 -4
  282. package/out/name-score.js.map +1 -1
  283. package/out/nsul/index.d.ts +8 -0
  284. package/out/nsul/index.d.ts.map +1 -0
  285. package/out/nsul/index.js +8 -0
  286. package/out/nsul/index.js.map +1 -0
  287. package/out/nsul/lookup.d.ts +83 -0
  288. package/out/nsul/lookup.d.ts.map +1 -0
  289. package/out/nsul/lookup.js +80 -0
  290. package/out/nsul/lookup.js.map +1 -0
  291. package/out/nsul/schema.d.ts +100 -0
  292. package/out/nsul/schema.d.ts.map +1 -0
  293. package/out/nsul/schema.js +78 -0
  294. package/out/nsul/schema.js.map +1 -0
  295. package/out/place-importance-schema.d.ts +47 -10
  296. package/out/place-importance-schema.d.ts.map +1 -1
  297. package/out/place-importance-schema.js +56 -10
  298. package/out/place-importance-schema.js.map +1 -1
  299. package/out/poi/index.d.ts +8 -0
  300. package/out/poi/index.d.ts.map +1 -0
  301. package/out/poi/index.js +8 -0
  302. package/out/poi/index.js.map +1 -0
  303. package/out/{poi-lookup.d.ts → poi/lookup.d.ts} +8 -10
  304. package/out/poi/lookup.d.ts.map +1 -0
  305. package/out/{poi-lookup.js → poi/lookup.js} +24 -29
  306. package/out/poi/lookup.js.map +1 -0
  307. package/out/{poi-schema.d.ts → poi/schema.d.ts} +10 -6
  308. package/out/poi/schema.d.ts.map +1 -0
  309. package/out/{poi-schema.js → poi/schema.js} +1 -1
  310. package/out/poi/schema.js.map +1 -0
  311. package/out/polygon-schema.d.ts +37 -0
  312. package/out/polygon-schema.d.ts.map +1 -0
  313. package/out/polygon-schema.js +23 -0
  314. package/out/polygon-schema.js.map +1 -0
  315. package/out/{postal-city-alias-lookup.d.ts → postal/city-alias-lookup.d.ts} +7 -6
  316. package/out/postal/city-alias-lookup.d.ts.map +1 -0
  317. package/out/{postal-city-alias-lookup.js → postal/city-alias-lookup.js} +12 -16
  318. package/out/postal/city-alias-lookup.js.map +1 -0
  319. package/out/{postal-city-alias-schema.d.ts → postal/city-alias-schema.d.ts} +1 -1
  320. package/out/{postal-city-alias-schema.d.ts.map → postal/city-alias-schema.d.ts.map} +1 -1
  321. package/out/{postal-city-alias-schema.js → postal/city-alias-schema.js} +1 -1
  322. package/out/{postal-city-alias-schema.js.map → postal/city-alias-schema.js.map} +1 -1
  323. package/out/{postal-city-candidate-schema.d.ts → postal/city-candidate-schema.d.ts} +4 -3
  324. package/out/postal/city-candidate-schema.d.ts.map +1 -0
  325. package/out/{postal-city-candidate-schema.js → postal/city-candidate-schema.js} +2 -2
  326. package/out/{postal-city-candidate-schema.js.map → postal/city-candidate-schema.js.map} +1 -1
  327. package/out/postal/index.d.ts +9 -0
  328. package/out/postal/index.d.ts.map +1 -0
  329. package/out/postal/index.js +9 -0
  330. package/out/postal/index.js.map +1 -0
  331. package/out/postcode-point-lookup.d.ts +10 -10
  332. package/out/postcode-point-lookup.d.ts.map +1 -1
  333. package/out/postcode-point-lookup.js +13 -13
  334. package/out/postcode-point-lookup.js.map +1 -1
  335. package/out/primary-preference.d.ts +133 -0
  336. package/out/primary-preference.d.ts.map +1 -0
  337. package/out/primary-preference.js +146 -0
  338. package/out/primary-preference.js.map +1 -0
  339. package/out/proximity-rerank.d.ts +77 -0
  340. package/out/proximity-rerank.d.ts.map +1 -0
  341. package/out/proximity-rerank.js +86 -0
  342. package/out/proximity-rerank.js.map +1 -0
  343. package/out/ranking-weights.d.ts +15 -3
  344. package/out/ranking-weights.d.ts.map +1 -1
  345. package/out/ranking-weights.js +21 -3
  346. package/out/ranking-weights.js.map +1 -1
  347. package/out/region-keys.d.ts +47 -0
  348. package/out/region-keys.d.ts.map +1 -0
  349. package/out/region-keys.js +121 -0
  350. package/out/region-keys.js.map +1 -0
  351. package/out/reverse.d.ts +6 -6
  352. package/out/reverse.d.ts.map +1 -1
  353. package/out/reverse.js +23 -35
  354. package/out/reverse.js.map +1 -1
  355. package/out/schema.d.ts +10 -1
  356. package/out/schema.d.ts.map +1 -1
  357. package/out/schema.js.map +1 -1
  358. package/out/search-fetch.d.ts +59 -0
  359. package/out/search-fetch.d.ts.map +1 -0
  360. package/out/search-fetch.js +184 -0
  361. package/out/search-fetch.js.map +1 -0
  362. package/out/sqlite-convention-source.d.ts +7 -7
  363. package/out/sqlite-convention-source.d.ts.map +1 -1
  364. package/out/sqlite-convention-source.js +5 -5
  365. package/out/sqlite-convention-source.js.map +1 -1
  366. package/out/sqlite-utils.d.ts +24 -6
  367. package/out/sqlite-utils.d.ts.map +1 -1
  368. package/out/sqlite-utils.js +24 -7
  369. package/out/sqlite-utils.js.map +1 -1
  370. package/out/{street-centroid-schema.d.ts → street/centroid-schema.d.ts} +12 -7
  371. package/out/street/centroid-schema.d.ts.map +1 -0
  372. package/out/{street-centroid-schema.js → street/centroid-schema.js} +5 -5
  373. package/out/{street-centroid-schema.js.map → street/centroid-schema.js.map} +1 -1
  374. package/out/{street-centroid.d.ts → street/centroid.d.ts} +6 -6
  375. package/out/street/centroid.d.ts.map +1 -0
  376. package/out/{street-centroid.js → street/centroid.js} +18 -24
  377. package/out/street/centroid.js.map +1 -0
  378. package/out/street/index.d.ts +13 -0
  379. package/out/street/index.d.ts.map +1 -0
  380. package/out/street/index.js +13 -0
  381. package/out/street/index.js.map +1 -0
  382. package/out/{street-morphology-fst-builder.d.ts → street/morphology-fst-builder.d.ts} +4 -4
  383. package/out/street/morphology-fst-builder.d.ts.map +1 -0
  384. package/out/{street-morphology-fst-builder.js → street/morphology-fst-builder.js} +18 -13
  385. package/out/street/morphology-fst-builder.js.map +1 -0
  386. package/out/{street-morphology-fst-loader.d.ts → street/morphology-fst-loader.d.ts} +5 -5
  387. package/out/street/morphology-fst-loader.d.ts.map +1 -0
  388. package/out/{street-morphology-fst-loader.js → street/morphology-fst-loader.js} +11 -10
  389. package/out/street/morphology-fst-loader.js.map +1 -0
  390. package/out/{street-name-lookup.d.ts → street/name-lookup.d.ts} +4 -7
  391. package/out/street/name-lookup.d.ts.map +1 -0
  392. package/out/{street-name-lookup.js → street/name-lookup.js} +9 -23
  393. package/out/street/name-lookup.js.map +1 -0
  394. package/out/street/normalize.d.ts +179 -0
  395. package/out/street/normalize.d.ts.map +1 -0
  396. package/out/street/normalize.js +457 -0
  397. package/out/street/normalize.js.map +1 -0
  398. package/out/{street-segment-schema.d.ts → street/segment-schema.d.ts} +13 -9
  399. package/out/street/segment-schema.d.ts.map +1 -0
  400. package/out/{street-segment-schema.js → street/segment-schema.js} +4 -4
  401. package/out/{street-segment-schema.js.map → street/segment-schema.js.map} +1 -1
  402. package/out/types.d.ts +49 -9
  403. package/out/types.d.ts.map +1 -1
  404. package/out/types.js.map +1 -1
  405. package/out/unified-schema.d.ts +6 -5
  406. package/out/unified-schema.d.ts.map +1 -1
  407. package/out/unified-schema.js +16 -19
  408. package/out/unified-schema.js.map +1 -1
  409. package/out/uprn/existence.d.ts +53 -0
  410. package/out/uprn/existence.d.ts.map +1 -0
  411. package/out/uprn/existence.js +61 -0
  412. package/out/uprn/existence.js.map +1 -0
  413. package/out/uprn/index.d.ts +9 -0
  414. package/out/uprn/index.d.ts.map +1 -0
  415. package/out/uprn/index.js +9 -0
  416. package/out/uprn/index.js.map +1 -0
  417. package/out/uprn/lookup.d.ts +85 -0
  418. package/out/uprn/lookup.d.ts.map +1 -0
  419. package/out/uprn/lookup.js +149 -0
  420. package/out/uprn/lookup.js.map +1 -0
  421. package/out/uprn/schema.d.ts +93 -0
  422. package/out/uprn/schema.d.ts.map +1 -0
  423. package/out/uprn/schema.js +78 -0
  424. package/out/uprn/schema.js.map +1 -0
  425. package/out/weights-overlay-linker.d.ts +299 -0
  426. package/out/weights-overlay-linker.d.ts.map +1 -0
  427. package/out/weights-overlay-linker.js +511 -0
  428. package/out/weights-overlay-linker.js.map +1 -0
  429. package/package.json +622 -154
  430. package/address-point.ts +0 -125
  431. package/candidate-lookup.ts +0 -720
  432. package/fst-autocomplete.ts +0 -204
  433. package/geo.ts +0 -121
  434. package/lookup.ts +0 -1354
  435. package/out/address-point-interpolation.d.ts.map +0 -1
  436. package/out/address-point-interpolation.js.map +0 -1
  437. package/out/address-point-schema.d.ts.map +0 -1
  438. package/out/address-point-schema.js.map +0 -1
  439. package/out/address-point.d.ts.map +0 -1
  440. package/out/address-point.js +0 -84
  441. package/out/address-point.js.map +0 -1
  442. package/out/ancestry-backfill.d.ts.map +0 -1
  443. package/out/ancestry-backfill.js.map +0 -1
  444. package/out/ancestry.d.ts.map +0 -1
  445. package/out/ancestry.js.map +0 -1
  446. package/out/convention.d.ts.map +0 -1
  447. package/out/convention.js.map +0 -1
  448. package/out/fst-autocomplete.d.ts.map +0 -1
  449. package/out/fst-autocomplete.js +0 -130
  450. package/out/fst-autocomplete.js.map +0 -1
  451. package/out/fst-builder.d.ts.map +0 -1
  452. package/out/fst-builder.js.map +0 -1
  453. package/out/fst-deserialize-web.d.ts.map +0 -1
  454. package/out/fst-deserialize-web.js.map +0 -1
  455. package/out/fst-freshness.d.ts.map +0 -1
  456. package/out/fst-freshness.js.map +0 -1
  457. package/out/fst-matcher.d.ts.map +0 -1
  458. package/out/fst-matcher.js.map +0 -1
  459. package/out/fst-serialize.d.ts.map +0 -1
  460. package/out/fst-serialize.js.map +0 -1
  461. package/out/fst-types.d.ts.map +0 -1
  462. package/out/fst-types.js.map +0 -1
  463. package/out/fts-query.d.ts.map +0 -1
  464. package/out/fts-query.js.map +0 -1
  465. package/out/fts.d.ts.map +0 -1
  466. package/out/fts.js.map +0 -1
  467. package/out/geo.d.ts +0 -74
  468. package/out/geo.d.ts.map +0 -1
  469. package/out/geo.js +0 -71
  470. package/out/geo.js.map +0 -1
  471. package/out/geonames-aliases.d.ts.map +0 -1
  472. package/out/geonames-aliases.js.map +0 -1
  473. package/out/geonames-postal.d.ts.map +0 -1
  474. package/out/geonames-postal.js.map +0 -1
  475. package/out/poi-lookup.d.ts.map +0 -1
  476. package/out/poi-lookup.js.map +0 -1
  477. package/out/poi-schema.d.ts.map +0 -1
  478. package/out/poi-schema.js.map +0 -1
  479. package/out/postal-city-alias-lookup.d.ts.map +0 -1
  480. package/out/postal-city-alias-lookup.js.map +0 -1
  481. package/out/postal-city-candidate-schema.d.ts.map +0 -1
  482. package/out/sharding.d.ts +0 -114
  483. package/out/sharding.d.ts.map +0 -1
  484. package/out/sharding.js.map +0 -1
  485. package/out/street-centroid-schema.d.ts.map +0 -1
  486. package/out/street-centroid.d.ts.map +0 -1
  487. package/out/street-centroid.js.map +0 -1
  488. package/out/street-morphology-fst-builder.d.ts.map +0 -1
  489. package/out/street-morphology-fst-builder.js.map +0 -1
  490. package/out/street-morphology-fst-loader.d.ts.map +0 -1
  491. package/out/street-morphology-fst-loader.js.map +0 -1
  492. package/out/street-name-lookup.d.ts.map +0 -1
  493. package/out/street-name-lookup.js.map +0 -1
  494. package/out/street-normalize.d.ts +0 -95
  495. package/out/street-normalize.d.ts.map +0 -1
  496. package/out/street-normalize.js +0 -272
  497. package/out/street-normalize.js.map +0 -1
  498. package/out/street-segment-schema.d.ts.map +0 -1
  499. package/sqlite-utils.ts +0 -46
  500. package/street-normalize.ts +0 -318
  501. /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"}
@@ -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 by the SAME `trigramJaccard` the admin/FTS backend uses, so a typo
13
- * resolves identically on either.
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 { DatabaseSync } from "node:sqlite";
27
+ import type { DatabaseClient } from "@mailwoman/sqlite/client";
26
28
  /**
27
- * Name of the FTS5 trigram virtual table this module owns. The reader gates its fuzzy fallback on it.
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: DatabaseSync): void;
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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;GAEG;AACH,eAAO,MAAM,mBAAmB,kBAAkB,CAAA;AAElD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAOzD"}
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"}
@@ -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 by the SAME `trigramJaccard` the admin/FTS backend uses, so a typo
13
- * resolves identically on either.
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 gates its fuzzy fallback on it.
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
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-fts.js","sourceRoot":"","sources":["../candidate-fts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAA;AAElD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAgB;IAClD,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"}
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"}