@mailwoman/resolver-wof-sqlite 11.0.0 → 11.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.
Files changed (557) hide show
  1. package/README.md +6 -6
  2. package/lib/address/duplicate.ts +133 -0
  3. package/lib/address/keys/attribution.ts +119 -0
  4. package/lib/address/keys/build.ts +768 -0
  5. package/lib/address/keys/layout.ts +166 -0
  6. package/lib/address/keys/local-runner.ts +18 -0
  7. package/lib/address/keys/lookup.ts +205 -0
  8. package/lib/address/keys/open.ts +33 -0
  9. package/lib/address/keys/point-lookup.ts +130 -0
  10. package/lib/address/keys/postcode.ts +27 -0
  11. package/lib/address/keys/schema.ts +264 -0
  12. package/lib/address/number-forms.ts +61 -0
  13. package/lib/address/point/interpolation.ts +28 -23
  14. package/lib/address/point/schema.ts +2 -5
  15. package/lib/address/point/spine-schema.ts +4 -4
  16. package/lib/address/point.ts +12 -79
  17. package/lib/address/record.ts +155 -0
  18. package/lib/address/stack.ts +20 -0
  19. package/lib/address/subdivision-bounds.ts +81 -0
  20. package/lib/address.ts +2 -5
  21. package/lib/ancestry/backfill.ts +18 -47
  22. package/lib/ancestry.ts +10 -10
  23. package/lib/build/candidate.ts +44 -48
  24. package/lib/build/population-corrections.ts +4 -4
  25. package/lib/build/slim.ts +3 -6
  26. package/lib/candidate/alias-bags.ts +58 -18
  27. package/lib/candidate/ancestors/schema.ts +63 -43
  28. package/lib/candidate/ancestors/sidecar.ts +3 -3
  29. package/lib/candidate/bare-admin-names.ts +3 -3
  30. package/lib/candidate/country-display-names.ts +2 -5
  31. package/lib/candidate/extract-fold.ts +2 -5
  32. package/lib/candidate/fts.ts +5 -5
  33. package/lib/candidate/importance.ts +30 -24
  34. package/lib/candidate/key-fold.ts +132 -0
  35. package/lib/candidate/lookup.ts +25 -18
  36. package/lib/candidate/name-roles.ts +4 -4
  37. package/lib/candidate/nickname-namesakes.ts +140 -0
  38. package/lib/candidate/own-name.ts +12 -10
  39. package/lib/candidate/place-attrs.ts +4 -4
  40. package/lib/candidate/schema.ts +2 -5
  41. package/lib/candidate/scoring.ts +3 -6
  42. package/lib/capital-schema.ts +11 -10
  43. package/lib/capitals.ts +15 -12
  44. package/lib/convention/schema.ts +7 -7
  45. package/lib/convention.ts +3 -3
  46. package/lib/coverage-manifest-schema.ts +4 -4
  47. package/lib/env.ts +7 -6
  48. package/lib/exact-match.ts +6 -7
  49. package/lib/extracts.ts +11 -9
  50. package/lib/fst/autocomplete.ts +19 -15
  51. package/lib/fst/binary-matcher.ts +36 -50
  52. package/lib/fst/builder.ts +32 -11
  53. package/lib/fst/deserialize-web.ts +9 -8
  54. package/lib/fst/format.ts +153 -14
  55. package/lib/fst/freshness.ts +3 -4
  56. package/lib/fst/matcher.ts +6 -6
  57. package/lib/fst/serialize.ts +94 -69
  58. package/lib/fst/types.ts +4 -4
  59. package/lib/fst.ts +2 -5
  60. package/lib/fts/query.ts +3 -4
  61. package/lib/fts.ts +2 -5
  62. package/lib/geonames/aliases.ts +189 -46
  63. package/lib/geonames/postal.ts +17 -15
  64. package/lib/geonames.ts +2 -5
  65. package/lib/importance-source.ts +210 -0
  66. package/lib/index.ts +4 -5
  67. package/lib/interpolation.ts +7 -6
  68. package/lib/landmark/rows.ts +5 -5
  69. package/lib/landmark.ts +6 -6
  70. package/lib/lookup.ts +8 -8
  71. package/lib/name-score.ts +7 -6
  72. package/lib/nsul/lookup.ts +19 -15
  73. package/lib/nsul/schema.ts +4 -5
  74. package/lib/nsul.ts +2 -5
  75. package/lib/paths.ts +7 -7
  76. package/lib/place-importance-schema.ts +5 -8
  77. package/lib/poi/lookup.ts +11 -10
  78. package/lib/poi/schema.ts +16 -10
  79. package/lib/poi.ts +2 -5
  80. package/lib/polygon-schema.ts +10 -9
  81. package/lib/postal/city/alias/lookup.ts +14 -13
  82. package/lib/postal/city/alias/schema.ts +12 -12
  83. package/lib/postal/city/candidate-schema.ts +15 -12
  84. package/lib/postal.ts +2 -5
  85. package/lib/postcode-point-lookup.ts +2 -5
  86. package/lib/primary-preference.ts +42 -7
  87. package/lib/proximity-rerank.ts +23 -19
  88. package/lib/ranking-weights.ts +8 -7
  89. package/lib/region-keys.ts +15 -14
  90. package/lib/reverse.ts +16 -17
  91. package/lib/schema.ts +20 -6
  92. package/lib/search-fetch.ts +15 -11
  93. package/lib/sqlite/convention-source.ts +2 -5
  94. package/lib/sqlite/utils.ts +4 -4
  95. package/lib/street/centroid/schema.ts +6 -6
  96. package/lib/street/centroid.ts +3 -3
  97. package/lib/street/locale.ts +64 -0
  98. package/lib/street/morphology/fst/builder.ts +21 -19
  99. package/lib/street/morphology/fst/loader.ts +15 -13
  100. package/lib/street/name-lookup.ts +15 -14
  101. package/lib/street/normalize.ts +62 -17
  102. package/lib/street/segment-schema.ts +16 -14
  103. package/lib/street/table.ts +276 -0
  104. package/lib/street.ts +3 -5
  105. package/lib/types.ts +3 -6
  106. package/lib/unified-schema.ts +31 -9
  107. package/lib/uprn/existence.ts +10 -10
  108. package/lib/uprn/lookup.ts +7 -8
  109. package/lib/uprn/schema.ts +5 -5
  110. package/lib/uprn.ts +2 -5
  111. package/lib/weights-overlay-linker.ts +5 -8
  112. package/out/address/duplicate.d.ts +74 -0
  113. package/out/address/duplicate.d.ts.map +1 -0
  114. package/out/address/duplicate.js +79 -0
  115. package/out/address/duplicate.js.map +1 -0
  116. package/out/address/keys/attribution.d.ts +56 -0
  117. package/out/address/keys/attribution.d.ts.map +1 -0
  118. package/out/address/keys/attribution.js +64 -0
  119. package/out/address/keys/attribution.js.map +1 -0
  120. package/out/address/keys/build.d.ts +154 -0
  121. package/out/address/keys/build.d.ts.map +1 -0
  122. package/out/address/keys/build.js +423 -0
  123. package/out/address/keys/build.js.map +1 -0
  124. package/out/address/keys/layout.d.ts +92 -0
  125. package/out/address/keys/layout.d.ts.map +1 -0
  126. package/out/address/keys/layout.js +87 -0
  127. package/out/address/keys/layout.js.map +1 -0
  128. package/out/address/keys/local-runner.d.ts +9 -0
  129. package/out/address/keys/local-runner.d.ts.map +1 -0
  130. package/out/address/keys/local-runner.js +13 -0
  131. package/out/address/keys/local-runner.js.map +1 -0
  132. package/out/address/keys/lookup.d.ts +80 -0
  133. package/out/address/keys/lookup.d.ts.map +1 -0
  134. package/out/address/keys/lookup.js +104 -0
  135. package/out/address/keys/lookup.js.map +1 -0
  136. package/out/address/keys/open.d.ts +10 -0
  137. package/out/address/keys/open.d.ts.map +1 -0
  138. package/out/address/keys/open.js +28 -0
  139. package/out/address/keys/open.js.map +1 -0
  140. package/out/address/keys/point-lookup.d.ts +25 -0
  141. package/out/address/keys/point-lookup.d.ts.map +1 -0
  142. package/out/address/keys/point-lookup.js +100 -0
  143. package/out/address/keys/point-lookup.js.map +1 -0
  144. package/out/address/keys/postcode.d.ts +9 -0
  145. package/out/address/keys/postcode.d.ts.map +1 -0
  146. package/out/address/keys/postcode.js +25 -0
  147. package/out/address/keys/postcode.js.map +1 -0
  148. package/out/address/keys/schema.d.ts +156 -0
  149. package/out/address/keys/schema.d.ts.map +1 -0
  150. package/out/address/keys/schema.js +119 -0
  151. package/out/address/keys/schema.js.map +1 -0
  152. package/out/address/number-forms.d.ts +19 -0
  153. package/out/address/number-forms.d.ts.map +1 -0
  154. package/out/address/number-forms.js +50 -0
  155. package/out/address/number-forms.js.map +1 -0
  156. package/out/address/point/interpolation.d.ts +24 -22
  157. package/out/address/point/interpolation.d.ts.map +1 -1
  158. package/out/address/point/interpolation.js +3 -31
  159. package/out/address/point/interpolation.js.map +1 -1
  160. package/out/address/point/schema.d.ts +0 -5
  161. package/out/address/point/schema.d.ts.map +1 -1
  162. package/out/address/point/schema.js +2 -5
  163. package/out/address/point/schema.js.map +1 -1
  164. package/out/address/point/spine-schema.d.ts +1 -4
  165. package/out/address/point/spine-schema.d.ts.map +1 -1
  166. package/out/address/point/spine-schema.js +3 -4
  167. package/out/address/point/spine-schema.js.map +1 -1
  168. package/out/address/point.d.ts +0 -3
  169. package/out/address/point.d.ts.map +1 -1
  170. package/out/address/point.js +12 -71
  171. package/out/address/point.js.map +1 -1
  172. package/out/address/record.d.ts +125 -0
  173. package/out/address/record.d.ts.map +1 -0
  174. package/out/address/record.js +49 -0
  175. package/out/address/record.js.map +1 -0
  176. package/out/address/stack.d.ts +14 -0
  177. package/out/address/stack.d.ts.map +1 -0
  178. package/out/address/stack.js +19 -0
  179. package/out/address/stack.js.map +1 -0
  180. package/out/address/subdivision-bounds.d.ts +32 -0
  181. package/out/address/subdivision-bounds.d.ts.map +1 -0
  182. package/out/address/subdivision-bounds.js +48 -0
  183. package/out/address/subdivision-bounds.js.map +1 -0
  184. package/out/address.d.ts +0 -5
  185. package/out/address.d.ts.map +1 -1
  186. package/out/address.js +2 -5
  187. package/out/address.js.map +1 -1
  188. package/out/ancestry/backfill.d.ts +11 -13
  189. package/out/ancestry/backfill.d.ts.map +1 -1
  190. package/out/ancestry/backfill.js +6 -44
  191. package/out/ancestry/backfill.js.map +1 -1
  192. package/out/ancestry.d.ts +0 -14
  193. package/out/ancestry.d.ts.map +1 -1
  194. package/out/ancestry.js +9 -10
  195. package/out/ancestry.js.map +1 -1
  196. package/out/build/candidate.d.ts +20 -22
  197. package/out/build/candidate.d.ts.map +1 -1
  198. package/out/build/candidate.js +16 -28
  199. package/out/build/candidate.js.map +1 -1
  200. package/out/build/population-corrections.d.ts +1 -4
  201. package/out/build/population-corrections.d.ts.map +1 -1
  202. package/out/build/population-corrections.js +2 -19
  203. package/out/build/population-corrections.js.map +1 -1
  204. package/out/build/slim.d.ts +0 -5
  205. package/out/build/slim.d.ts.map +1 -1
  206. package/out/build/slim.js +3 -6
  207. package/out/build/slim.js.map +1 -1
  208. package/out/candidate/alias-bags.d.ts +9 -4
  209. package/out/candidate/alias-bags.d.ts.map +1 -1
  210. package/out/candidate/alias-bags.js +46 -19
  211. package/out/candidate/alias-bags.js.map +1 -1
  212. package/out/candidate/ancestors/schema.d.ts +60 -43
  213. package/out/candidate/ancestors/schema.d.ts.map +1 -1
  214. package/out/candidate/ancestors/schema.js +62 -43
  215. package/out/candidate/ancestors/schema.js.map +1 -1
  216. package/out/candidate/ancestors/sidecar.d.ts +0 -3
  217. package/out/candidate/ancestors/sidecar.d.ts.map +1 -1
  218. package/out/candidate/ancestors/sidecar.js +2 -6
  219. package/out/candidate/ancestors/sidecar.js.map +1 -1
  220. package/out/candidate/bare-admin-names.d.ts +0 -6
  221. package/out/candidate/bare-admin-names.d.ts.map +1 -1
  222. package/out/candidate/bare-admin-names.js +2 -3
  223. package/out/candidate/bare-admin-names.js.map +1 -1
  224. package/out/candidate/country-display-names.d.ts +0 -5
  225. package/out/candidate/country-display-names.d.ts.map +1 -1
  226. package/out/candidate/country-display-names.js +2 -5
  227. package/out/candidate/country-display-names.js.map +1 -1
  228. package/out/candidate/extract-fold.d.ts +0 -5
  229. package/out/candidate/extract-fold.d.ts.map +1 -1
  230. package/out/candidate/extract-fold.js +2 -5
  231. package/out/candidate/extract-fold.js.map +1 -1
  232. package/out/candidate/fts.d.ts +2 -5
  233. package/out/candidate/fts.d.ts.map +1 -1
  234. package/out/candidate/fts.js +2 -7
  235. package/out/candidate/fts.js.map +1 -1
  236. package/out/candidate/importance.d.ts +3 -33
  237. package/out/candidate/importance.d.ts.map +1 -1
  238. package/out/candidate/importance.js +29 -24
  239. package/out/candidate/importance.js.map +1 -1
  240. package/out/candidate/key-fold.d.ts +55 -0
  241. package/out/candidate/key-fold.d.ts.map +1 -0
  242. package/out/candidate/key-fold.js +80 -0
  243. package/out/candidate/key-fold.js.map +1 -0
  244. package/out/candidate/lookup.d.ts +0 -5
  245. package/out/candidate/lookup.d.ts.map +1 -1
  246. package/out/candidate/lookup.js +24 -17
  247. package/out/candidate/lookup.js.map +1 -1
  248. package/out/candidate/name-roles.d.ts +0 -6
  249. package/out/candidate/name-roles.d.ts.map +1 -1
  250. package/out/candidate/name-roles.js +3 -4
  251. package/out/candidate/name-roles.js.map +1 -1
  252. package/out/candidate/nickname-namesakes.d.ts +32 -0
  253. package/out/candidate/nickname-namesakes.d.ts.map +1 -0
  254. package/out/candidate/nickname-namesakes.js +98 -0
  255. package/out/candidate/nickname-namesakes.js.map +1 -0
  256. package/out/candidate/own-name.d.ts +0 -18
  257. package/out/candidate/own-name.d.ts.map +1 -1
  258. package/out/candidate/own-name.js +11 -10
  259. package/out/candidate/own-name.js.map +1 -1
  260. package/out/candidate/place-attrs.d.ts +1 -4
  261. package/out/candidate/place-attrs.d.ts.map +1 -1
  262. package/out/candidate/place-attrs.js +2 -12
  263. package/out/candidate/place-attrs.js.map +1 -1
  264. package/out/candidate/schema.d.ts +0 -5
  265. package/out/candidate/schema.d.ts.map +1 -1
  266. package/out/candidate/schema.js +2 -5
  267. package/out/candidate/schema.js.map +1 -1
  268. package/out/candidate/scoring.d.ts +0 -5
  269. package/out/candidate/scoring.d.ts.map +1 -1
  270. package/out/candidate/scoring.js +3 -6
  271. package/out/candidate/scoring.js.map +1 -1
  272. package/out/capital-schema.d.ts +0 -14
  273. package/out/capital-schema.d.ts.map +1 -1
  274. package/out/capital-schema.js +10 -10
  275. package/out/capital-schema.js.map +1 -1
  276. package/out/capitals.d.ts +0 -16
  277. package/out/capitals.d.ts.map +1 -1
  278. package/out/capitals.js +14 -12
  279. package/out/capitals.js.map +1 -1
  280. package/out/convention/schema.d.ts +4 -7
  281. package/out/convention/schema.d.ts.map +1 -1
  282. package/out/convention/schema.js +2 -10
  283. package/out/convention/schema.js.map +1 -1
  284. package/out/convention.d.ts +0 -3
  285. package/out/convention.d.ts.map +1 -1
  286. package/out/convention.js +2 -8
  287. package/out/convention.js.map +1 -1
  288. package/out/coverage-manifest-schema.d.ts +1 -4
  289. package/out/coverage-manifest-schema.d.ts.map +1 -1
  290. package/out/coverage-manifest-schema.js +2 -3
  291. package/out/coverage-manifest-schema.js.map +1 -1
  292. package/out/env.d.ts +0 -8
  293. package/out/env.d.ts.map +1 -1
  294. package/out/env.js +6 -6
  295. package/out/env.js.map +1 -1
  296. package/out/exact-match.d.ts +2 -6
  297. package/out/exact-match.d.ts.map +1 -1
  298. package/out/exact-match.js +3 -9
  299. package/out/exact-match.js.map +1 -1
  300. package/out/extracts.d.ts +8 -9
  301. package/out/extracts.d.ts.map +1 -1
  302. package/out/extracts.js +9 -8
  303. package/out/extracts.js.map +1 -1
  304. package/out/fst/autocomplete.d.ts +1 -19
  305. package/out/fst/autocomplete.d.ts.map +1 -1
  306. package/out/fst/autocomplete.js +2 -18
  307. package/out/fst/autocomplete.js.map +1 -1
  308. package/out/fst/binary-matcher.d.ts +6 -8
  309. package/out/fst/binary-matcher.d.ts.map +1 -1
  310. package/out/fst/binary-matcher.js +12 -43
  311. package/out/fst/binary-matcher.js.map +1 -1
  312. package/out/fst/builder.d.ts +0 -12
  313. package/out/fst/builder.d.ts.map +1 -1
  314. package/out/fst/builder.js +23 -11
  315. package/out/fst/builder.js.map +1 -1
  316. package/out/fst/deserialize-web.d.ts +1 -12
  317. package/out/fst/deserialize-web.d.ts.map +1 -1
  318. package/out/fst/deserialize-web.js +8 -8
  319. package/out/fst/deserialize-web.js.map +1 -1
  320. package/out/fst/format.d.ts +66 -16
  321. package/out/fst/format.d.ts.map +1 -1
  322. package/out/fst/format.js +100 -16
  323. package/out/fst/format.js.map +1 -1
  324. package/out/fst/freshness.d.ts +0 -7
  325. package/out/fst/freshness.d.ts.map +1 -1
  326. package/out/fst/freshness.js +2 -4
  327. package/out/fst/freshness.js.map +1 -1
  328. package/out/fst/matcher.d.ts +3 -6
  329. package/out/fst/matcher.d.ts.map +1 -1
  330. package/out/fst/matcher.js +2 -9
  331. package/out/fst/matcher.js.map +1 -1
  332. package/out/fst/serialize.d.ts +0 -23
  333. package/out/fst/serialize.d.ts.map +1 -1
  334. package/out/fst/serialize.js +68 -60
  335. package/out/fst/serialize.js.map +1 -1
  336. package/out/fst/types.d.ts +1 -4
  337. package/out/fst/types.d.ts.map +1 -1
  338. package/out/fst/types.js +2 -6
  339. package/out/fst/types.js.map +1 -1
  340. package/out/fst.d.ts +0 -5
  341. package/out/fst.d.ts.map +1 -1
  342. package/out/fst.js +2 -5
  343. package/out/fst.js.map +1 -1
  344. package/out/fts/query.d.ts +0 -4
  345. package/out/fts/query.d.ts.map +1 -1
  346. package/out/fts/query.js +2 -7
  347. package/out/fts/query.js.map +1 -1
  348. package/out/fts.d.ts +0 -5
  349. package/out/fts.d.ts.map +1 -1
  350. package/out/fts.js +2 -5
  351. package/out/fts.js.map +1 -1
  352. package/out/geonames/aliases.d.ts +43 -5
  353. package/out/geonames/aliases.d.ts.map +1 -1
  354. package/out/geonames/aliases.js +108 -44
  355. package/out/geonames/aliases.js.map +1 -1
  356. package/out/geonames/postal.d.ts +1 -25
  357. package/out/geonames/postal.d.ts.map +1 -1
  358. package/out/geonames/postal.js +15 -14
  359. package/out/geonames/postal.js.map +1 -1
  360. package/out/geonames.d.ts +0 -5
  361. package/out/geonames.d.ts.map +1 -1
  362. package/out/geonames.js +2 -5
  363. package/out/geonames.js.map +1 -1
  364. package/out/importance-source.d.ts +90 -0
  365. package/out/importance-source.d.ts.map +1 -0
  366. package/out/importance-source.js +133 -0
  367. package/out/importance-source.js.map +1 -0
  368. package/out/index.d.ts +2 -5
  369. package/out/index.d.ts.map +1 -1
  370. package/out/index.js +4 -5
  371. package/out/index.js.map +1 -1
  372. package/out/interpolation.d.ts +0 -7
  373. package/out/interpolation.d.ts.map +1 -1
  374. package/out/interpolation.js +6 -6
  375. package/out/interpolation.js.map +1 -1
  376. package/out/landmark/rows.d.ts +2 -5
  377. package/out/landmark/rows.d.ts.map +1 -1
  378. package/out/landmark/rows.js +2 -8
  379. package/out/landmark/rows.js.map +1 -1
  380. package/out/landmark.d.ts +3 -6
  381. package/out/landmark.d.ts.map +1 -1
  382. package/out/landmark.js +2 -8
  383. package/out/landmark.js.map +1 -1
  384. package/out/lookup.d.ts +0 -7
  385. package/out/lookup.d.ts.map +1 -1
  386. package/out/lookup.js +7 -8
  387. package/out/lookup.js.map +1 -1
  388. package/out/name-score.d.ts +4 -6
  389. package/out/name-score.d.ts.map +1 -1
  390. package/out/name-score.js +6 -6
  391. package/out/name-score.js.map +1 -1
  392. package/out/nsul/lookup.d.ts +16 -15
  393. package/out/nsul/lookup.d.ts.map +1 -1
  394. package/out/nsul/lookup.js +2 -25
  395. package/out/nsul/lookup.js.map +1 -1
  396. package/out/nsul/schema.d.ts +1 -5
  397. package/out/nsul/schema.d.ts.map +1 -1
  398. package/out/nsul/schema.js +3 -8
  399. package/out/nsul/schema.js.map +1 -1
  400. package/out/nsul.d.ts +0 -5
  401. package/out/nsul.d.ts.map +1 -1
  402. package/out/nsul.js +2 -5
  403. package/out/nsul.js.map +1 -1
  404. package/out/paths.d.ts +1 -13
  405. package/out/paths.d.ts.map +1 -1
  406. package/out/paths.js +6 -7
  407. package/out/paths.js.map +1 -1
  408. package/out/place-importance-schema.d.ts +3 -8
  409. package/out/place-importance-schema.d.ts.map +1 -1
  410. package/out/place-importance-schema.js +3 -6
  411. package/out/place-importance-schema.js.map +1 -1
  412. package/out/poi/lookup.d.ts +0 -13
  413. package/out/poi/lookup.d.ts.map +1 -1
  414. package/out/poi/lookup.js +10 -10
  415. package/out/poi/lookup.js.map +1 -1
  416. package/out/poi/schema.d.ts +13 -10
  417. package/out/poi/schema.d.ts.map +1 -1
  418. package/out/poi/schema.js +2 -13
  419. package/out/poi/schema.js.map +1 -1
  420. package/out/poi.d.ts +0 -5
  421. package/out/poi.d.ts.map +1 -1
  422. package/out/poi.js +2 -5
  423. package/out/poi.js.map +1 -1
  424. package/out/polygon-schema.d.ts +7 -9
  425. package/out/polygon-schema.d.ts.map +1 -1
  426. package/out/polygon-schema.js +2 -12
  427. package/out/polygon-schema.js.map +1 -1
  428. package/out/postal/city/alias/lookup.d.ts +11 -13
  429. package/out/postal/city/alias/lookup.d.ts.map +1 -1
  430. package/out/postal/city/alias/lookup.js +13 -13
  431. package/out/postal/city/alias/lookup.js.map +1 -1
  432. package/out/postal/city/alias/schema.d.ts +9 -12
  433. package/out/postal/city/alias/schema.d.ts.map +1 -1
  434. package/out/postal/city/alias/schema.js +2 -17
  435. package/out/postal/city/alias/schema.js.map +1 -1
  436. package/out/postal/city/candidate-schema.d.ts +12 -12
  437. package/out/postal/city/candidate-schema.d.ts.map +1 -1
  438. package/out/postal/city/candidate-schema.js +14 -12
  439. package/out/postal/city/candidate-schema.js.map +1 -1
  440. package/out/postal.d.ts +0 -5
  441. package/out/postal.d.ts.map +1 -1
  442. package/out/postal.js +2 -5
  443. package/out/postal.js.map +1 -1
  444. package/out/postcode-point-lookup.d.ts +0 -5
  445. package/out/postcode-point-lookup.d.ts.map +1 -1
  446. package/out/postcode-point-lookup.js +2 -5
  447. package/out/postcode-point-lookup.js.map +1 -1
  448. package/out/primary-preference.d.ts +20 -6
  449. package/out/primary-preference.d.ts.map +1 -1
  450. package/out/primary-preference.js +33 -6
  451. package/out/primary-preference.js.map +1 -1
  452. package/out/proximity-rerank.d.ts +2 -26
  453. package/out/proximity-rerank.d.ts.map +1 -1
  454. package/out/proximity-rerank.js +22 -19
  455. package/out/proximity-rerank.js.map +1 -1
  456. package/out/ranking-weights.d.ts +5 -7
  457. package/out/ranking-weights.d.ts.map +1 -1
  458. package/out/ranking-weights.js +2 -9
  459. package/out/ranking-weights.js.map +1 -1
  460. package/out/region-keys.d.ts +0 -15
  461. package/out/region-keys.d.ts.map +1 -1
  462. package/out/region-keys.js +14 -14
  463. package/out/region-keys.js.map +1 -1
  464. package/out/reverse.d.ts +1 -24
  465. package/out/reverse.d.ts.map +1 -1
  466. package/out/reverse.js +14 -16
  467. package/out/reverse.js.map +1 -1
  468. package/out/schema.d.ts +17 -6
  469. package/out/schema.d.ts.map +1 -1
  470. package/out/schema.js +2 -15
  471. package/out/schema.js.map +1 -1
  472. package/out/search-fetch.d.ts +0 -13
  473. package/out/search-fetch.d.ts.map +1 -1
  474. package/out/search-fetch.js +14 -11
  475. package/out/search-fetch.js.map +1 -1
  476. package/out/sqlite/convention-source.d.ts +0 -5
  477. package/out/sqlite/convention-source.d.ts.map +1 -1
  478. package/out/sqlite/convention-source.js +2 -5
  479. package/out/sqlite/convention-source.js.map +1 -1
  480. package/out/sqlite/utils.d.ts +1 -7
  481. package/out/sqlite/utils.d.ts.map +1 -1
  482. package/out/sqlite/utils.js +3 -4
  483. package/out/sqlite/utils.js.map +1 -1
  484. package/out/street/centroid/schema.d.ts +3 -6
  485. package/out/street/centroid/schema.d.ts.map +1 -1
  486. package/out/street/centroid/schema.js +2 -7
  487. package/out/street/centroid/schema.js.map +1 -1
  488. package/out/street/centroid.d.ts +0 -3
  489. package/out/street/centroid.d.ts.map +1 -1
  490. package/out/street/centroid.js +2 -6
  491. package/out/street/centroid.js.map +1 -1
  492. package/out/street/locale.d.ts +12 -0
  493. package/out/street/locale.d.ts.map +1 -0
  494. package/out/street/locale.js +54 -0
  495. package/out/street/locale.js.map +1 -0
  496. package/out/street/morphology/fst/builder.d.ts +1 -26
  497. package/out/street/morphology/fst/builder.d.ts.map +1 -1
  498. package/out/street/morphology/fst/builder.js +19 -18
  499. package/out/street/morphology/fst/builder.js.map +1 -1
  500. package/out/street/morphology/fst/loader.d.ts +0 -20
  501. package/out/street/morphology/fst/loader.d.ts.map +1 -1
  502. package/out/street/morphology/fst/loader.js +14 -13
  503. package/out/street/morphology/fst/loader.js.map +1 -1
  504. package/out/street/name-lookup.d.ts +11 -13
  505. package/out/street/name-lookup.d.ts.map +1 -1
  506. package/out/street/name-lookup.js +14 -14
  507. package/out/street/name-lookup.js.map +1 -1
  508. package/out/street/normalize.d.ts +29 -12
  509. package/out/street/normalize.d.ts.map +1 -1
  510. package/out/street/normalize.js +53 -13
  511. package/out/street/normalize.js.map +1 -1
  512. package/out/street/segment-schema.d.ts +11 -12
  513. package/out/street/segment-schema.d.ts.map +1 -1
  514. package/out/street/segment-schema.js +13 -12
  515. package/out/street/segment-schema.js.map +1 -1
  516. package/out/street/table.d.ts +154 -0
  517. package/out/street/table.d.ts.map +1 -0
  518. package/out/street/table.js +122 -0
  519. package/out/street/table.js.map +1 -0
  520. package/out/street.d.ts +1 -5
  521. package/out/street.d.ts.map +1 -1
  522. package/out/street.js +3 -5
  523. package/out/street.js.map +1 -1
  524. package/out/types.d.ts +1 -6
  525. package/out/types.d.ts.map +1 -1
  526. package/out/types.js +2 -5
  527. package/out/types.js.map +1 -1
  528. package/out/unified-schema.d.ts +18 -7
  529. package/out/unified-schema.d.ts.map +1 -1
  530. package/out/unified-schema.js +14 -10
  531. package/out/unified-schema.js.map +1 -1
  532. package/out/uprn/existence.d.ts +7 -10
  533. package/out/uprn/existence.d.ts.map +1 -1
  534. package/out/uprn/existence.js +9 -10
  535. package/out/uprn/existence.js.map +1 -1
  536. package/out/uprn/lookup.d.ts +1 -8
  537. package/out/uprn/lookup.d.ts.map +1 -1
  538. package/out/uprn/lookup.js +6 -8
  539. package/out/uprn/lookup.js.map +1 -1
  540. package/out/uprn/schema.d.ts +2 -5
  541. package/out/uprn/schema.d.ts.map +1 -1
  542. package/out/uprn/schema.js +2 -7
  543. package/out/uprn/schema.js.map +1 -1
  544. package/out/uprn.d.ts +0 -5
  545. package/out/uprn.d.ts.map +1 -1
  546. package/out/uprn.js +2 -5
  547. package/out/uprn.js.map +1 -1
  548. package/out/weights-overlay-linker.d.ts +3 -8
  549. package/out/weights-overlay-linker.d.ts.map +1 -1
  550. package/out/weights-overlay-linker.js +5 -8
  551. package/out/weights-overlay-linker.js.map +1 -1
  552. package/package.json +12 -12
  553. package/lib/currency-backfill.ts +0 -289
  554. package/out/currency-backfill.d.ts +0 -68
  555. package/out/currency-backfill.d.ts.map +0 -1
  556. package/out/currency-backfill.js +0 -169
  557. package/out/currency-backfill.js.map +0 -1
@@ -1,8 +1,8 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- * @file Pass 3c of the candidate build — the `name_role` detectors and the thresholds they are judged by.
5
+ * @file Pass 3c of the candidate build — the `name_role` detectors and the thresholds they're judged by.
6
6
  */
7
7
 
8
8
  import { isOfficialLanguage } from "@mailwoman/codex/country"
@@ -0,0 +1,140 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
4
+ /**
5
+ * @file The candidate build's nickname refusal: a colloquial or unclassified name doesn't become an
6
+ * alias row when a populated place holds the same key by a real name.
7
+ */
8
+
9
+ import type { DatabaseClient } from "@mailwoman/sqlite/client"
10
+ import { tableExists } from "@mailwoman/sqlite/introspection"
11
+
12
+ import type { PlaceAttrs } from "#candidate/place-attrs"
13
+ import type { CandidateDatabase } from "#candidate/schema"
14
+ import type { WOFDatabase } from "#schema"
15
+ import { normalizeLocalityForKey, withoutApostropheLikeMarks } from "#street/normalize"
16
+
17
+ /**
18
+ * The WOF name kinds that name a place without being its name: a colloquial name
19
+ * (`Motor City`, `T.O.`) and an unclassified one.
20
+ * An unclassified name is mostly a code (`DE`, `AP`, `GTA`).
21
+ */
22
+ const NICKNAME_KINDS: readonly string[] = ["colloquial", "unknown"]
23
+
24
+ /**
25
+ * The keys a name stages as alias rows: its key, and its mark-free form when that differs.
26
+ */
27
+ function stagedKeys(name: string): string[] {
28
+ const k = normalizeLocalityForKey(name)
29
+
30
+ if (!k) return []
31
+ const free = withoutApostropheLikeMarks(k)
32
+
33
+ return free && free !== k ? [k, free] : [k]
34
+ }
35
+
36
+ /**
37
+ * Deletes the alias rows a place holds only through a colloquial or unclassified name,
38
+ * when another place with a population holds the same key by any other name.
39
+ *
40
+ * The candidate ranks a key's rows by population, so a nickname of a large place outranks
41
+ * every smaller place whose own name the nickname spells: `T.O.` and `To.`
42
+ * (Toronto) over Tó, `Garden City` (Victoria) over each Garden City, `DE` (Germany) over Delaware's `DE`.
43
+ *
44
+ * A namesake without a population ranks last under any populated holder, so a nickname whose
45
+ * only namesakes are unpopulated stays: `Motor City` keeps Detroit over Motor City, California.
46
+ * A nickname that several places share also stays when no other place holds its key
47
+ * by a real name (`The Windy City` for Chicago and Wellington).
48
+ *
49
+ * Runs on `cand_stage` after the primaries, aliases and abbreviations are staged,
50
+ * and before the postcode extracts.
51
+ * A postcode row stores no population.
52
+ *
53
+ * @returns The count of alias rows deleted, and of distinct keys they held.
54
+ */
55
+ export function refuseNicknamesOfNamesakes(
56
+ src: DatabaseClient<WOFDatabase>,
57
+ out: DatabaseClient<CandidateDatabase>,
58
+ attrs: Map<number, PlaceAttrs>
59
+ ): { rows: number; keys: number } {
60
+ if (!tableExists(src, "names")) return { rows: 0, keys: 0 }
61
+
62
+ const kinds = NICKNAME_KINDS.map(() => "?").join(", ")
63
+ const nicknameKeys = new Map<number, Set<string>>()
64
+
65
+ for (const r of src.prepare(`SELECT id, name FROM names WHERE privateuse IN (${kinds})`).iterate(...NICKNAME_KINDS)) {
66
+ const id = Number(r.id)
67
+
68
+ if (!attrs.has(id)) continue
69
+ let keys = nicknameKeys.get(id)
70
+
71
+ if (!keys) {
72
+ keys = new Set()
73
+ nicknameKeys.set(id, keys)
74
+ }
75
+
76
+ for (const k of stagedKeys(String(r.name ?? ""))) {
77
+ keys.add(k)
78
+ }
79
+ }
80
+
81
+ if (!nicknameKeys.size) return { rows: 0, keys: 0 }
82
+
83
+ // A key the place also holds by a real name belongs to that name's row and is never refused.
84
+ const realNames = src.prepare(`SELECT name FROM names WHERE id = ? AND privateuse NOT IN (${kinds})`)
85
+ const abbrs = tableExists(src, "place_abbr") ? src.prepare("SELECT abbr FROM place_abbr WHERE id = ?") : null
86
+
87
+ const ownKeys = (id: number): string[] => [
88
+ ...stagedKeys(attrs.get(id)?.name ?? ""),
89
+ ...realNames.all(id, ...NICKNAME_KINDS).flatMap((r) => stagedKeys(String(r.name ?? ""))),
90
+ ...(abbrs?.all(id).flatMap((r) => stagedKeys(String(r.abbr ?? ""))) ?? []),
91
+ ]
92
+
93
+ out.exec(
94
+ "CREATE TEMP TABLE nickname_key (spr_id INTEGER NOT NULL, name_key TEXT NOT NULL, PRIMARY KEY (spr_id, name_key)) WITHOUT ROWID"
95
+ )
96
+
97
+ const insNickname = out.prepare("INSERT OR IGNORE INTO nickname_key VALUES (?, ?)")
98
+ out.exec("BEGIN")
99
+
100
+ for (const [id, keys] of nicknameKeys) {
101
+ for (const k of ownKeys(id)) {
102
+ keys.delete(k)
103
+ }
104
+
105
+ for (const k of keys) {
106
+ insNickname.run(id, k)
107
+ }
108
+ }
109
+
110
+ out.exec("COMMIT")
111
+
112
+ out.exec("CREATE INDEX temp.nickname_key_by_key ON nickname_key (name_key)")
113
+ out.exec("CREATE TEMP TABLE namesake_key (name_key TEXT PRIMARY KEY) WITHOUT ROWID")
114
+
115
+ out.exec(
116
+ `INSERT OR IGNORE INTO namesake_key
117
+ SELECT cs.name_key FROM cand_stage cs
118
+ WHERE cs.population > 0
119
+ AND cs.name_key IN (SELECT name_key FROM nickname_key)
120
+ AND NOT EXISTS (SELECT 1 FROM nickname_key nk WHERE nk.spr_id = cs.spr_id AND nk.name_key = cs.name_key)`
121
+ )
122
+
123
+ const keys = Number(out.prepare("SELECT count(*) AS n FROM namesake_key").get()!["n"])
124
+
125
+ const rows = Number(
126
+ out
127
+ .prepare(
128
+ `DELETE FROM cand_stage
129
+ WHERE is_primary = 0
130
+ AND name_key IN (SELECT name_key FROM namesake_key)
131
+ AND EXISTS (SELECT 1 FROM nickname_key nk WHERE nk.spr_id = cand_stage.spr_id AND nk.name_key = cand_stage.name_key)`
132
+ )
133
+ .run().changes
134
+ )
135
+
136
+ out.exec("DROP TABLE namesake_key")
137
+ out.exec("DROP TABLE nickname_key")
138
+
139
+ return { rows, keys }
140
+ }
@@ -1,20 +1,22 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
5
  * The own-name variant predicate: is an alias surface the holder's own primary name in another
7
6
  * orthography, whether a romanization (`Брэст` → `brest`), a spacing or diacritic variant
8
7
  * (`George Town` → `georgetown`), or an abbreviation expansion (`St. George's` → `Saint George's`)?
8
+ *
9
9
  * The alternative is a different name that merely shares the folded key.
10
10
  *
11
- * The comparator is `levenshteinSimilarity`. Jaro-Winkler's common-prefix bonus scores the required
12
- * negative case (`chanchun` against `cancun`, 0.925) above real positives (`saint george s` against
13
- * `st georges` expanded, 0.914), so no JW threshold separates them. Edit similarity separates every
14
- * measured case with margin.
11
+ * The comparator is `levenshteinSimilarity`.
12
+ * Jaro-Winkler's common-prefix bonus scores the required negative
13
+ * case (`chanchun` against `cancun`, 0.925) above real positives
14
+ * (`saint george s` against `st georges` expanded, 0.914), so no JW threshold separates them.
15
+ * Edit similarity separates every measured case with margin.
15
16
  *
16
- * An unhandled script (Arabic, Hebrew, CJK, since the romanizer covers Cyrillic only) answers NULL,
17
- * never "different name". Absence of a verdict must not stamp anything.
17
+ * An unhandled script (Arabic, Hebrew, CJK, since the romanizer covers Cyrillic only)
18
+ * answers NULL, never "different name".
19
+ * Absence of a verdict mustn't stamp anything.
18
20
  */
19
21
 
20
22
  import { levenshteinSimilarity } from "@mailwoman/match/comparators"
@@ -1,7 +1,7 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
5
  * @file The per-place record every candidate-staging pass writes its rows from.
6
6
  *
7
7
  * Pass 1 reduces each current `spr` row to one {@link PlaceAttrs}. Every later pass (alias bags,
@@ -36,7 +36,7 @@ export interface PlaceAttrs {
36
36
  * The place's toponym-fame score, or null when the score source has no measurement for it.
37
37
  *
38
38
  * A property of the place, so it appears on {@link StageRow} and on alias and abbrev rows too.
39
- * That is how a bare `Moscow` reaches Москва's score through the alias row that includes the key.
39
+ * That's how a bare `Moscow` reaches Москва's score through the alias row that includes the key.
40
40
  */
41
41
  imp: number | null
42
42
  }
@@ -1,8 +1,5 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- */
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
6
3
 
7
4
  import { sql, type Kysely } from "kysely"
8
5
 
@@ -1,8 +1,5 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- */
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
6
3
 
7
4
  import { compareReferential, referentialFromPopulation } from "@mailwoman/core/resolver"
8
5
  import { haversine } from "@mailwoman/spatial/geometries/point/distance"
@@ -196,7 +193,7 @@ export function rankCandidates<DB>(
196
193
 
197
194
  // With proximity hints, prominence replaces raw population as the within-tier key.
198
195
  // Without them, referential ordering decides.
199
- // Encyclopedic importance does not affect this order.
196
+ // Encyclopedic importance doesn't affect this order.
200
197
  const hasHints = !!query.near || (query.bias?.length ?? 0) > 0
201
198
 
202
199
  candidates.sort((a, b) => {
@@ -1,16 +1,17 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
+ * The `capital` table: the capital-status reference included inside `candidate.db`,
6
+ * so an npm consumer who pulled the artifact can run `capital_tier` without the repo's
7
+ * `data/gazetteer/capitals-v1.json`, which published packages do not ship.
5
8
  *
6
- * The `capital` table: the capital-status reference included inside `candidate.db`, so an npm
7
- * consumer who pulled the artifact can run `capital_tier` without the repo's
8
- * `data/gazetteer/capitals-v1.json`, which published packages do not ship. One row per reference
9
- * entry. The loader reads the whole table once into a `CapitalIndex` at session construction, so
10
- * there is no per-probe query and no index beyond the rowid.
9
+ * One row per reference entry.
10
+ * The loader reads the whole table once into a `CapitalIndex` at session construction,
11
+ * so there's no per-probe query and no index beyond the rowid.
11
12
  *
12
- * `keys` holds the entry's folded name set as a JSON array, the name-membership conjunct that keeps
13
- * the coordinate radius from promoting a capital's same-name neighbors (`capitals.ts`).
13
+ * `keys` holds the entry's folded name set as a JSON array, the name-membership conjunct that
14
+ * keeps the coordinate radius from promoting a capital's same-name neighbors (`capitals.ts`).
14
15
  */
15
16
 
16
17
  import { tryParsingJSON } from "@mailwoman/core/json"
package/lib/capitals.ts CHANGED
@@ -1,18 +1,21 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
+ * The capital-status reference index answers whether a resolved candidate is
6
+ * its country's national capital or admin-1 seat.
7
+ *
8
+ * The consumer is the resolver's bounded capital promotion
9
+ * (`@mailwoman/resolver`'s `promoteCapitals`, applied after the fame key on the bare-toponym class).
10
+ * This module only matches and never ranks.
11
+ * It is pure and platform-free.
5
12
  *
6
- * The capital-status reference index answers whether a resolved candidate is its country's national capital or admin-1 seat.
7
- * The consumer is the resolver's
8
- * bounded capital promotion (`@mailwoman/resolver`'s `promoteCapitals`, applied after the fame
9
- * key on the bare-toponym class). This module only matches and never ranks. It is pure and
10
- * platform-free.
13
+ * A match requires the same country and a distance within
14
+ * {@link CAPITAL_MATCH_RADIUS_KM} of the reference point.
15
+ * The candidate's folded name must also appear in the reference entry's folded name set
16
+ * (name + romanization + the source's alternate names, so exonym rows such as "Vienna" for Wien still match).
11
17
  *
12
- * A match requires the same country and a distance within {@link CAPITAL_MATCH_RADIUS_KM} of the reference point.
13
- * The candidate's folded name must also appear in the reference entry's folded name set (name + romanization + the source's alternate
14
- * names, so exonym rows such as "Vienna" for Wien still match). The name set is what makes the
15
- * radius a centroid-drift allowance rather than a catchment.
18
+ * The name set is what makes the radius a centroid-drift allowance rather than a catchment.
16
19
  */
17
20
 
18
21
  import { haversine } from "@mailwoman/spatial/geometries/point/distance"
@@ -1,12 +1,12 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
+ * Typed schema for the convention asset — the `address_convention` table `SqliteConventionSource`
6
+ * probes, plus the `meta` provenance row every sealed artifact here includes.
5
7
  *
6
- * Typed schema for the convention asset — the `address_convention` table `SqliteConventionSource` probes, plus the
7
- * `meta` provenance row every sealed artifact here includes. The interface is the read/write interface and
8
- * {@link createAddressConventionTable} creates the table, so a column added to one is a compile error against the
9
- * other.
8
+ * The interface is the read/write interface and {@link createAddressConventionTable}
9
+ * creates the table, so a column added to one is a compile error against the other.
10
10
  */
11
11
 
12
12
  import type { KeyValueMetaTable } from "@mailwoman/sqlite/database-schema"
package/lib/convention.ts CHANGED
@@ -1,7 +1,7 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
5
  * @file Defines resolution conventions as per-polygon profiles merged along a place's ancestor chain.
6
6
  *
7
7
  * The strategy implementations live in `lookup.ts` and are registered by name.
@@ -1,7 +1,7 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
5
  * @file Schema and read/write helpers for the candidate gazetteer's coverage manifest.
6
6
  *
7
7
  * The manifest holds two country-keyed tables. `country_coverage` records each measured country's hard-filter
@@ -33,7 +33,7 @@ export interface CountryCoverageTable {
33
33
  /**
34
34
  * The promotion-eval verdict as 0 or 1.
35
35
  *
36
- * It is stored directly because the rate by itself does not decide it.
36
+ * It is stored directly because the rate by itself doesn't decide it.
37
37
  */
38
38
  hard_filter_safe: number
39
39
  /**
package/lib/env.ts CHANGED
@@ -1,10 +1,11 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Environment variables name the WOF SQLite artifacts this resolver opens and the development weights the overlay
7
- * linker materializes. CLI flags (`--resolve-db`, …) override these at the call site.
5
+ * Environment variables name the WOF SQLite artifacts this resolver opens
6
+ * and the development weights the overlay
7
+ * linker materializes.
8
+ * CLI flags (`--resolve-db`, …) override these at the call site.
8
9
  */
9
10
 
10
11
  import { $public as corePublic, liveEnv } from "@mailwoman/core/env"
@@ -1,10 +1,9 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * The exact-match tier's name probes, the two case-folded equality lookups that decide whether a
7
- * candidate holds the query text as its own name, an alias, or an official name.
5
+ * The exact-match tier's name probes, the two case-folded equality lookups that decide
6
+ * whether a candidate holds the query text as its own name, an alias, or an official name.
8
7
  */
9
8
 
10
9
  import type { DatabaseClient } from "@mailwoman/sqlite/client"
@@ -77,7 +76,7 @@ export function exactMatchIDs<DB>(
77
76
  }
78
77
  }
79
78
  } catch {
80
- // Extract without place_search either, so there is no exact-match tier.
79
+ // Extract without place_search either, so there's no exact-match tier.
81
80
  // The caller falls back to weighted-sum order.
82
81
  }
83
82
 
package/lib/extracts.ts CHANGED
@@ -1,13 +1,14 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  import { stringifyJSON } from "@mailwoman/core/json"
2
5
  import { basename, PathBuilder, type PathBuilderLike } from "path-ts"
3
6
 
4
7
  /**
5
- * @copyright Sister Software
6
- * @license AGPL-3.0
7
- * @author Teffen Ellis, et al.
8
+ * Multi-extract support for `WOFSQLitePlaceLookup`.
8
9
  *
9
- * Multi-extract support for `WOFSQLitePlaceLookup`. It opens multiple WOF SQLite distributions
10
- * on one connection with `attach database`. It routes queries by placetype.
10
+ * It opens multiple WOF SQLite distributions on one connection with `attach database`.
11
+ * It routes queries by placetype.
11
12
  *
12
13
  * SQLite parses a schema-qualified table on the left of `match` as "column place_search of table
13
14
  * pc", so the working form is schema-qualified in `from` and a bare table name in `match`:
@@ -16,8 +17,9 @@ import { basename, PathBuilder, type PathBuilderLike } from "path-ts"
16
17
  * select … from pc.place_search where place_search match ?
17
18
  * ```
18
19
  *
19
- * Identical table names across attached extracts are fine, because the bare-name `match` resolves
20
- * against `from` scope. Every extract ships its own `place_search` and `place_bbox`.
20
+ * Identical table names across attached extracts are fine, because the bare-name
21
+ * `match` resolves against `from` scope.
22
+ * Every extract ships its own `place_search` and `place_bbox`.
21
23
  */
22
24
 
23
25
  /**
@@ -66,7 +68,7 @@ export interface ExtractConfig {
66
68
  /**
67
69
  * Override the auto-derived schema name.
68
70
  *
69
- * Useful when the filename does not match WOF convention or when you want a memorable handle.
71
+ * Useful when the filename doesn't match WOF convention or when you want a memorable handle.
70
72
  * Must be a valid SQLite identifier matching `[a-zA-Z_][a-zA-Z0-9_]*`.
71
73
  */
72
74
  schemaName?: string
@@ -205,7 +207,7 @@ export function pickExtractsForPlacetype(
205
207
  * (e.g. `postalcode_us` matches `postalcode`), use it.
206
208
  * 3. Otherwise, fall back to `main`.
207
209
  *
208
- * This deliberately does not union across extracts.
210
+ * This deliberately doesn't union across extracts.
209
211
  * BM25 scores are not comparable across separately indexed corpora.
210
212
  * A typical mailwoman query has one placetype.
211
213
  *
@@ -1,20 +1,24 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
5
  * FST-based autocomplete, mailwoman vocabulary over `@mailwoman/ancestrie`'s generic algorithm.
7
- * The prefix walk, BFS expansion, partial-last-token completion, per-branch capping and dedupe
8
- * live in ancestrie's `autocomplete`. This module contributes only the storage adapter
9
- * ({@link FSTMatcher} → `AncestrieReaderLike`) and the mapping back to mailwoman's suggestion
10
- * shape (name, placetype, referential and encyclopedic scores, WOF ids).
11
6
  *
12
- * The bytes do not migrate. The shipped artifacts are `FST\0` v1 to v5 (`fst-serialize.ts`), and
13
- * ancestrie's entries are id-keyed with one record per id. An FST place row is per-(surface,
14
- * place), because `crossCountryBranches` is a property of the surface, so the same wofID
15
- * legitimately has different values under different aliases, so it cannot use IDs as keys.
16
- * The matcher, both deserializers and serializer stay here. The algorithm is the
17
- * half that migrated.
7
+ * The prefix walk, BFS expansion, partial-last-token completion, per-branch capping
8
+ * and dedupe live in ancestrie's `autocomplete`.
9
+ * This module contributes only the storage adapter ({@link FSTMatcher} → `AncestrieReaderLike`)
10
+ * and the mapping back to mailwoman's suggestion shape
11
+ * (name, placetype, referential and encyclopedic scores, WOF ids).
12
+ *
13
+ * The bytes do not migrate.
14
+ * The shipped artifacts are `FST\0` v1 to v5 (`fst-serialize.ts`), and ancestrie's
15
+ * entries are id-keyed with one record per id.
16
+ *
17
+ * An FST place row is per-(surface, place), because `crossCountryBranches` is a
18
+ * property of the surface, so the same wofID legitimately has different values
19
+ * under different aliases, so it cannot use IDs as keys.
20
+ * The matcher, both deserializers and serializer stay here.
21
+ * The algorithm is the half that migrated.
18
22
  */
19
23
 
20
24
  import type {
@@ -69,7 +73,7 @@ export interface AutocompleteOpts {
69
73
  *
70
74
  * Off by default, because the CLI surfaces distinct same-name places such as
71
75
  * New York the city and New York the county.
72
- * A typeahead wants it on so the dropdown does not show four "New London"s.
76
+ * A typeahead wants it on so the dropdown doesn't show four "New London"s.
73
77
  */
74
78
  dedupeByName?: boolean
75
79
  }
@@ -1,31 +1,31 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
1
4
  /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
5
  * An FST matcher that answers from the serialized binary in place.
7
6
  *
8
- * {@link FSTMatcher} holds one `Map` per state and one object per place entry. For a national gazetteer those
9
- * objects take several times the size of the file. This matcher keeps the file's bytes and two typed-array hash tables: one from
10
- * an edge token to its string index, and one from a (state, string index) pair to the edge's target state. Place
11
- * entries are decoded when a query reaches their state.
7
+ * {@link FSTMatcher} holds one `Map` per state and one object per place entry.
8
+ * For a national gazetteer those objects take several times the size of the file.
9
+ *
10
+ * This matcher keeps the file's bytes and two typed-array hash tables: one from an edge token
11
+ * to its string index, and one from a (state, string index) pair to the edge's target state.
12
+ * Place entries are decoded when a query reaches their state.
12
13
  */
13
14
 
14
15
  import type { AncestrieMatch } from "@mailwoman/ancestrie"
15
16
  import { hashFNV1a } from "@mailwoman/core/coarse-placer/fnv-hash"
16
17
 
17
18
  import {
19
+ decodePlaceEntry,
20
+ idTableOffset,
21
+ loadIDTable,
18
22
  EDGE_ENTRY_SIZE,
19
- ENCYCLOPEDIC_OFFSET,
20
23
  FST_FORMAT_VERSION,
21
24
  FST_MAGIC_BYTES,
22
25
  HEADER_SIZE,
23
- LEGACY_PLACE_ENTRY_SIZE,
24
26
  NARROW_STATE_ENTRY_SIZE,
25
- PLACE_FLAG_HAS_ENCYCLOPEDIC,
26
- PLACETYPE_ORDER,
27
- SPLIT_PLACE_ENTRY_SIZE,
28
- VERSION_TWO_SCORE_SPLIT,
27
+ placeEntryLayout,
28
+ type PlaceEntryLayout,
29
29
  VERSION_WIDE_STATE_COUNTERS,
30
30
  WIDE_STATE_ENTRY_SIZE,
31
31
  } from "#fst/format"
@@ -70,10 +70,13 @@ export class BinaryFSTMatcher {
70
70
  readonly #decoder = new TextDecoder("utf-8")
71
71
  readonly #version: number
72
72
  readonly #isWide: boolean
73
- readonly #isSplit: boolean
74
73
  readonly #hasAmbiguity: boolean
75
74
  readonly #stateEntrySize: number
76
- readonly #placeEntrySize: number
75
+ readonly #placeLayout: PlaceEntryLayout
76
+ /**
77
+ * The file's id table, or `null` for a file that stores WOF ids in its place entries.
78
+ */
79
+ readonly #ids: Float64Array | null
77
80
  readonly #stringDataStart: number
78
81
  readonly #stateTableStart: number
79
82
  readonly #edgeTableStart: number
@@ -105,12 +108,10 @@ export class BinaryFSTMatcher {
105
108
  this.#view = view
106
109
  this.#version = version
107
110
  this.#isWide = version >= VERSION_WIDE_STATE_COUNTERS
108
- this.#isSplit = version >= VERSION_TWO_SCORE_SPLIT
109
111
  // Flags bit 0, as `serializeFST` writes it: place rows include surface-ambiguity data.
110
112
  this.#hasAmbiguity = (view.getUint16(6, true) & 1) === 1
111
113
  this.#stateEntrySize = this.#isWide ? WIDE_STATE_ENTRY_SIZE : NARROW_STATE_ENTRY_SIZE
112
- // Version 5 grew the place entry by the encyclopedic float.
113
- this.#placeEntrySize = this.#isSplit ? SPLIT_PLACE_ENTRY_SIZE : LEGACY_PLACE_ENTRY_SIZE
114
+ this.#placeLayout = placeEntryLayout(version)
114
115
 
115
116
  const stateCount = view.getUint32(8, true)
116
117
  const edgeCount = view.getUint32(12, true)
@@ -129,6 +130,12 @@ export class BinaryFSTMatcher {
129
130
  this.#edgeTableStart = this.#stateTableStart + stateCount * this.#stateEntrySize
130
131
  this.#placeTableStart = this.#edgeTableStart + edgeCount * EDGE_ENTRY_SIZE
131
132
 
133
+ this.#ids = loadIDTable(
134
+ view,
135
+ idTableOffset(this.#placeTableStart, view.getUint32(16, true), this.#placeLayout),
136
+ this.#placeLayout
137
+ )
138
+
132
139
  this.#tokenSlots = new Int32Array(tableCapacity(stringCount)).fill(EMPTY_SLOT)
133
140
 
134
141
  const edgeCapacity = tableCapacity(edgeCount)
@@ -324,7 +331,7 @@ export class BinaryFSTMatcher {
324
331
  }
325
332
 
326
333
  /**
327
- * Returns the state the edge labeled `token` leads to from `stateID`, or 0 when there is no such edge.
334
+ * Returns the state the edge labeled `token` leads to from `stateID`, or 0 when there's no such edge.
328
335
  */
329
336
  #target(stateID: number, token: string): number {
330
337
  const stringIndex = this.#tokenIndex(token)
@@ -345,35 +352,14 @@ export class BinaryFSTMatcher {
345
352
  }
346
353
 
347
354
  #placeAt(placeIndex: number): PlaceEntry {
348
- const view = this.#view
349
- const entry = this.#placeTableStart + placeIndex * this.#placeEntrySize
350
- const chainLength = view.getUint8(entry + 5)
351
- const parentChain: number[] = new Array(chainLength)
352
-
353
- for (let index = 0; index < chainLength; index++) {
354
- parentChain[index] = view.getUint32(entry + 24 + index * 4, true)
355
- }
356
-
357
- // Version 1 stored a raw population u32 here, and later versions store the referential score.
358
- // `deserializeFST` explains why a version 1 value converts to the referential score this way.
359
- const referential =
360
- this.#version >= 2
361
- ? view.getFloat32(entry + 12, true)
362
- : Math.min(1, Math.log2(1 + view.getUint32(entry + 12, true) / 1000) / 14)
363
-
364
- const hasEncyclopedic =
365
- this.#isSplit && (view.getUint8(entry + 7) & PLACE_FLAG_HAS_ENCYCLOPEDIC) === PLACE_FLAG_HAS_ENCYCLOPEDIC
366
-
367
- return {
368
- wofID: view.getUint32(entry, true),
369
- placetype: PLACETYPE_ORDER[view.getUint8(entry + 4)] ?? "locality",
370
- name: this.#string(view.getUint32(entry + 8, true)),
371
- referential,
372
- lat: view.getFloat32(entry + 16, true),
373
- lon: view.getFloat32(entry + 20, true),
374
- parentChain,
375
- crossCountryBranches: this.#hasAmbiguity ? view.getUint8(entry + 6) : null,
376
- encyclopedic: hasEncyclopedic ? view.getFloat32(entry + ENCYCLOPEDIC_OFFSET, true) : null,
377
- }
355
+ return decodePlaceEntry(
356
+ this.#view,
357
+ this.#placeTableStart + placeIndex * this.#placeLayout.size,
358
+ this.#version,
359
+ this.#placeLayout,
360
+ this.#hasAmbiguity,
361
+ (index) => this.#string(index),
362
+ this.#ids
363
+ )
378
364
  }
379
365
  }