@mailwoman/corpus 11.1.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 (474) hide show
  1. package/README.md +20 -14
  2. package/data/address-source-register.json +618 -13
  3. package/data/builds/v0.8.19-overlay/OVERLAY_PLAN.json +4778 -0
  4. package/data/builds/v0.8.19-rebuild/inputs.json +128 -0
  5. package/data/builds/v0.8.20-overlay/OVERLAY_PLAN.json +3595 -0
  6. package/data/builds/v0.8.20-rebuild/inputs.json +131 -0
  7. package/data/builds/v0.8.21-overlay/OVERLAY_PLAN.json +72 -0
  8. package/data/corpus-source-inputs.json +104 -2
  9. package/data/holdout/evaluation-groups.v0.8.18.json +90511 -0
  10. package/data/holdout/evaluation-groups.v0.8.19.json +100537 -0
  11. package/data/holdout/evaluation-groups.v0.8.20.json +129215 -0
  12. package/data/holdout/evaluation-groups.v0.8.21.json +173286 -0
  13. package/data/holdout/probe-text-collisions.v0.8.20.json +1478 -0
  14. package/data/license-decisions.json +393 -3
  15. package/data/licenses/PROVENANCE.md +15 -9
  16. package/data/licenses/au-acnc-cc-by-3.0-au.md +37 -0
  17. package/data/licenses/es-sanidad-aviso-legal.md +26 -0
  18. package/data/licenses/it-miur-iodl-2.0.md +41 -0
  19. package/data/licenses/nz-charities-cc-by-3.0-nz.md +36 -0
  20. package/data/region-slot-second-level.json +966 -0
  21. package/data/source-additions.json +126 -6
  22. package/data/source-resolutions.json +97 -0
  23. package/data/training-configs/v8.7.0-base-c6-90k-usgs-structures-s42.yaml +801 -0
  24. package/data/training-configs/v8.7.0-base-c6-90k-usgs-structures-s43.yaml +726 -0
  25. package/data/training-configs/v8.8.0-base-c6-90k-v0820-county-s42.yaml +944 -0
  26. package/data/training-configs/v8.9.0-base-c6-90k-v0821-s42.yaml +848 -0
  27. package/data/training-manifests/v0.8.19-retention-overlay.json +4553 -0
  28. package/data/training-manifests/v0.8.20-retention-overlay.json +4579 -0
  29. package/data/training-manifests/v0.8.21-retention-overlay.effective.json +2521 -0
  30. package/data/training-manifests/v0.8.21-retention-overlay.json +4579 -0
  31. package/lib/adapters/cordis/adapter.ts +10 -2
  32. package/lib/adapters/gleif/adapter.ts +23 -5
  33. package/lib/adapters/osm/adapter.ts +2 -2
  34. package/lib/adapters/street/repetition.ts +87 -0
  35. package/lib/adapters/street/unit.ts +14 -0
  36. package/lib/adapters/wof/admin/json/adapter.ts +34 -21
  37. package/lib/adapters/wof/admin/json/dual-role.ts +274 -0
  38. package/lib/adapters/wof/admin/json/explore.ts +4 -4
  39. package/lib/adapters/wof/admin/json/region-codes.ts +74 -3
  40. package/lib/adapters/wof/json-rows.ts +36 -21
  41. package/lib/adapters/wof/postalcode-json/adapter.ts +10 -28
  42. package/lib/adapters/wof/sample.ts +15 -3
  43. package/lib/adapters/wof/stored-records.ts +162 -0
  44. package/lib/adapters.ts +18 -6
  45. package/lib/au/adapters/acnc-register/adapter.ts +40 -0
  46. package/lib/au/evaluation/acnc-register.ts +144 -0
  47. package/lib/build/align/range.ts +9 -0
  48. package/lib/build/align/totals.ts +23 -0
  49. package/lib/build/align.ts +74 -4
  50. package/lib/build/budget.ts +11 -45
  51. package/lib/build/checkpoint.ts +11 -0
  52. package/lib/build/component-check.ts +99 -3
  53. package/lib/build/manifest.ts +4 -0
  54. package/lib/build/parallel.ts +8 -34
  55. package/lib/build/region-names.ts +609 -0
  56. package/lib/build/source-record.ts +7 -0
  57. package/lib/build/types.ts +20 -0
  58. package/lib/build/worker.ts +3 -1
  59. package/lib/build.ts +3 -6
  60. package/lib/de/recipes/locale.ts +3 -2
  61. package/lib/env.ts +0 -6
  62. package/lib/es/adapters/sanidad-centros-ap/adapter.ts +40 -0
  63. package/lib/es/evaluation/sanidad-centros-ap.ts +164 -0
  64. package/lib/evaluation/corpus-adapter.ts +153 -0
  65. package/lib/evaluation/source.ts +209 -0
  66. package/lib/evaluation/sources.ts +25 -0
  67. package/lib/fr/adapters/laposte-poincont/adapter.ts +381 -0
  68. package/lib/fr/recipes/unit-line-guideline.ts +9 -4
  69. package/lib/fr/structures/laposte.ts +139 -0
  70. package/lib/fr/tools/fetch/laposte-poincont.ts +234 -0
  71. package/lib/it/adapters/miur-scuole/adapter.ts +39 -0
  72. package/lib/it/evaluation/miur-scuole.ts +125 -0
  73. package/lib/jp/adapters/wof-admin/adapter.ts +4 -4
  74. package/lib/nc/adapters/opt-nc/adapter.ts +237 -0
  75. package/lib/nc/structures/opt-nc.ts +101 -0
  76. package/lib/nc/tools/fetch/opt-nc.ts +249 -0
  77. package/lib/nz/adapters/charities-register/adapter.ts +40 -0
  78. package/lib/nz/evaluation/charities-register.ts +149 -0
  79. package/lib/recipes/bare/postcode.ts +14 -11
  80. package/lib/recipes/deepseek/batches.ts +8 -8
  81. package/lib/recipes/po/box/cedex/recipe.ts +12 -1
  82. package/lib/recipes/po/box/cedex/us.ts +43 -2
  83. package/lib/recipes/scaffold.ts +1 -1
  84. package/lib/recipes/sources.ts +16 -0
  85. package/lib/recipes.ts +2 -0
  86. package/lib/registers.ts +28 -2
  87. package/lib/{post-offices → structures}/source.ts +49 -16
  88. package/lib/structures/sources.ts +26 -0
  89. package/lib/synthesizers/house-venue.ts +11 -6
  90. package/lib/synthesizers/tail.ts +27 -3
  91. package/lib/tools/audit.ts +1 -1
  92. package/lib/tools/fetch/storage.ts +18 -4
  93. package/lib/tools/fetch.ts +10 -2
  94. package/lib/tools/overlay/kryptonite.ts +6 -2
  95. package/lib/tools/overlay/split/attribute.ts +14 -2
  96. package/lib/tools/overlay/split/overlay.ts +36 -7
  97. package/lib/tools/postcode/triples.ts +3 -3
  98. package/lib/tools/region-slot-census.run.ts +184 -0
  99. package/lib/training/config/load.ts +19 -0
  100. package/lib/training/config/schema.ts +6 -0
  101. package/lib/tw/registers.ts +15 -4
  102. package/lib/tw/structures/chunghwa-post.ts +191 -0
  103. package/lib/tw/tools/fetch/chunghwa-post.ts +174 -0
  104. package/lib/us/adapters/state/ny-notaries/adapter.ts +7 -2
  105. package/lib/us/adapters/state/tx-notaries/adapter.ts +126 -21
  106. package/lib/us/adapters/usgov/nad/adapter.ts +111 -31
  107. package/lib/us/adapters/usgov/nppes/adapter.ts +8 -11
  108. package/lib/us/adapters/usgov/{usgs-post-offices → usgs-structures}/adapter.ts +65 -35
  109. package/lib/us/recipes/county.ts +474 -0
  110. package/lib/us/street-unit.ts +15 -5
  111. package/lib/us/structures/usgs/layers.ts +171 -0
  112. package/lib/us/structures/usgs/national-map.ts +95 -0
  113. package/lib/us/tools/fetch/usgs/gnis.ts +288 -0
  114. package/lib/us/tools/fetch/usgs/structures.ts +362 -0
  115. package/lib/utils/align.ts +2 -2
  116. package/lib/utils/evaluation-groups.ts +172 -0
  117. package/lib/utils/split.ts +40 -4
  118. package/lib/utils/tokenize.ts +7 -7
  119. package/lib/utils/validation-groups.ts +292 -0
  120. package/lib/utils/wof-json.ts +96 -134
  121. package/out/adapters/cordis/adapter.d.ts +3 -1
  122. package/out/adapters/cordis/adapter.d.ts.map +1 -1
  123. package/out/adapters/cordis/adapter.js +8 -2
  124. package/out/adapters/cordis/adapter.js.map +1 -1
  125. package/out/adapters/gleif/adapter.d.ts.map +1 -1
  126. package/out/adapters/gleif/adapter.js +19 -5
  127. package/out/adapters/gleif/adapter.js.map +1 -1
  128. package/out/adapters/osm/adapter.js +2 -2
  129. package/out/adapters/osm/adapter.js.map +1 -1
  130. package/out/adapters/street/repetition.d.ts +19 -0
  131. package/out/adapters/street/repetition.d.ts.map +1 -0
  132. package/out/adapters/street/repetition.js +71 -0
  133. package/out/adapters/street/repetition.js.map +1 -0
  134. package/out/adapters/street/unit.d.ts +10 -0
  135. package/out/adapters/street/unit.d.ts.map +1 -1
  136. package/out/adapters/street/unit.js +6 -0
  137. package/out/adapters/street/unit.js.map +1 -1
  138. package/out/adapters/wof/admin/json/adapter.d.ts +8 -0
  139. package/out/adapters/wof/admin/json/adapter.d.ts.map +1 -1
  140. package/out/adapters/wof/admin/json/adapter.js +26 -22
  141. package/out/adapters/wof/admin/json/adapter.js.map +1 -1
  142. package/out/adapters/wof/admin/json/dual-role.d.ts +83 -0
  143. package/out/adapters/wof/admin/json/dual-role.d.ts.map +1 -0
  144. package/out/adapters/wof/admin/json/dual-role.js +183 -0
  145. package/out/adapters/wof/admin/json/dual-role.js.map +1 -0
  146. package/out/adapters/wof/admin/json/explore.d.ts.map +1 -1
  147. package/out/adapters/wof/admin/json/explore.js +4 -4
  148. package/out/adapters/wof/admin/json/explore.js.map +1 -1
  149. package/out/adapters/wof/admin/json/region-codes.d.ts +16 -0
  150. package/out/adapters/wof/admin/json/region-codes.d.ts.map +1 -1
  151. package/out/adapters/wof/admin/json/region-codes.js +62 -3
  152. package/out/adapters/wof/admin/json/region-codes.js.map +1 -1
  153. package/out/adapters/wof/json-rows.d.ts +28 -6
  154. package/out/adapters/wof/json-rows.d.ts.map +1 -1
  155. package/out/adapters/wof/json-rows.js +9 -15
  156. package/out/adapters/wof/json-rows.js.map +1 -1
  157. package/out/adapters/wof/postalcode-json/adapter.d.ts +1 -1
  158. package/out/adapters/wof/postalcode-json/adapter.d.ts.map +1 -1
  159. package/out/adapters/wof/postalcode-json/adapter.js +9 -26
  160. package/out/adapters/wof/postalcode-json/adapter.js.map +1 -1
  161. package/out/adapters/wof/sample.d.ts +8 -1
  162. package/out/adapters/wof/sample.d.ts.map +1 -1
  163. package/out/adapters/wof/sample.js +12 -4
  164. package/out/adapters/wof/sample.js.map +1 -1
  165. package/out/adapters/wof/stored-records.d.ts +62 -0
  166. package/out/adapters/wof/stored-records.d.ts.map +1 -0
  167. package/out/adapters/wof/stored-records.js +91 -0
  168. package/out/adapters/wof/stored-records.js.map +1 -0
  169. package/out/adapters.d.ts +1 -1
  170. package/out/adapters.d.ts.map +1 -1
  171. package/out/adapters.js +15 -3
  172. package/out/adapters.js.map +1 -1
  173. package/out/au/adapters/acnc-register/adapter.d.ts +9 -0
  174. package/out/au/adapters/acnc-register/adapter.d.ts.map +1 -0
  175. package/out/au/adapters/acnc-register/adapter.js +37 -0
  176. package/out/au/adapters/acnc-register/adapter.js.map +1 -0
  177. package/out/au/evaluation/acnc-register.d.ts +56 -0
  178. package/out/au/evaluation/acnc-register.d.ts.map +1 -0
  179. package/out/au/evaluation/acnc-register.js +84 -0
  180. package/out/au/evaluation/acnc-register.js.map +1 -0
  181. package/out/build/align/range.d.ts.map +1 -1
  182. package/out/build/align/range.js +9 -0
  183. package/out/build/align/range.js.map +1 -1
  184. package/out/build/align/totals.d.ts +5 -0
  185. package/out/build/align/totals.d.ts.map +1 -1
  186. package/out/build/align/totals.js +15 -0
  187. package/out/build/align/totals.js.map +1 -1
  188. package/out/build/align.d.ts +26 -0
  189. package/out/build/align.d.ts.map +1 -1
  190. package/out/build/align.js +35 -2
  191. package/out/build/align.js.map +1 -1
  192. package/out/build/budget.d.ts +9 -26
  193. package/out/build/budget.d.ts.map +1 -1
  194. package/out/build/budget.js +10 -31
  195. package/out/build/budget.js.map +1 -1
  196. package/out/build/checkpoint.d.ts +11 -0
  197. package/out/build/checkpoint.d.ts.map +1 -1
  198. package/out/build/checkpoint.js.map +1 -1
  199. package/out/build/component-check.d.ts +55 -1
  200. package/out/build/component-check.d.ts.map +1 -1
  201. package/out/build/component-check.js +65 -3
  202. package/out/build/component-check.js.map +1 -1
  203. package/out/build/manifest.d.ts.map +1 -1
  204. package/out/build/manifest.js +4 -0
  205. package/out/build/manifest.js.map +1 -1
  206. package/out/build/parallel.d.ts.map +1 -1
  207. package/out/build/parallel.js +8 -24
  208. package/out/build/parallel.js.map +1 -1
  209. package/out/build/region-names.d.ts +120 -0
  210. package/out/build/region-names.d.ts.map +1 -0
  211. package/out/build/region-names.js +430 -0
  212. package/out/build/region-names.js.map +1 -0
  213. package/out/build/source-record.d.ts.map +1 -1
  214. package/out/build/source-record.js +4 -0
  215. package/out/build/source-record.js.map +1 -1
  216. package/out/build/types.d.ts +20 -0
  217. package/out/build/types.d.ts.map +1 -1
  218. package/out/build/worker.js +3 -1
  219. package/out/build/worker.js.map +1 -1
  220. package/out/build.d.ts +0 -1
  221. package/out/build.d.ts.map +1 -1
  222. package/out/build.js +3 -5
  223. package/out/build.js.map +1 -1
  224. package/out/de/recipes/locale.d.ts.map +1 -1
  225. package/out/de/recipes/locale.js +3 -2
  226. package/out/de/recipes/locale.js.map +1 -1
  227. package/out/env.d.ts +0 -2
  228. package/out/env.d.ts.map +1 -1
  229. package/out/env.js +0 -5
  230. package/out/env.js.map +1 -1
  231. package/out/es/adapters/sanidad-centros-ap/adapter.d.ts +9 -0
  232. package/out/es/adapters/sanidad-centros-ap/adapter.d.ts.map +1 -0
  233. package/out/es/adapters/sanidad-centros-ap/adapter.js +36 -0
  234. package/out/es/adapters/sanidad-centros-ap/adapter.js.map +1 -0
  235. package/out/es/evaluation/sanidad-centros-ap.d.ts +34 -0
  236. package/out/es/evaluation/sanidad-centros-ap.d.ts.map +1 -0
  237. package/out/es/evaluation/sanidad-centros-ap.js +128 -0
  238. package/out/es/evaluation/sanidad-centros-ap.js.map +1 -0
  239. package/out/evaluation/corpus-adapter.d.ts +60 -0
  240. package/out/evaluation/corpus-adapter.d.ts.map +1 -0
  241. package/out/evaluation/corpus-adapter.js +100 -0
  242. package/out/evaluation/corpus-adapter.js.map +1 -0
  243. package/out/evaluation/source.d.ts +134 -0
  244. package/out/evaluation/source.d.ts.map +1 -0
  245. package/out/evaluation/source.js +80 -0
  246. package/out/evaluation/source.js.map +1 -0
  247. package/out/evaluation/sources.d.ts +6 -0
  248. package/out/evaluation/sources.d.ts.map +1 -0
  249. package/out/evaluation/sources.js +22 -0
  250. package/out/evaluation/sources.js.map +1 -0
  251. package/out/fr/adapters/laposte-poincont/adapter.d.ts +110 -0
  252. package/out/fr/adapters/laposte-poincont/adapter.d.ts.map +1 -0
  253. package/out/fr/adapters/laposte-poincont/adapter.js +315 -0
  254. package/out/fr/adapters/laposte-poincont/adapter.js.map +1 -0
  255. package/out/fr/recipes/unit-line-guideline.d.ts.map +1 -1
  256. package/out/fr/recipes/unit-line-guideline.js +8 -4
  257. package/out/fr/recipes/unit-line-guideline.js.map +1 -1
  258. package/out/fr/structures/laposte.d.ts +27 -0
  259. package/out/fr/structures/laposte.d.ts.map +1 -0
  260. package/out/fr/structures/laposte.js +96 -0
  261. package/out/fr/structures/laposte.js.map +1 -0
  262. package/out/fr/tools/fetch/laposte-poincont.d.ts +95 -0
  263. package/out/fr/tools/fetch/laposte-poincont.d.ts.map +1 -0
  264. package/out/fr/tools/fetch/laposte-poincont.js +135 -0
  265. package/out/fr/tools/fetch/laposte-poincont.js.map +1 -0
  266. package/out/it/adapters/miur-scuole/adapter.d.ts +9 -0
  267. package/out/it/adapters/miur-scuole/adapter.d.ts.map +1 -0
  268. package/out/it/adapters/miur-scuole/adapter.js +35 -0
  269. package/out/it/adapters/miur-scuole/adapter.js.map +1 -0
  270. package/out/it/evaluation/miur-scuole.d.ts +53 -0
  271. package/out/it/evaluation/miur-scuole.d.ts.map +1 -0
  272. package/out/it/evaluation/miur-scuole.js +68 -0
  273. package/out/it/evaluation/miur-scuole.js.map +1 -0
  274. package/out/jp/adapters/wof-admin/adapter.js +4 -4
  275. package/out/nc/adapters/opt-nc/adapter.d.ts +84 -0
  276. package/out/nc/adapters/opt-nc/adapter.d.ts.map +1 -0
  277. package/out/nc/adapters/opt-nc/adapter.js +173 -0
  278. package/out/nc/adapters/opt-nc/adapter.js.map +1 -0
  279. package/out/nc/structures/opt-nc.d.ts +12 -0
  280. package/out/nc/structures/opt-nc.d.ts.map +1 -0
  281. package/out/nc/structures/opt-nc.js +64 -0
  282. package/out/nc/structures/opt-nc.js.map +1 -0
  283. package/out/nc/tools/fetch/opt-nc.d.ts +81 -0
  284. package/out/nc/tools/fetch/opt-nc.d.ts.map +1 -0
  285. package/out/nc/tools/fetch/opt-nc.js +162 -0
  286. package/out/nc/tools/fetch/opt-nc.js.map +1 -0
  287. package/out/nz/adapters/charities-register/adapter.d.ts +9 -0
  288. package/out/nz/adapters/charities-register/adapter.d.ts.map +1 -0
  289. package/out/nz/adapters/charities-register/adapter.js +36 -0
  290. package/out/nz/adapters/charities-register/adapter.js.map +1 -0
  291. package/out/nz/evaluation/charities-register.d.ts +60 -0
  292. package/out/nz/evaluation/charities-register.d.ts.map +1 -0
  293. package/out/nz/evaluation/charities-register.js +84 -0
  294. package/out/nz/evaluation/charities-register.js.map +1 -0
  295. package/out/recipes/bare/postcode.d.ts +2 -1
  296. package/out/recipes/bare/postcode.d.ts.map +1 -1
  297. package/out/recipes/bare/postcode.js +14 -11
  298. package/out/recipes/bare/postcode.js.map +1 -1
  299. package/out/recipes/deepseek/batches.d.ts +11 -1
  300. package/out/recipes/deepseek/batches.d.ts.map +1 -1
  301. package/out/recipes/deepseek/batches.js +8 -7
  302. package/out/recipes/deepseek/batches.js.map +1 -1
  303. package/out/recipes/po/box/cedex/recipe.d.ts.map +1 -1
  304. package/out/recipes/po/box/cedex/recipe.js +12 -1
  305. package/out/recipes/po/box/cedex/recipe.js.map +1 -1
  306. package/out/recipes/po/box/cedex/us.d.ts +12 -0
  307. package/out/recipes/po/box/cedex/us.d.ts.map +1 -1
  308. package/out/recipes/po/box/cedex/us.js +36 -2
  309. package/out/recipes/po/box/cedex/us.js.map +1 -1
  310. package/out/recipes/scaffold.d.ts +1 -1
  311. package/out/recipes/sources.d.ts.map +1 -1
  312. package/out/recipes/sources.js +16 -0
  313. package/out/recipes/sources.js.map +1 -1
  314. package/out/recipes.d.ts.map +1 -1
  315. package/out/recipes.js +2 -0
  316. package/out/recipes.js.map +1 -1
  317. package/out/registers.d.ts +28 -2
  318. package/out/registers.d.ts.map +1 -1
  319. package/out/registers.js +28 -2
  320. package/out/registers.js.map +1 -1
  321. package/out/{post-offices → structures}/source.d.ts +34 -16
  322. package/out/structures/source.d.ts.map +1 -0
  323. package/out/structures/source.js +39 -0
  324. package/out/structures/source.js.map +1 -0
  325. package/out/structures/sources.d.ts +6 -0
  326. package/out/structures/sources.d.ts.map +1 -0
  327. package/out/structures/sources.js +23 -0
  328. package/out/structures/sources.js.map +1 -0
  329. package/out/synthesizers/house-venue.d.ts.map +1 -1
  330. package/out/synthesizers/house-venue.js +2 -1
  331. package/out/synthesizers/house-venue.js.map +1 -1
  332. package/out/synthesizers/tail.d.ts +15 -1
  333. package/out/synthesizers/tail.d.ts.map +1 -1
  334. package/out/synthesizers/tail.js +8 -3
  335. package/out/synthesizers/tail.js.map +1 -1
  336. package/out/tools/audit.js +1 -1
  337. package/out/tools/audit.js.map +1 -1
  338. package/out/tools/fetch/storage.d.ts +10 -2
  339. package/out/tools/fetch/storage.d.ts.map +1 -1
  340. package/out/tools/fetch/storage.js +18 -4
  341. package/out/tools/fetch/storage.js.map +1 -1
  342. package/out/tools/fetch.d.ts +10 -2
  343. package/out/tools/fetch.d.ts.map +1 -1
  344. package/out/tools/fetch.js +10 -2
  345. package/out/tools/fetch.js.map +1 -1
  346. package/out/tools/overlay/kryptonite.d.ts.map +1 -1
  347. package/out/tools/overlay/kryptonite.js +5 -2
  348. package/out/tools/overlay/kryptonite.js.map +1 -1
  349. package/out/tools/overlay/split/attribute.d.ts +7 -1
  350. package/out/tools/overlay/split/attribute.d.ts.map +1 -1
  351. package/out/tools/overlay/split/attribute.js +4 -1
  352. package/out/tools/overlay/split/attribute.js.map +1 -1
  353. package/out/tools/overlay/split/overlay.d.ts +10 -0
  354. package/out/tools/overlay/split/overlay.d.ts.map +1 -1
  355. package/out/tools/overlay/split/overlay.js +17 -4
  356. package/out/tools/overlay/split/overlay.js.map +1 -1
  357. package/out/tools/postcode/triples.js +3 -3
  358. package/out/tools/postcode/triples.js.map +1 -1
  359. package/out/tools/region-slot-census.run.d.ts +2 -0
  360. package/out/tools/region-slot-census.run.d.ts.map +1 -0
  361. package/out/tools/region-slot-census.run.js +134 -0
  362. package/out/tools/region-slot-census.run.js.map +1 -0
  363. package/out/training/config/load.d.ts.map +1 -1
  364. package/out/training/config/load.js +10 -0
  365. package/out/training/config/load.js.map +1 -1
  366. package/out/training/config/schema.d.ts +13 -0
  367. package/out/training/config/schema.d.ts.map +1 -1
  368. package/out/training/config/schema.js +6 -0
  369. package/out/training/config/schema.js.map +1 -1
  370. package/out/tw/registers.d.ts +9 -0
  371. package/out/tw/registers.d.ts.map +1 -1
  372. package/out/tw/registers.js +11 -4
  373. package/out/tw/registers.js.map +1 -1
  374. package/out/tw/structures/chunghwa-post.d.ts +39 -0
  375. package/out/tw/structures/chunghwa-post.d.ts.map +1 -0
  376. package/out/tw/structures/chunghwa-post.js +150 -0
  377. package/out/tw/structures/chunghwa-post.js.map +1 -0
  378. package/out/tw/tools/fetch/chunghwa-post.d.ts +55 -0
  379. package/out/tw/tools/fetch/chunghwa-post.d.ts.map +1 -0
  380. package/out/tw/tools/fetch/chunghwa-post.js +110 -0
  381. package/out/tw/tools/fetch/chunghwa-post.js.map +1 -0
  382. package/out/us/adapters/state/ny-notaries/adapter.d.ts.map +1 -1
  383. package/out/us/adapters/state/ny-notaries/adapter.js +7 -2
  384. package/out/us/adapters/state/ny-notaries/adapter.js.map +1 -1
  385. package/out/us/adapters/state/tx-notaries/adapter.d.ts +42 -0
  386. package/out/us/adapters/state/tx-notaries/adapter.d.ts.map +1 -1
  387. package/out/us/adapters/state/tx-notaries/adapter.js +92 -19
  388. package/out/us/adapters/state/tx-notaries/adapter.js.map +1 -1
  389. package/out/us/adapters/usgov/nad/adapter.d.ts +35 -2
  390. package/out/us/adapters/usgov/nad/adapter.d.ts.map +1 -1
  391. package/out/us/adapters/usgov/nad/adapter.js +90 -27
  392. package/out/us/adapters/usgov/nad/adapter.js.map +1 -1
  393. package/out/us/adapters/usgov/nppes/adapter.d.ts.map +1 -1
  394. package/out/us/adapters/usgov/nppes/adapter.js +8 -11
  395. package/out/us/adapters/usgov/nppes/adapter.js.map +1 -1
  396. package/out/us/adapters/usgov/usgs-structures/adapter.d.ts +87 -0
  397. package/out/us/adapters/usgov/usgs-structures/adapter.d.ts.map +1 -0
  398. package/out/us/adapters/usgov/{usgs-post-offices → usgs-structures}/adapter.js +36 -27
  399. package/out/us/adapters/usgov/usgs-structures/adapter.js.map +1 -0
  400. package/out/us/recipes/county.d.ts +124 -0
  401. package/out/us/recipes/county.d.ts.map +1 -0
  402. package/out/us/recipes/county.js +295 -0
  403. package/out/us/recipes/county.js.map +1 -0
  404. package/out/us/street-unit.d.ts +10 -3
  405. package/out/us/street-unit.d.ts.map +1 -1
  406. package/out/us/street-unit.js +14 -6
  407. package/out/us/street-unit.js.map +1 -1
  408. package/out/us/structures/usgs/layers.d.ts +57 -0
  409. package/out/us/structures/usgs/layers.d.ts.map +1 -0
  410. package/out/us/structures/usgs/layers.js +121 -0
  411. package/out/us/structures/usgs/layers.js.map +1 -0
  412. package/out/us/structures/usgs/national-map.d.ts +14 -0
  413. package/out/us/structures/usgs/national-map.d.ts.map +1 -0
  414. package/out/us/{post-offices/usgs-national-map.js → structures/usgs/national-map.js} +16 -14
  415. package/out/us/structures/usgs/national-map.js.map +1 -0
  416. package/out/us/tools/fetch/usgs/gnis.d.ts +118 -0
  417. package/out/us/tools/fetch/usgs/gnis.d.ts.map +1 -0
  418. package/out/us/tools/fetch/usgs/gnis.js +177 -0
  419. package/out/us/tools/fetch/usgs/gnis.js.map +1 -0
  420. package/out/us/tools/fetch/usgs/structures.d.ts +99 -0
  421. package/out/us/tools/fetch/usgs/structures.d.ts.map +1 -0
  422. package/out/us/tools/fetch/usgs/structures.js +233 -0
  423. package/out/us/tools/fetch/usgs/structures.js.map +1 -0
  424. package/out/utils/align.js.map +1 -1
  425. package/out/utils/evaluation-groups.d.ts +98 -0
  426. package/out/utils/evaluation-groups.d.ts.map +1 -0
  427. package/out/utils/evaluation-groups.js +92 -0
  428. package/out/utils/evaluation-groups.js.map +1 -0
  429. package/out/utils/split.d.ts +26 -1
  430. package/out/utils/split.d.ts.map +1 -1
  431. package/out/utils/split.js +28 -3
  432. package/out/utils/split.js.map +1 -1
  433. package/out/utils/tokenize.d.ts +3 -3
  434. package/out/utils/tokenize.d.ts.map +1 -1
  435. package/out/utils/tokenize.js.map +1 -1
  436. package/out/utils/validation-groups.d.ts +168 -0
  437. package/out/utils/validation-groups.d.ts.map +1 -0
  438. package/out/utils/validation-groups.js +135 -0
  439. package/out/utils/validation-groups.js.map +1 -0
  440. package/out/utils/wof-json.d.ts +31 -57
  441. package/out/utils/wof-json.d.ts.map +1 -1
  442. package/out/utils/wof-json.js +81 -98
  443. package/out/utils/wof-json.js.map +1 -1
  444. package/package.json +18 -18
  445. package/lib/adapters/wof/record-cache.ts +0 -118
  446. package/lib/build/heap.ts +0 -60
  447. package/lib/post-offices/sources.ts +0 -18
  448. package/lib/us/post-offices/usgs-national-map.ts +0 -89
  449. package/lib/us/tools/fetch/usgs-post-offices.ts +0 -362
  450. package/out/adapters/wof/record-cache.d.ts +0 -22
  451. package/out/adapters/wof/record-cache.d.ts.map +0 -1
  452. package/out/adapters/wof/record-cache.js +0 -89
  453. package/out/adapters/wof/record-cache.js.map +0 -1
  454. package/out/build/heap.d.ts +0 -26
  455. package/out/build/heap.d.ts.map +0 -1
  456. package/out/build/heap.js +0 -52
  457. package/out/build/heap.js.map +0 -1
  458. package/out/post-offices/source.d.ts.map +0 -1
  459. package/out/post-offices/source.js +0 -21
  460. package/out/post-offices/source.js.map +0 -1
  461. package/out/post-offices/sources.d.ts +0 -13
  462. package/out/post-offices/sources.d.ts.map +0 -1
  463. package/out/post-offices/sources.js +0 -8
  464. package/out/post-offices/sources.js.map +0 -1
  465. package/out/us/adapters/usgov/usgs-post-offices/adapter.d.ts +0 -66
  466. package/out/us/adapters/usgov/usgs-post-offices/adapter.d.ts.map +0 -1
  467. package/out/us/adapters/usgov/usgs-post-offices/adapter.js.map +0 -1
  468. package/out/us/post-offices/usgs-national-map.d.ts +0 -14
  469. package/out/us/post-offices/usgs-national-map.d.ts.map +0 -1
  470. package/out/us/post-offices/usgs-national-map.js.map +0 -1
  471. package/out/us/tools/fetch/usgs-post-offices.d.ts +0 -99
  472. package/out/us/tools/fetch/usgs-post-offices.d.ts.map +0 -1
  473. package/out/us/tools/fetch/usgs-post-offices.js +0 -246
  474. package/out/us/tools/fetch/usgs-post-offices.js.map +0 -1
@@ -0,0 +1,292 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
4
+ /**
5
+ * @file The validation groups of the evaluation-group policy, chosen by a per-country quota.
6
+ *
7
+ * Under the evaluation-group policy (HOLDOUT_AND_EVALUATION section 4.6) `val` holds only what the trainer's
8
+ * validation loss and the launch preflight's validation audits read. For each country the quota walks the
9
+ * groups of the holdout policy's held-out places in the order of their group hash, lowest first, and takes
10
+ * groups until the country reaches its target rows and target street rows, or the cap. A country whose whole
11
+ * pool is under its target keeps the pool.
12
+ *
13
+ * A target is `min(cap, max(margin × floor, minimum))`, the floor being the training config's
14
+ * `required_validation_coverage` entry for the country. The street target is `min(cap, margin × street floor)`.
15
+ * The quota parameters and the list's sha256 join the split policy hash.
16
+ */
17
+
18
+ import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
19
+ import { sha256File } from "@mailwoman/core/hash"
20
+
21
+ import {
22
+ type EvaluationGroups,
23
+ type EvaluationGroupsIdentity,
24
+ evaluationGroupsIdentity,
25
+ readEvaluationGroups,
26
+ } from "#utils/evaluation-groups"
27
+ import { hashUint32 } from "#utils/split"
28
+
29
+ /**
30
+ * The attribute name a validation-group file declares.
31
+ */
32
+ export const VALIDATION_GROUPS_ATTRIBUTE = "validation-groups"
33
+
34
+ /**
35
+ * The quota's parameters.
36
+ */
37
+ export interface ValidationQuota {
38
+ /**
39
+ * The multiple of a country's validation floor its target asks for.
40
+ */
41
+ margin: number
42
+ /**
43
+ * The rows every country with a held-out pool aims at, floor or none.
44
+ */
45
+ minimumRows: number
46
+ /**
47
+ * The most rows one country's validation groups may hold.
48
+ */
49
+ capRows: number
50
+ }
51
+
52
+ /**
53
+ * The quota the v0.8.19 corpus is split under.
54
+ */
55
+ export const DEFAULT_VALIDATION_QUOTA: ValidationQuota = { margin: 2, minimumRows: 200, capRows: 20_000 }
56
+
57
+ /**
58
+ * A country's validation floor, as the training config states it.
59
+ */
60
+ export interface ValidationFloor {
61
+ minRows: number
62
+ minStreetRows: number
63
+ }
64
+
65
+ /**
66
+ * A country's quota target.
67
+ */
68
+ export interface ValidationTarget {
69
+ rows: number
70
+ streetRows: number
71
+ }
72
+
73
+ /**
74
+ * The target of one country under a quota: `min(cap, max(margin × floor, minimum))` rows
75
+ * and `min(cap, margin × street floor)` street rows.
76
+ * A country without a floor aims at the minimum.
77
+ */
78
+ export function validationTarget(floor: ValidationFloor | undefined, quota: ValidationQuota): ValidationTarget {
79
+ return {
80
+ rows: Math.min(quota.capRows, Math.max(Math.ceil(quota.margin * (floor?.minRows ?? 0)), quota.minimumRows)),
81
+ streetRows: Math.min(quota.capRows, Math.ceil(quota.margin * (floor?.minStreetRows ?? 0))),
82
+ }
83
+ }
84
+
85
+ /**
86
+ * One group of a country's held-out pool.
87
+ */
88
+ export interface ValidationCandidate {
89
+ country: string
90
+ group: string
91
+ rows: number
92
+ streetRows: number
93
+ }
94
+
95
+ /**
96
+ * What the quota took from one country.
97
+ */
98
+ export interface ValidationCountrySelection {
99
+ target: ValidationTarget
100
+ /**
101
+ * The country's held-out pool, as far as the caller read it.
102
+ */
103
+ poolRows: number
104
+ poolGroups: number
105
+ rows: number
106
+ streetRows: number
107
+ groups: number
108
+ /**
109
+ * The pool ran out before the target was met, so the country keeps all of it.
110
+ */
111
+ exhausted: boolean
112
+ }
113
+
114
+ /**
115
+ * Takes each country's groups lowest `hashUint32` first, ties broken by the group string,
116
+ * until the country holds its target rows and street rows or reaches the cap.
117
+ *
118
+ * A caller may pass only the head of a country's pool in hash order, as long as the head reaches the cap.
119
+ * `poolRows` and `poolGroups` then describe that head, and the caller records the whole pool's figures.
120
+ */
121
+ export function selectValidationGroups(
122
+ candidates: Iterable<ValidationCandidate>,
123
+ targetOf: (country: string) => ValidationTarget,
124
+ quota: ValidationQuota
125
+ ): { groups: string[]; countries: Record<string, ValidationCountrySelection> } {
126
+ const byCountry = Map.groupBy(candidates, (candidate) => candidate.country)
127
+ const groups: string[] = []
128
+ const countries: Record<string, ValidationCountrySelection> = {}
129
+
130
+ for (const country of [...byCountry.keys()].toSorted()) {
131
+ const pool = byCountry
132
+ .get(country)!
133
+ .map((candidate) => ({ ...candidate, hash: hashUint32(candidate.group) }))
134
+ .toSorted((a, b) => a.hash - b.hash || (a.group < b.group ? -1 : a.group > b.group ? 1 : 0))
135
+
136
+ const target = targetOf(country)
137
+
138
+ const selection: ValidationCountrySelection = {
139
+ target,
140
+ poolRows: pool.reduce((sum, candidate) => sum + candidate.rows, 0),
141
+ poolGroups: pool.length,
142
+ rows: 0,
143
+ streetRows: 0,
144
+ groups: 0,
145
+ exhausted: false,
146
+ }
147
+
148
+ for (const candidate of pool) {
149
+ const met = selection.rows >= target.rows && selection.streetRows >= target.streetRows
150
+
151
+ if (met || selection.rows >= quota.capRows) break
152
+
153
+ groups.push(candidate.group)
154
+ selection.rows += candidate.rows
155
+ selection.streetRows += candidate.streetRows
156
+
157
+ selection.groups++
158
+ }
159
+
160
+ selection.exhausted =
161
+ selection.groups === pool.length && (selection.rows < target.rows || selection.streetRows < target.streetRows)
162
+
163
+ countries[country] = selection
164
+ }
165
+
166
+ return { groups: groups.toSorted(), countries }
167
+ }
168
+
169
+ /**
170
+ * The file a quota pass writes beside the corpus it measured.
171
+ */
172
+ export interface ValidationGroupsFile {
173
+ attribute: typeof VALIDATION_GROUPS_ATTRIBUTE
174
+ /**
175
+ * The corpus manifest whose held-out pool was read.
176
+ */
177
+ drawnFrom: { manifest: string; sha256: string; corpusVersion: string | null }
178
+ /**
179
+ * The training config whose validation floors set the targets.
180
+ */
181
+ config: { path: string; sha256: string }
182
+ /**
183
+ * The frozen group list the pool excluded.
184
+ */
185
+ evaluationGroups: EvaluationGroupsIdentity
186
+ quota: ValidationQuota
187
+ countries: Record<string, ValidationCountrySelection>
188
+ groups: string[]
189
+ }
190
+
191
+ /**
192
+ * The validation lookup a split applies.
193
+ */
194
+ export interface ValidationGroups {
195
+ path: string
196
+ sha256: string
197
+ quota: ValidationQuota
198
+ /**
199
+ * The frozen list's sha256 the pool excluded.
200
+ */
201
+ evaluationGroupsSHA256: string
202
+ groups: ReadonlySet<string>
203
+ }
204
+
205
+ /**
206
+ * Reads a validation-group file.
207
+ *
208
+ * @throws When the file declares another attribute or records no quota.
209
+ */
210
+ export async function readValidationGroups(path: string): Promise<ValidationGroups> {
211
+ const file = await readLocalJSONFile<ValidationGroupsFile>(path)
212
+
213
+ if (file.attribute !== VALIDATION_GROUPS_ATTRIBUTE || !Array.isArray(file.groups)) {
214
+ throw new Error(`${path} is not a validation-group file`)
215
+ }
216
+
217
+ if (!file.quota || typeof file.evaluationGroups?.sha256 !== "string") {
218
+ throw new Error(`${path} records no quota or no frozen list`)
219
+ }
220
+
221
+ return {
222
+ path,
223
+ sha256: await sha256File(path),
224
+ quota: file.quota,
225
+ evaluationGroupsSHA256: file.evaluationGroups.sha256,
226
+ groups: new Set(file.groups),
227
+ }
228
+ }
229
+
230
+ /**
231
+ * The two lists the evaluation-group policy applies.
232
+ *
233
+ * Frozen groups go to `test` and validation groups go to `val`.
234
+ */
235
+ export interface EvaluationGroupPolicy {
236
+ frozen: EvaluationGroups
237
+ validation: ValidationGroups
238
+ }
239
+
240
+ /**
241
+ * Pairs the two lists, refusing a validation list drawn against another frozen list
242
+ * or one that holds a frozen group, since such a group's rows could take only one split.
243
+ */
244
+ export function evaluationGroupPolicy(frozen: EvaluationGroups, validation: ValidationGroups): EvaluationGroupPolicy {
245
+ if (validation.evaluationGroupsSHA256 !== frozen.sha256) {
246
+ throw new Error(
247
+ `${validation.path} was drawn against frozen list ${validation.evaluationGroupsSHA256}; ` +
248
+ `${frozen.path} has sha256 ${frozen.sha256}`
249
+ )
250
+ }
251
+
252
+ for (const group of validation.groups) {
253
+ if (frozen.groups.has(group)) throw new Error(`${validation.path} lists frozen group ${group}`)
254
+ }
255
+
256
+ return { frozen, validation }
257
+ }
258
+
259
+ /**
260
+ * Reads both lists and pairs them with {@linkcode evaluationGroupPolicy}.
261
+ */
262
+ export async function readEvaluationGroupPolicy(paths: {
263
+ evaluationGroups: string
264
+ validationGroups: string
265
+ }): Promise<EvaluationGroupPolicy> {
266
+ return evaluationGroupPolicy(
267
+ await readEvaluationGroups(paths.evaluationGroups),
268
+ await readValidationGroups(paths.validationGroups)
269
+ )
270
+ }
271
+
272
+ /**
273
+ * What a split policy hash and a corpus manifest record about the policy applied.
274
+ */
275
+ export interface EvaluationGroupPolicyIdentity {
276
+ evaluationGroups: EvaluationGroupsIdentity
277
+ validationGroups: { sha256: string; quota: ValidationQuota; groups: number }
278
+ }
279
+
280
+ /**
281
+ * The identity of a policy: both lists' sha256, the frozen sets, the quota and the group counts.
282
+ */
283
+ export function evaluationGroupPolicyIdentity(policy: EvaluationGroupPolicy): EvaluationGroupPolicyIdentity {
284
+ return {
285
+ evaluationGroups: evaluationGroupsIdentity(policy.frozen),
286
+ validationGroups: {
287
+ sha256: policy.validation.sha256,
288
+ quota: policy.validation.quota,
289
+ groups: policy.validation.groups.size,
290
+ },
291
+ }
292
+ }
@@ -17,11 +17,7 @@
17
17
  import { readLocalJSONFile, readLocalTextFile } from "@mailwoman/core/fs/readers"
18
18
  import { tryParsingJSON } from "@mailwoman/core/json"
19
19
  import { resolveModulePath } from "@mailwoman/core/module/resolvers"
20
- import { compareByScalarValue } from "@mailwoman/core/strings/compare"
21
20
  import { agreedHierarchyAncestors } from "@mailwoman/gazetteer/whosonfirst/hierarchy"
22
- import type { PathBuilderLike } from "path-ts"
23
- import { AsyncSequence } from "spliterator"
24
- import { Globerator } from "spliterator/node/fs"
25
21
 
26
22
  /**
27
23
  * A WOF GeoJSON feature, as published by the per-record bundles.
@@ -74,6 +70,52 @@ export interface WOFRecord {
74
70
  * Empty when the record lists no hierarchy, in which case the parent chain answers.
75
71
  */
76
72
  ancestors: readonly number[]
73
+ /**
74
+ * The countries that lead the record's own ISO 3166 and HASC codes ({@linkcode SUBDIVISION_OF_SOURCES}),
75
+ * where one differs from `country`: `GP` for France's region Guadeloupe (`iso:id` `GP`).
76
+ */
77
+ codeCountries: readonly string[]
78
+ }
79
+
80
+ /**
81
+ * The WOF concordances whose leading two letters are the code of the country a region is a
82
+ * subdivision of: the ISO code and the HASC code (`GF` for French Guiana, `BQ.BO` for Bonaire).
83
+ */
84
+ export const SUBDIVISION_OF_SOURCES = ["iso:id", "iso:code", "hasc:id"] as const
85
+
86
+ const CODE_COUNTRY = /^([A-Z]{2})(?:[-.]|$)/u
87
+
88
+ /**
89
+ * The country code that leads an ISO 3166 or HASC code, `GF` for `GF` and `BQ` for `BQ.BO`
90
+ * or `BQ-BO`, or `null` for a code that leads with none.
91
+ */
92
+ export function codeCountry(code: string): string | null {
93
+ return CODE_COUNTRY.exec(code.toUpperCase())?.[1] ?? null
94
+ }
95
+
96
+ const NO_CODE_COUNTRIES: readonly string[] = Object.freeze([])
97
+
98
+ /**
99
+ * The {@linkcode WOFRecord.codeCountries} of a record's properties.
100
+ */
101
+ function codeCountriesOf(props: Record<string, unknown>, country: string): readonly string[] {
102
+ const concordances = props["wof:concordances"]
103
+
104
+ if (!concordances || typeof concordances !== "object") return NO_CODE_COUNTRIES
105
+ const found = new Set<string>()
106
+
107
+ for (const source of SUBDIVISION_OF_SOURCES) {
108
+ const code = (concordances as Record<string, unknown>)[source]
109
+ const named = typeof code === "string" ? codeCountry(code) : null
110
+
111
+ if (named && named !== country) {
112
+ found.add(named)
113
+ }
114
+ }
115
+
116
+ // An admin run holds millions of records.
117
+ // Most hold no other country's code, so those records share one empty list.
118
+ return found.size ? [...found] : NO_CODE_COUNTRIES
77
119
  }
78
120
 
79
121
  /**
@@ -259,6 +301,7 @@ export function recordFromFeature(feature: WOFFeature, refutedParents: ReadonlyS
259
301
  country,
260
302
  nameVariants: extractNameVariants(props),
261
303
  ancestors: placed ? agreedHierarchyAncestors(id, props["wof:hierarchy"]) : [],
304
+ codeCountries: codeCountriesOf(props, country),
262
305
  }
263
306
  }
264
307
 
@@ -293,61 +336,10 @@ export function isAtOrigin(props: Record<string, unknown>): boolean {
293
336
  return props["geom:latitude"] === 0 && props["geom:longitude"] === 0
294
337
  }
295
338
 
296
- /**
297
- * Stream every canonical GeoJSON file under `repoDir` and yield parsed `WOFRecord`s;
298
- * `repoDir` may be a single cloned `whosonfirst-data-*` repo or a parent holding several
299
- * (the corpus pipeline clones all four into a shared `wof/repos/` root).
300
- *
301
- * `-alt-` siblings are skipped as alternate-geometry exports.
302
- * They do not represent new records.
303
- *
304
- * Per-file errors (unreadable files, malformed JSON, or missing properties) are swallowed
305
- * so one bad file doesn't poison a multi-gigabyte walk.
306
- *
307
- * The libuv threadpool has four workers by default; `UV_THREADPOOL_SIZE` can change that count.
308
- * `parallelMap` reads files concurrently up to the threadpool capacity.
309
- *
310
- * Records are yielded in the code-point order of their absolute paths.
311
- * Code-point order is the byte order of the paths' UTF-8 spellings.
312
- *
313
- * The adapters deduplicate surface strings first-come.
314
- * The yield order therefore decides which record claims a shared name.
315
- *
316
- * The directory listing's own order comes from `opendir` and varies with the filesystem.
317
- * ext4's hashed directory index lists `2.geojson` before `1.geojson`.
318
- * The listing is sorted before the ordered parallel read.
319
- *
320
- * Two hosts that hold the same checkout then yield the same sequence.
321
- */
322
- export async function* walkFeatures(
323
- repoDir: PathBuilderLike,
324
- opts: { signal?: AbortSignal } = {}
325
- ): AsyncIterable<WOFRecord> {
326
- const listed: string[] = await Globerator.from("**/*.geojson", {
327
- cwd: repoDir,
328
- absolute: true,
329
- exclude: ["**/*-alt-*.geojson"],
330
- // Bundle repositories can expose their data through a link.
331
- followSymlinks: true,
332
- signal: opts.signal,
333
- }).toArray()
334
-
335
- const records = AsyncSequence.from<string>(listed.toSorted(compareByScalarValue)).parallelMap(readFeatureRecord, {
336
- ordered: true,
337
- signal: opts.signal,
338
- })
339
-
340
- for await (const rec of records) {
341
- if (rec) {
342
- yield rec
343
- }
344
- }
345
- }
346
-
347
339
  /**
348
340
  * The record one GeoJSON file holds, or `null` when the file is unreadable, malformed or skipped.
349
341
  *
350
- * {@linkcode walkFeatures} reads every file through this, and so does the single-record explorer.
342
+ * The single-record explorer reads its record and ancestors through this.
351
343
  */
352
344
  export async function readFeatureRecord(filePath: string): Promise<WOFRecord | null> {
353
345
  let text: string
@@ -380,25 +372,6 @@ export const ANCESTOR_NAME_TAGS = ["locality", "subregion", "region", "country"]
380
372
  */
381
373
  export type AncestorNames = Partial<Record<(typeof ANCESTOR_NAME_TAGS)[number], string>>
382
374
 
383
- /**
384
- * The ancestor names that each record needs, keyed by `wof:id`.
385
- *
386
- * The predecessor index held one array of record references per record, so a run over the 13,274,691
387
- * admin records of `v0.7.0-de-holdout` allocated 13.3 million arrays alongside the record index.
388
- * This holds at most four strings per record instead.
389
- *
390
- * Each string is the same object the ancestor already holds, so the index costs
391
- * one small object per record without copying a name.
392
- *
393
- * The adapter's second pass reads only this.
394
- * `wof-postalcode` keeps admin records in its record index solely so postcode ancestry resolves.
395
- * It can release them once this index is built.
396
- *
397
- * Nearest wins: the walk goes upward from the record's parent and the first ancestor
398
- * carrying a tag sets it, matching the `ancestry.find` the builders used.
399
- */
400
- export type AncestorNameIndex = Map<number, AncestorNames>
401
-
402
375
  /**
403
376
  * The nearest ancestor record per tag in {@linkcode ANCESTOR_NAME_TAGS}.
404
377
  *
@@ -408,94 +381,83 @@ export type AncestorNameIndex = Map<number, AncestorNames>
408
381
  export type AncestorRecords = Partial<Record<(typeof ANCESTOR_NAME_TAGS)[number], WOFRecord>>
409
382
 
410
383
  /**
411
- * Resolves {@linkcode AncestorNameIndex} from a record index, keeping each ancestor's `wof:name`.
384
+ * Each ancestor record's `wof:name`, per tag.
412
385
  *
413
- * `wof-postalcode` uses it so that it can release every admin record once the index is built.
386
+ * `wof-postalcode` renders a postcode's hierarchy from these names and reads no other ancestor field.
414
387
  */
415
- export function buildAncestorNameIndex(
416
- byID: ReadonlyMap<number, WOFRecord>,
417
- tagOf: (placetype: string) => string | null | undefined
418
- ): AncestorNameIndex {
419
- const index: AncestorNameIndex = new Map()
420
-
421
- for (const [id, records] of buildAncestorRecordIndex(byID, tagOf)) {
422
- const names: AncestorNames = {}
388
+ export function ancestorNamesOf(records: AncestorRecords): AncestorNames {
389
+ const names: AncestorNames = {}
423
390
 
424
- for (const tag of ANCESTOR_NAME_TAGS) {
425
- const name = records[tag]?.name
391
+ for (const tag of ANCESTOR_NAME_TAGS) {
392
+ const name = records[tag]?.name
426
393
 
427
- if (name) {
428
- names[tag] = name
429
- }
394
+ if (name) {
395
+ names[tag] = name
430
396
  }
431
-
432
- index.set(id, names)
433
397
  }
434
398
 
435
- return index
399
+ return names
436
400
  }
437
401
 
438
402
  /**
439
- * Resolves the nearest ancestor record per tag for every record in `byID`.
403
+ * The nearest ancestor record per tag in {@linkcode ANCESTOR_NAME_TAGS} for one record.
440
404
  *
405
+ * `lookup` returns a record the reader kept, or `undefined`.
441
406
  * `tagOf` maps a WOF placetype to a component tag, or returns a value outside
442
407
  * {@linkcode ANCESTOR_NAME_TAGS} for a placetype no builder looks up.
408
+ *
443
409
  * It is a parameter because `placetypeToTag` lives with the adapters and this module doesn't import them.
444
410
  *
445
- * The walk stops at the first `parent_id` absent from `byID`, and a cycle guard halts at any re-visit.
446
- * WOF data is acyclic by construction.
447
- * The guard keeps a corrupt fixture from looping the adapter.
411
+ * The `wof:hierarchy` levels are read first, then the parent chain.
412
+ * The chain stops at the first id `lookup` cannot return, and at any re-visit.
413
+ * Only a corrupt fixture holds a cycle.
448
414
  *
449
415
  * A record whose ancestors are absent resolves the tags it can reach rather than failing.
416
+ *
417
+ * An ancestor in another country claims no tag, unless its own ISO or HASC code leads with
418
+ * the record's country, as France's region Guadeloupe (`GP`) does for a record in `GP`.
419
+ * A row takes its country from the record, so any other such ancestor would write another country's
420
+ * region under it: WOF files Monaco's quarters under Alpes-Maritimes and Macau's under Guangdong.
450
421
  */
451
- export function buildAncestorRecordIndex(
452
- byID: ReadonlyMap<number, WOFRecord>,
422
+ export function ancestorRecordsOf(
423
+ rec: WOFRecord,
424
+ lookup: (id: number) => WOFRecord | undefined,
453
425
  tagOf: (placetype: string) => string | null | undefined
454
- ): Map<number, AncestorRecords> {
455
- const index = new Map<number, AncestorRecords>()
426
+ ): AncestorRecords {
427
+ const names: AncestorRecords = {}
456
428
 
457
- for (const [id, rec] of byID) {
458
- const names: AncestorRecords = {}
429
+ const claim = (ancestor: WOFRecord): void => {
430
+ if (ancestor.country !== rec.country && !ancestor.codeCountries.includes(rec.country)) return
459
431
 
460
- // `wof:hierarchy` names every ancestor level directly, including for a record whose parent is -4.
461
- for (const ancestorID of rec.ancestors) {
462
- const ancestor = byID.get(ancestorID)
432
+ const tag = tagOf(ancestor.placetype)
463
433
 
464
- if (!ancestor) continue
465
-
466
- const tag = tagOf(ancestor.placetype)
467
-
468
- for (const wanted of ANCESTOR_NAME_TAGS) {
469
- if (tag === wanted && !names[wanted]) {
470
- names[wanted] = ancestor
471
- }
434
+ for (const wanted of ANCESTOR_NAME_TAGS) {
435
+ if (tag === wanted && !names[wanted]) {
436
+ names[wanted] = ancestor
472
437
  }
473
438
  }
439
+ }
474
440
 
475
- const guard = new Set<number>([id])
476
- let cur: number | null = rec.parent_id
477
-
478
- while (cur !== null && cur > 0) {
479
- const parent = byID.get(cur)
480
-
481
- if (!parent) break
482
-
483
- if (guard.has(parent.id)) break
441
+ // `wof:hierarchy` names every ancestor level directly, including for a record whose parent is -4.
442
+ for (const ancestorID of rec.ancestors) {
443
+ const ancestor = lookup(ancestorID)
484
444
 
485
- const tag = tagOf(parent.placetype)
445
+ if (ancestor) {
446
+ claim(ancestor)
447
+ }
448
+ }
486
449
 
487
- for (const wanted of ANCESTOR_NAME_TAGS) {
488
- if (tag === wanted && !names[wanted]) {
489
- names[wanted] = parent
490
- }
491
- }
450
+ const guard = new Set<number>([rec.id])
451
+ let cur: number | null = rec.parent_id
492
452
 
493
- guard.add(parent.id)
494
- cur = parent.parent_id
495
- }
453
+ while (cur !== null && cur > 0) {
454
+ const parent = lookup(cur)
496
455
 
497
- index.set(id, names)
456
+ if (!parent || guard.has(parent.id)) break
457
+ claim(parent)
458
+ guard.add(parent.id)
459
+ cur = parent.parent_id
498
460
  }
499
461
 
500
- return index
462
+ return names
501
463
  }
@@ -160,8 +160,10 @@ export declare function naturalPersonForm(name: string, shortName: string, lexic
160
160
  *
161
161
  * `order` is `null` for a country with no unambiguous side, and such a line
162
162
  * is kept only where it holds no digit.
163
+ * In a `country` that writes a repetition index, `20 BIS RUE LOUIS PHILIPPE` yields the house number
164
+ * `20 BIS` and the street `RUE LOUIS PHILIPPE`, as {@linkcode joinRepetitionIndex} reads it.
163
165
  */
164
- export declare function splitCORDISStreetLine(line: string, order: StreetOrder | null): SplitStreetLine | {
166
+ export declare function splitCORDISStreetLine(line: string, order: StreetOrder | null, country?: string): SplitStreetLine | {
165
167
  refused: CORDISRefusal;
166
168
  } | null;
167
169
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../lib/adapters/cordis/adapter.ts"],"names":[],"mappings":"AAkIA,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAM3D,OAAO,EAA4C,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACtG,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAG7E,OAAO,EAGN,KAAK,YAAY,EACjB,KAAK,aAAa,EAGlB,MAAM,QAAQ,CAAA;AAEf;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,WAAW,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,cAAc,cAAc,CAAA;AAEzC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,8EAAyE,CAAA;AAExG;;GAEG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAA;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,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AI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAKjF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,wBAAwB,EAChC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,YAAY,GACjB,aAAa,CA8Ff;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAA;IACzC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;CAC/B;AAED;;;;;;;;;GASG;AACH,wBAAuB,iBAAiB,CACvC,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,iBAAiB,EAC1B,OAAO,GAAE;IACR,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC9B,WAAW,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;CAC/B,GACJ,cAAc,CAAC,mBAAmB,CAAC,CAwCrC;AAwED,wBAAgB,mBAAmB,IAAI,aAAa,CA6DnD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,eAAwB,CAAA"}
@@ -132,6 +132,7 @@ import { Globerator } from "spliterator/node/fs";
132
132
  import { loadLibpostalDictionary } from "#adapters/libpostal-dictionary";
133
133
  import { stableSourceID } from "#adapters/source-id";
134
134
  import { splitStreetLine, splitTrailingStreetLine } from "#adapters/street/line";
135
+ import { joinRepetitionIndex } from "#adapters/street/repetition";
135
136
  import { createUnitSplitter } from "#adapters/street/unit";
136
137
  import { SourceRegister } from "#registers";
137
138
  import { streetIndexOpener } from "#street-index/reader";
@@ -387,8 +388,10 @@ const LEADING_NUMBER_COMMA = /^(\d+[\p{L}]?),\s*/u;
387
388
  *
388
389
  * `order` is `null` for a country with no unambiguous side, and such a line
389
390
  * is kept only where it holds no digit.
391
+ * In a `country` that writes a repetition index, `20 BIS RUE LOUIS PHILIPPE` yields the house number
392
+ * `20 BIS` and the street `RUE LOUIS PHILIPPE`, as {@linkcode joinRepetitionIndex} reads it.
390
393
  */
391
- export function splitCORDISStreetLine(line, order) {
394
+ export function splitCORDISStreetLine(line, order, country) {
392
395
  const trimmed = line
393
396
  .replaceAll(/\s+/gu, " ")
394
397
  .replace(/[\s,.;]+$/u, "")
@@ -401,6 +404,9 @@ export function splitCORDISStreetLine(line, order) {
401
404
  let split = { street: trimmed };
402
405
  if (order === StreetOrder.NumberFirst) {
403
406
  split = splitStreetLine(trimmed.replace(LEADING_NUMBER_COMMA, "$1 "));
407
+ if (split && country) {
408
+ split = joinRepetitionIndex(split, country);
409
+ }
404
410
  }
405
411
  else if (order === StreetOrder.NumberLast) {
406
412
  split = splitTrailingStreetLine(trimmed);
@@ -451,7 +457,7 @@ export function readCORDISRecord(record, lexicon, units) {
451
457
  // A unit at the end of the line (`BD SAINT-JACQUES BATIMENT B`) comes off first,
452
458
  // so its identifier is never read as the house number.
453
459
  const lineUnit = units.split(streetLine, { country, locality, postcode: fieldValue(record.postCode) });
454
- const split = splitCORDISStreetLine(lineUnit?.street ?? streetLine, streetOrderForCountry(country));
460
+ const split = splitCORDISStreetLine(lineUnit?.street ?? streetLine, streetOrderForCountry(country), country);
455
461
  if (split && "refused" in split)
456
462
  return { refused: split.refused, country };
457
463
  if (split?.house_number) {