@mailwoman/corpus 11.3.0 → 11.5.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 (352) hide show
  1. package/data/PROVENANCE.md +3 -4
  2. package/data/address-source-register.json +12 -4
  3. package/data/builds/v0.8.22-nz-overlay/OVERLAY_PLAN.json +19 -0
  4. package/data/builds/v0.8.23-overlay/OVERLAY_PLAN.json +3656 -0
  5. package/data/builds/v0.8.23-prominent-overlay/OVERLAY_PLAN.json +42 -0
  6. package/data/builds/v0.8.23-rebuild/inputs.json +141 -0
  7. package/data/builds/v0.8.24-rebuild/inputs.json +111 -0
  8. package/data/corpus-source-inputs.json +95 -1
  9. package/data/holdout/evaluation-groups.v0.8.24.json +222158 -0
  10. package/data/license-decisions.json +14 -1
  11. package/data/region-slot-second-level.json +1 -1
  12. package/data/training-configs/v8.11.0-base-c6-90k-v0823-s42.yaml +920 -0
  13. package/data/training-configs/v8.12.0-base-c6-wofreps-v0823-s42.yaml +944 -0
  14. package/data/training-configs/v8.13.0-base-c6-wofreps-v0822-s42.yaml +918 -0
  15. package/data/training-configs/v8.14.0-base-c6-wofreps-cursor-v0822-s42.yaml +926 -0
  16. package/data/training-configs/v8.15.0-base-c6-wofreps-cursor-emit-v0822-s42.yaml +973 -0
  17. package/data/training-configs/v8.16.0-base-c6-wofreps-positions-v0822-s42.yaml +988 -0
  18. package/data/training-configs/v8.19.0-nz-v0822-s42.yaml +870 -0
  19. package/data/training-manifests/v0.8.22-nz-overlay.effective.json +2556 -0
  20. package/data/training-manifests/v0.8.22-nz-overlay.json +9000 -0
  21. package/lib/adapters/cordis/adapter.ts +3 -2
  22. package/lib/adapters/gleif/adapter.ts +123 -20
  23. package/lib/adapters/openaddresses/adapter.ts +2 -2
  24. package/lib/adapters/osm/adapter.ts +62 -4
  25. package/lib/adapters/overture/adapter.ts +97 -15
  26. package/lib/adapters/overture/address-key.ts +89 -0
  27. package/lib/adapters/overture/places-in/adapter.ts +258 -0
  28. package/lib/adapters/street/convention.ts +49 -0
  29. package/lib/adapters/street/country-line.ts +65 -0
  30. package/lib/adapters/wof/admin/json/adapter.ts +4 -4
  31. package/lib/adapters/wof/admin/json/region-codes.ts +98 -0
  32. package/lib/adapters/wof/json-rows.ts +2 -2
  33. package/lib/adapters.ts +2 -0
  34. package/lib/build/align/range.ts +21 -11
  35. package/lib/build/align/totals.ts +20 -0
  36. package/lib/build/align.ts +218 -20
  37. package/lib/build/budget.ts +55 -20
  38. package/lib/build/checkpoint.ts +9 -0
  39. package/lib/build/component-check.ts +97 -3
  40. package/lib/build/inputs.ts +122 -31
  41. package/lib/build/manifest.ts +1 -0
  42. package/lib/build/parallel.ts +140 -23
  43. package/lib/build/{region-names.ts → region/names.ts} +16 -4
  44. package/lib/build/region/recount.ts +153 -0
  45. package/lib/build/reuse.ts +112 -0
  46. package/lib/build/settings.ts +84 -3
  47. package/lib/build/source-record.ts +45 -8
  48. package/lib/build/types.ts +26 -0
  49. package/lib/build/worker.ts +75 -10
  50. package/lib/build.ts +2 -1
  51. package/lib/de/recipes/locale.ts +9 -3
  52. package/lib/evaluation/corpus-adapter.ts +2 -2
  53. package/lib/fi/adapters/ryhti/adapter.ts +2 -2
  54. package/lib/fo/adapters/adressur/adapter.ts +2 -2
  55. package/lib/fr/recipes/lieudit.ts +3 -4
  56. package/lib/in/street-line/segment.ts +370 -0
  57. package/lib/international/recipes/locale.ts +6 -3
  58. package/lib/li/adapters/llv/adapter.ts +2 -2
  59. package/lib/lu/adapters/bd-adresses/adapter.ts +2 -2
  60. package/lib/no/adapters/matrikkelen/adapter.ts +2 -2
  61. package/lib/parquet/streams.ts +18 -3
  62. package/lib/parquet/writers.ts +161 -29
  63. package/lib/recipes/country-balanced.ts +32 -18
  64. package/lib/recipes/fragment-assay/build.ts +8 -5
  65. package/lib/recipes/fragment-assay/rows.ts +4 -4
  66. package/lib/recipes/house/venue.ts +2 -1
  67. package/lib/recipes/postal/guideline/leg.ts +3 -2
  68. package/lib/recipes/prominent/places.ts +4 -4
  69. package/lib/runner.ts +139 -20
  70. package/lib/sg/recipes/register.ts +6 -1
  71. package/lib/source-register/row-license.ts +12 -2
  72. package/lib/surfaces/corpus-row.ts +84 -0
  73. package/lib/surfaces/locale.ts +20 -24
  74. package/lib/synthesizers/house-venue.ts +33 -40
  75. package/lib/synthesizers/no-street.ts +2 -2
  76. package/lib/synthesizers/po-box.ts +3 -3
  77. package/lib/synthesizers/tail.ts +3 -2
  78. package/lib/synthesizers/utils.ts +95 -56
  79. package/lib/test-kit.ts +50 -1
  80. package/lib/tools/fetch/overture-places-in.ts +118 -0
  81. package/lib/tools/fetch/storage.ts +3 -0
  82. package/lib/tools/fetch.ts +2 -0
  83. package/lib/tools/overlay/manifest.ts +36 -5
  84. package/lib/tools/region-slot-census.run.ts +2 -2
  85. package/lib/training/config/schema.ts +17 -0
  86. package/lib/types.ts +39 -0
  87. package/lib/us/adapters/state/tx-notaries/adapter.ts +2 -1
  88. package/lib/us/adapters/usgov/imls-pls/adapter.ts +2 -1
  89. package/lib/us/adapters/usgov/nad/adapter.ts +40 -7
  90. package/lib/us/adapters/usgov/nad/address-key.ts +8 -47
  91. package/lib/us/adapters/usgov/nppes/adapter.ts +2 -1
  92. package/lib/utils/address-key.ts +57 -0
  93. package/lib/utils/align.ts +22 -10
  94. package/lib/utils/evaluation-groups.ts +13 -6
  95. package/lib/utils/split.ts +24 -3
  96. package/out/adapters/cordis/adapter.d.ts.map +1 -1
  97. package/out/adapters/cordis/adapter.js +3 -2
  98. package/out/adapters/cordis/adapter.js.map +1 -1
  99. package/out/adapters/gleif/adapter.d.ts +4 -0
  100. package/out/adapters/gleif/adapter.d.ts.map +1 -1
  101. package/out/adapters/gleif/adapter.js +100 -20
  102. package/out/adapters/gleif/adapter.js.map +1 -1
  103. package/out/adapters/openaddresses/adapter.js +2 -2
  104. package/out/adapters/openaddresses/adapter.js.map +1 -1
  105. package/out/adapters/osm/adapter.d.ts +9 -0
  106. package/out/adapters/osm/adapter.d.ts.map +1 -1
  107. package/out/adapters/osm/adapter.js +55 -13
  108. package/out/adapters/osm/adapter.js.map +1 -1
  109. package/out/adapters/overture/adapter.d.ts +6 -0
  110. package/out/adapters/overture/adapter.d.ts.map +1 -1
  111. package/out/adapters/overture/adapter.js +72 -9
  112. package/out/adapters/overture/adapter.js.map +1 -1
  113. package/out/adapters/overture/address-key.d.ts +39 -0
  114. package/out/adapters/overture/address-key.d.ts.map +1 -0
  115. package/out/adapters/overture/address-key.js +75 -0
  116. package/out/adapters/overture/address-key.js.map +1 -0
  117. package/out/adapters/overture/places-in/adapter.d.ts +20 -0
  118. package/out/adapters/overture/places-in/adapter.d.ts.map +1 -0
  119. package/out/adapters/overture/places-in/adapter.js +191 -0
  120. package/out/adapters/overture/places-in/adapter.js.map +1 -0
  121. package/out/adapters/street/convention.d.ts +11 -0
  122. package/out/adapters/street/convention.d.ts.map +1 -0
  123. package/out/adapters/street/convention.js +40 -0
  124. package/out/adapters/street/convention.js.map +1 -0
  125. package/out/adapters/street/country-line.d.ts +31 -0
  126. package/out/adapters/street/country-line.d.ts.map +1 -0
  127. package/out/adapters/street/country-line.js +31 -0
  128. package/out/adapters/street/country-line.js.map +1 -0
  129. package/out/adapters/wof/admin/json/adapter.js +4 -4
  130. package/out/adapters/wof/admin/json/adapter.js.map +1 -1
  131. package/out/adapters/wof/admin/json/region-codes.d.ts +5 -0
  132. package/out/adapters/wof/admin/json/region-codes.d.ts.map +1 -1
  133. package/out/adapters/wof/admin/json/region-codes.js +83 -0
  134. package/out/adapters/wof/admin/json/region-codes.js.map +1 -1
  135. package/out/adapters/wof/json-rows.d.ts.map +1 -1
  136. package/out/adapters/wof/json-rows.js +2 -2
  137. package/out/adapters/wof/json-rows.js.map +1 -1
  138. package/out/adapters.d.ts.map +1 -1
  139. package/out/adapters.js +2 -0
  140. package/out/adapters.js.map +1 -1
  141. package/out/build/align/range.d.ts +7 -3
  142. package/out/build/align/range.d.ts.map +1 -1
  143. package/out/build/align/range.js +17 -9
  144. package/out/build/align/range.js.map +1 -1
  145. package/out/build/align/totals.d.ts +12 -0
  146. package/out/build/align/totals.d.ts.map +1 -1
  147. package/out/build/align/totals.js +8 -0
  148. package/out/build/align/totals.js.map +1 -1
  149. package/out/build/align.d.ts +60 -5
  150. package/out/build/align.d.ts.map +1 -1
  151. package/out/build/align.js +136 -12
  152. package/out/build/align.js.map +1 -1
  153. package/out/build/budget.d.ts +35 -11
  154. package/out/build/budget.d.ts.map +1 -1
  155. package/out/build/budget.js +52 -20
  156. package/out/build/budget.js.map +1 -1
  157. package/out/build/checkpoint.d.ts +9 -0
  158. package/out/build/checkpoint.d.ts.map +1 -1
  159. package/out/build/checkpoint.js.map +1 -1
  160. package/out/build/component-check.d.ts +29 -1
  161. package/out/build/component-check.d.ts.map +1 -1
  162. package/out/build/component-check.js +57 -2
  163. package/out/build/component-check.js.map +1 -1
  164. package/out/build/inputs.d.ts +58 -0
  165. package/out/build/inputs.d.ts.map +1 -1
  166. package/out/build/inputs.js +57 -20
  167. package/out/build/inputs.js.map +1 -1
  168. package/out/build/manifest.d.ts.map +1 -1
  169. package/out/build/manifest.js +1 -0
  170. package/out/build/manifest.js.map +1 -1
  171. package/out/build/parallel.d.ts +19 -1
  172. package/out/build/parallel.d.ts.map +1 -1
  173. package/out/build/parallel.js +92 -11
  174. package/out/build/parallel.js.map +1 -1
  175. package/out/build/{region-names.d.ts → region/names.d.ts} +10 -1
  176. package/out/build/region/names.d.ts.map +1 -0
  177. package/out/build/{region-names.js → region/names.js} +16 -5
  178. package/out/build/region/names.js.map +1 -0
  179. package/out/build/region/recount.d.ts +47 -0
  180. package/out/build/region/recount.d.ts.map +1 -0
  181. package/out/build/region/recount.js +105 -0
  182. package/out/build/region/recount.js.map +1 -0
  183. package/out/build/reuse.d.ts +31 -0
  184. package/out/build/reuse.d.ts.map +1 -0
  185. package/out/build/reuse.js +50 -0
  186. package/out/build/reuse.js.map +1 -0
  187. package/out/build/settings.d.ts +38 -0
  188. package/out/build/settings.d.ts.map +1 -1
  189. package/out/build/settings.js +67 -3
  190. package/out/build/settings.js.map +1 -1
  191. package/out/build/source-record.d.ts +32 -7
  192. package/out/build/source-record.d.ts.map +1 -1
  193. package/out/build/source-record.js +17 -4
  194. package/out/build/source-record.js.map +1 -1
  195. package/out/build/types.d.ts +24 -0
  196. package/out/build/types.d.ts.map +1 -1
  197. package/out/build/worker.d.ts +17 -0
  198. package/out/build/worker.d.ts.map +1 -1
  199. package/out/build/worker.js +44 -9
  200. package/out/build/worker.js.map +1 -1
  201. package/out/build.d.ts.map +1 -1
  202. package/out/build.js +2 -1
  203. package/out/build.js.map +1 -1
  204. package/out/de/recipes/locale.d.ts.map +1 -1
  205. package/out/de/recipes/locale.js +9 -3
  206. package/out/de/recipes/locale.js.map +1 -1
  207. package/out/evaluation/corpus-adapter.d.ts +14 -0
  208. package/out/evaluation/corpus-adapter.d.ts.map +1 -1
  209. package/out/evaluation/corpus-adapter.js +2 -16
  210. package/out/evaluation/corpus-adapter.js.map +1 -1
  211. package/out/fi/adapters/ryhti/adapter.js +2 -2
  212. package/out/fi/adapters/ryhti/adapter.js.map +1 -1
  213. package/out/fo/adapters/adressur/adapter.js +2 -2
  214. package/out/fo/adapters/adressur/adapter.js.map +1 -1
  215. package/out/fr/recipes/lieudit.d.ts.map +1 -1
  216. package/out/fr/recipes/lieudit.js +3 -3
  217. package/out/fr/recipes/lieudit.js.map +1 -1
  218. package/out/in/street-line/segment.d.ts +75 -0
  219. package/out/in/street-line/segment.d.ts.map +1 -0
  220. package/out/in/street-line/segment.js +298 -0
  221. package/out/in/street-line/segment.js.map +1 -0
  222. package/out/international/recipes/locale.d.ts.map +1 -1
  223. package/out/international/recipes/locale.js +6 -3
  224. package/out/international/recipes/locale.js.map +1 -1
  225. package/out/li/adapters/llv/adapter.js +2 -2
  226. package/out/li/adapters/llv/adapter.js.map +1 -1
  227. package/out/lu/adapters/bd-adresses/adapter.js +2 -2
  228. package/out/lu/adapters/bd-adresses/adapter.js.map +1 -1
  229. package/out/no/adapters/matrikkelen/adapter.js +2 -2
  230. package/out/no/adapters/matrikkelen/adapter.js.map +1 -1
  231. package/out/parquet/streams.d.ts +9 -0
  232. package/out/parquet/streams.d.ts.map +1 -1
  233. package/out/parquet/streams.js +7 -3
  234. package/out/parquet/streams.js.map +1 -1
  235. package/out/parquet/writers.d.ts +55 -2
  236. package/out/parquet/writers.d.ts.map +1 -1
  237. package/out/parquet/writers.js +109 -27
  238. package/out/parquet/writers.js.map +1 -1
  239. package/out/recipes/country-balanced.d.ts.map +1 -1
  240. package/out/recipes/country-balanced.js +32 -15
  241. package/out/recipes/country-balanced.js.map +1 -1
  242. package/out/recipes/fragment-assay/build.d.ts +5 -2
  243. package/out/recipes/fragment-assay/build.d.ts.map +1 -1
  244. package/out/recipes/fragment-assay/build.js +8 -5
  245. package/out/recipes/fragment-assay/build.js.map +1 -1
  246. package/out/recipes/fragment-assay/rows.d.ts +2 -2
  247. package/out/recipes/fragment-assay/rows.js +4 -4
  248. package/out/recipes/fragment-assay/rows.js.map +1 -1
  249. package/out/recipes/house/venue.d.ts.map +1 -1
  250. package/out/recipes/house/venue.js +2 -1
  251. package/out/recipes/house/venue.js.map +1 -1
  252. package/out/recipes/postal/guideline/leg.d.ts.map +1 -1
  253. package/out/recipes/postal/guideline/leg.js +2 -7
  254. package/out/recipes/postal/guideline/leg.js.map +1 -1
  255. package/out/recipes/prominent/places.js +4 -4
  256. package/out/recipes/prominent/places.js.map +1 -1
  257. package/out/runner.d.ts +28 -0
  258. package/out/runner.d.ts.map +1 -1
  259. package/out/runner.js +85 -18
  260. package/out/runner.js.map +1 -1
  261. package/out/sg/recipes/register.d.ts.map +1 -1
  262. package/out/sg/recipes/register.js +6 -1
  263. package/out/sg/recipes/register.js.map +1 -1
  264. package/out/source-register/row-license.d.ts +8 -0
  265. package/out/source-register/row-license.d.ts.map +1 -1
  266. package/out/source-register/row-license.js +10 -2
  267. package/out/source-register/row-license.js.map +1 -1
  268. package/out/surfaces/corpus-row.d.ts +32 -0
  269. package/out/surfaces/corpus-row.d.ts.map +1 -0
  270. package/out/surfaces/corpus-row.js +70 -0
  271. package/out/surfaces/corpus-row.js.map +1 -0
  272. package/out/surfaces/locale.d.ts.map +1 -1
  273. package/out/surfaces/locale.js +16 -22
  274. package/out/surfaces/locale.js.map +1 -1
  275. package/out/synthesizers/house-venue.d.ts +9 -4
  276. package/out/synthesizers/house-venue.d.ts.map +1 -1
  277. package/out/synthesizers/house-venue.js +25 -35
  278. package/out/synthesizers/house-venue.js.map +1 -1
  279. package/out/synthesizers/no-street.js +2 -9
  280. package/out/synthesizers/no-street.js.map +1 -1
  281. package/out/synthesizers/po-box.js +3 -7
  282. package/out/synthesizers/po-box.js.map +1 -1
  283. package/out/synthesizers/tail.d.ts.map +1 -1
  284. package/out/synthesizers/tail.js +2 -2
  285. package/out/synthesizers/tail.js.map +1 -1
  286. package/out/synthesizers/utils.d.ts +20 -3
  287. package/out/synthesizers/utils.d.ts.map +1 -1
  288. package/out/synthesizers/utils.js +74 -57
  289. package/out/synthesizers/utils.js.map +1 -1
  290. package/out/test-kit.d.ts +11 -0
  291. package/out/test-kit.d.ts.map +1 -1
  292. package/out/test-kit.js +30 -1
  293. package/out/test-kit.js.map +1 -1
  294. package/out/tools/fetch/overture-places-in.d.ts +14 -0
  295. package/out/tools/fetch/overture-places-in.d.ts.map +1 -0
  296. package/out/tools/fetch/overture-places-in.js +82 -0
  297. package/out/tools/fetch/overture-places-in.js.map +1 -0
  298. package/out/tools/fetch/storage.d.ts +2 -0
  299. package/out/tools/fetch/storage.d.ts.map +1 -1
  300. package/out/tools/fetch/storage.js +3 -0
  301. package/out/tools/fetch/storage.js.map +1 -1
  302. package/out/tools/fetch.d.ts +2 -0
  303. package/out/tools/fetch.d.ts.map +1 -1
  304. package/out/tools/fetch.js +2 -0
  305. package/out/tools/fetch.js.map +1 -1
  306. package/out/tools/overlay/manifest.d.ts.map +1 -1
  307. package/out/tools/overlay/manifest.js +29 -5
  308. package/out/tools/overlay/manifest.js.map +1 -1
  309. package/out/tools/region-slot-census.run.js +2 -2
  310. package/out/training/config/schema.d.ts +46 -0
  311. package/out/training/config/schema.d.ts.map +1 -1
  312. package/out/training/config/schema.js +13 -0
  313. package/out/training/config/schema.js.map +1 -1
  314. package/out/types.d.ts +41 -0
  315. package/out/types.d.ts.map +1 -1
  316. package/out/types.js.map +1 -1
  317. package/out/us/adapters/state/tx-notaries/adapter.d.ts.map +1 -1
  318. package/out/us/adapters/state/tx-notaries/adapter.js +2 -1
  319. package/out/us/adapters/state/tx-notaries/adapter.js.map +1 -1
  320. package/out/us/adapters/usgov/imls-pls/adapter.d.ts.map +1 -1
  321. package/out/us/adapters/usgov/imls-pls/adapter.js +2 -1
  322. package/out/us/adapters/usgov/imls-pls/adapter.js.map +1 -1
  323. package/out/us/adapters/usgov/nad/adapter.d.ts +19 -0
  324. package/out/us/adapters/usgov/nad/adapter.d.ts.map +1 -1
  325. package/out/us/adapters/usgov/nad/adapter.js +29 -6
  326. package/out/us/adapters/usgov/nad/adapter.js.map +1 -1
  327. package/out/us/adapters/usgov/nad/address-key.d.ts +1 -5
  328. package/out/us/adapters/usgov/nad/address-key.d.ts.map +1 -1
  329. package/out/us/adapters/usgov/nad/address-key.js +8 -33
  330. package/out/us/adapters/usgov/nad/address-key.js.map +1 -1
  331. package/out/us/adapters/usgov/nppes/adapter.d.ts.map +1 -1
  332. package/out/us/adapters/usgov/nppes/adapter.js +2 -1
  333. package/out/us/adapters/usgov/nppes/adapter.js.map +1 -1
  334. package/out/utils/address-key.d.ts +23 -0
  335. package/out/utils/address-key.d.ts.map +1 -0
  336. package/out/utils/address-key.js +43 -0
  337. package/out/utils/address-key.js.map +1 -0
  338. package/out/utils/align.d.ts +7 -0
  339. package/out/utils/align.d.ts.map +1 -1
  340. package/out/utils/align.js +18 -8
  341. package/out/utils/align.js.map +1 -1
  342. package/out/utils/evaluation-groups.d.ts +5 -1
  343. package/out/utils/evaluation-groups.d.ts.map +1 -1
  344. package/out/utils/evaluation-groups.js +12 -1
  345. package/out/utils/evaluation-groups.js.map +1 -1
  346. package/out/utils/split.d.ts +11 -0
  347. package/out/utils/split.d.ts.map +1 -1
  348. package/out/utils/split.js +18 -3
  349. package/out/utils/split.js.map +1 -1
  350. package/package.json +19 -19
  351. package/out/build/region-names.d.ts.map +0 -1
  352. package/out/build/region-names.js.map +0 -1
@@ -23,7 +23,7 @@ import {
23
23
  readSecondLevelNames,
24
24
  secondLevelAdmitted,
25
25
  type SecondLevelRegionTable,
26
- } from "#build/region-names"
26
+ } from "#build/region/names"
27
27
  import { escapeSQLString, openDuckDB } from "#parquet/duckdb"
28
28
  import { parquetColumnNames } from "#parquet/readers"
29
29
  import { localManifestFilePath } from "#tools/overlay/manifest"
@@ -155,7 +155,7 @@ const table: SecondLevelRegionTable = {
155
155
  $description:
156
156
  "Per country, the base rows with a region and those whose region is a second-level (WOF county) name " +
157
157
  "of the country and no region name of it. Written by packages/corpus/lib/tools/region-slot-census.run.ts; " +
158
- "secondLevelAdmitted in packages/corpus/lib/build/region-names.ts decides which countries the region:unknown rule admits.",
158
+ "secondLevelAdmitted in packages/corpus/lib/build/region/names.ts decides which countries the region:unknown rule admits.",
159
159
  manifest: manifestPath,
160
160
  countries: Object.fromEntries(
161
161
  countries
@@ -61,6 +61,19 @@ const optionalInt = (value: bigint | null = null) => ({
61
61
  output: z.number().int().nullable(),
62
62
  })
63
63
 
64
+ /**
65
+ * The orders the train split can be read in.
66
+ *
67
+ * `mixture` draws each row's source from the weights and shuffles.
68
+ * `stored` reads each positively weighted source's rows once, in the order `source_weights`
69
+ * lists the sources and the corpus stores the rows, and ends the run when the files end.
70
+ */
71
+ export const READ_ORDERS = ["mixture", "stored"] as const
72
+
73
+ export type ReadOrder = (typeof READ_ORDERS)[number]
74
+
75
+ const readOrder = () => ({ annotation: "str", default: (): PythonValue => "mixture", output: z.enum(READ_ORDERS) })
76
+
64
77
  const optionalFloat = () => ({ annotation: "float | None", default: () => null, output: z.number().nullable() })
65
78
  const strList = () => ({ annotation: "list[str]", default: (): PythonValue => [], output: z.array(z.string()) })
66
79
 
@@ -169,12 +182,14 @@ export const DATA_SECTION = {
169
182
  ]),
170
183
  source_weights: optionalFloatMap(),
171
184
  source_reps: optionalFloatMap(),
185
+ source_emit_factors: optionalFloatMap(),
172
186
  unshippable_reason: optionalStr(),
173
187
  required_corpus_receipts: sectionList(CORPUS_RECEIPT_SECTION),
174
188
  required_validation_coverage: sectionList(VALIDATION_COVERAGE_SECTION),
175
189
  required_validation_label_support: sectionList(LABEL_SUPPORT_SECTION),
176
190
  prominent_place_coverage: optionalStr(),
177
191
  train_rows_per_epoch: optionalInt(),
192
+ read_order: readOrder(),
178
193
  val_rows: optionalInt(4096n),
179
194
  coarse_filter: bool(true),
180
195
  augment_directional_prob: float(0),
@@ -303,6 +318,8 @@ export const TRAIN_SECTION = {
303
318
  init_from: str(""),
304
319
  freeze_token_embeddings: bool(false),
305
320
  trainable_only_prefixes: strList(),
321
+ cuda_graph: bool(false),
322
+ length_buckets: intList([16n, 32n, 48n, 64n, 96n, 128n]),
306
323
  trackio_enabled: bool(false),
307
324
  trackio_project: str("mailwoman"),
308
325
  trackio_space: str(""),
package/lib/types.ts CHANGED
@@ -387,6 +387,36 @@ export interface AdapterOptions {
387
387
  */
388
388
  sample?: RowSample | null
389
389
 
390
+ /**
391
+ * The share of the source's training rows a build keeps, from 0 to 1, or no value to keep them all.
392
+ *
393
+ * Align applies it after each row's split is decided, so validation and test keep every row.
394
+ * A training row is kept when a salted hash of its id up to the last `#` falls
395
+ * under the share (`keepsTrainRow`).
396
+ *
397
+ * An id with no `#` draws per row, so a record's variants draw apart.
398
+ * The adapter ignores it.
399
+ */
400
+ trainShare?: number | null
401
+
402
+ /**
403
+ * The input rows to read, by position in the input file from `start` up to `end`,
404
+ * for an adapter that declares {@linkcode CorpusAdapter.inputRowCount}.
405
+ *
406
+ * A parallel build runs one partition of a large input per range and merges them in order,
407
+ * so a row's output must depend only on the row: its id comes from its own fields
408
+ * or its position in the file, never from a count of the rows before it.
409
+ */
410
+ rowRange?: { start: number; end: number } | null
411
+
412
+ /**
413
+ * Limits for the DuckDB instance an adapter reading parquet opens, set by a parallel
414
+ * build's partition worker so several partitions fit the host at once.
415
+ *
416
+ * An adapter without DuckDB ignores it, and it changes no row.
417
+ */
418
+ duckdb?: { memoryLimitBytes: number; threads: number } | null
419
+
390
420
  /**
391
421
  * A cancellation signal that adapters should check at each iteration.
392
422
  */
@@ -535,4 +565,13 @@ export interface CorpusAdapter {
535
565
  * They mustn't mutate rows already yielded.
536
566
  */
537
567
  rows(opts: AdapterOptions): AsyncIterable<CanonicalRow>
568
+
569
+ /**
570
+ * The number of rows in the input `opts.inputPath` names, for an adapter that
571
+ * reads {@linkcode AdapterOptions.rowRange}.
572
+ *
573
+ * Its presence declares that the adapter can read its input in row ranges,
574
+ * so a parallel build may split a large input across workers.
575
+ */
576
+ inputRowCount?(opts: AdapterOptions): Promise<number>
538
577
  }
@@ -21,6 +21,7 @@ import { formatPersonName } from "@mailwoman/record/name"
21
21
  import { CSVSpliterator } from "spliterator"
22
22
 
23
23
  import { stableSourceID } from "#adapters/source-id"
24
+ import { withConventionStreet } from "#adapters/street/convention"
24
25
  import { splitStreetLine } from "#adapters/street/line"
25
26
  import { createUnitSplitter } from "#adapters/street/unit"
26
27
  import { SourceRegister } from "#registers"
@@ -228,7 +229,7 @@ export function createStateTxNotariesAdapter(): CorpusAdapter {
228
229
  ...(zip ? { postcode: zip } : {}),
229
230
  }
230
231
 
231
- const rendered = formatAddressRow(components, "US", { singleLine: true })
232
+ const rendered = formatAddressRow(withConventionStreet(components, "US"), "US", { singleLine: true })
232
233
 
233
234
  if (!rendered) continue
234
235
 
@@ -22,6 +22,7 @@ import { CSVSpliterator } from "spliterator"
22
22
 
23
23
  import { rawTextDiscriminator } from "#adapters/record-id"
24
24
  import { stableSourceID } from "#adapters/source-id"
25
+ import { withConventionStreet } from "#adapters/street/convention"
25
26
  import { createUnitSplitter } from "#adapters/street/unit"
26
27
  import { SourceRegister } from "#registers"
27
28
  import { streetIndexOpener } from "#street-index/reader"
@@ -107,7 +108,7 @@ export function createUSGovIMLSPLSAdapter(): CorpusAdapter {
107
108
  // It isn't a postal-surface component here.
108
109
  }
109
110
 
110
- const rendered = formatAddressRow(components, "US", { singleLine: true })
111
+ const rendered = formatAddressRow(withConventionStreet(components, "US"), "US", { singleLine: true })
111
112
 
112
113
  if (!rendered) continue
113
114
 
@@ -12,6 +12,7 @@ import { isPresent } from "@mailwoman/core/values/objects"
12
12
  import type { PathBuilderLike } from "path-ts"
13
13
 
14
14
  import { rawTextDiscriminator } from "#adapters/record-id"
15
+ import { countParquetRows } from "#parquet/readers"
15
16
  import { openParquetRowStream } from "#parquet/streams"
16
17
  import { SourceRegister } from "#registers"
17
18
  import { AddressRole, type AdapterOptions, type CanonicalRow, type CorpusAdapter, SurfaceOrigin } from "#types"
@@ -36,6 +37,10 @@ export const NAD_PLACEHOLDER_UUID = /^0{8}-0{4}-0{4}-0{4}-0{12}$/u
36
37
  * The release's text file is read with every column as text.
37
38
  */
38
39
  export interface NADRecord {
40
+ /**
41
+ * The row's position in the release file, read by {@linkcode readNADRecords}.
42
+ */
43
+ file_row_number?: number | bigint | null
39
44
  OID_?: string | null
40
45
  UUID?: string | null
41
46
  AddNum_Pre?: string | null
@@ -175,16 +180,32 @@ export function normalizeNADRecord(record: NADRecord): NADRecord {
175
180
  * Streams the NAD records of one release Parquet file in file order,
176
181
  * each passed through {@linkcode normalizeNADRecord}.
177
182
  *
183
+ * Each record holds its `file_row_number`.
184
+ *
178
185
  * @param where A DuckDB condition rows must satisfy, built with `escapeSQLString` for every literal.
186
+ * @param rowRange The positions to read, from `start` up to `end`.
179
187
  * @throws When the file lacks a column of {@link NAD_RECORD_COLUMNS}.
180
188
  */
181
189
  export async function* readNADRecords(
182
190
  parquetPath: PathBuilderLike,
183
- options: { where?: string } = {}
191
+ options: {
192
+ where?: string
193
+ rowRange?: { start: number; end: number } | null
194
+ limits?: { memoryLimitBytes: number; threads: number } | null
195
+ } = {}
184
196
  ): AsyncGenerator<NADRecord> {
197
+ const conditions = [
198
+ options.where,
199
+ options.rowRange
200
+ ? `file_row_number >= ${Math.trunc(options.rowRange.start)} AND file_row_number < ${Math.trunc(options.rowRange.end)}`
201
+ : null,
202
+ ].filter(isPresent)
203
+
185
204
  const rows = openParquetRowStream<NADRecord>(parquetPath, {
186
205
  columns: NAD_RECORD_COLUMNS,
187
- ...(options.where ? { where: options.where } : {}),
206
+ fileRowNumber: true,
207
+ ...(options.limits ? { limits: options.limits } : {}),
208
+ ...(conditions.length ? { where: conditions.map((condition) => `(${condition})`).join(" AND ") } : {}),
188
209
  })
189
210
 
190
211
  for await (const row of rows) {
@@ -285,6 +306,10 @@ export interface DecomposedNADStreet {
285
306
  *
286
307
  * Structured street fields take precedence.
287
308
  * If they're empty, `StNam_Full` supplies the whole street.
309
+ *
310
+ * A pre-type and its separator open the street name, so `Farm to Market` + `1638` is the street
311
+ * `Farm to Market 1638`, as USPS Publication 28 lists a numbered road (`COUNTY ROAD 20`, SCHEMA.mdx).
312
+ * Only the pre-directional is the prefix.
288
313
  */
289
314
  export function decomposeNADStreet(r: NADRecord): DecomposedNADStreet | null {
290
315
  const name = (r.St_Name ?? "").toString().trim()
@@ -295,11 +320,12 @@ export function decomposeNADStreet(r: NADRecord): DecomposedNADStreet | null {
295
320
  const preSep = (r.St_PreSep ?? "").toString().trim()
296
321
  const posTyp = (r.St_PosTyp ?? "").toString().trim()
297
322
  const posDir = (r.St_PosDir ?? "").toString().trim()
298
- const prefix = [preDir, preTyp, preSep].filter(isPresent).join(" ") || undefined
323
+ const prefix = preDir || undefined
324
+ const street = [preTyp, preSep, name].filter(isPresent).join(" ")
299
325
  const suffix = [posTyp, posDir].filter(isPresent).join(" ") || undefined
300
- const full = [prefix, name, suffix].filter(isPresent).join(" ")
326
+ const full = [prefix, street, suffix].filter(isPresent).join(" ")
301
327
 
302
- return { prefix, street: name, suffix, full }
328
+ return { prefix, street, suffix, full }
303
329
  }
304
330
 
305
331
  const full = (r.StNam_Full ?? "").toString().trim()
@@ -428,6 +454,10 @@ export function createUsgovNADAdapter(): CorpusAdapter {
428
454
  description:
429
455
  "US DOT National Address Database — ~97M structured US address points (911-grade). Single largest US source.",
430
456
 
457
+ async inputRowCount(opts: AdapterOptions): Promise<number> {
458
+ return countParquetRows(opts.inputPath)
459
+ },
460
+
431
461
  async *rows(opts: AdapterOptions): AsyncIterable<CanonicalRow> {
432
462
  if (opts.country && opts.country !== "US") {
433
463
  throw new Error(`usgov-nad adapter: only US supported, got country=${opts.country}`)
@@ -436,7 +466,7 @@ export function createUsgovNADAdapter(): CorpusAdapter {
436
466
  let emitted = 0
437
467
 
438
468
  // The row stream closes its DuckDB connection when the loop exits early.
439
- for await (const record of readNADRecords(opts.inputPath)) {
469
+ for await (const record of readNADRecords(opts.inputPath, { rowRange: opts.rowRange, limits: opts.duckdb })) {
440
470
  if (opts.signal?.aborted) break
441
471
 
442
472
  if (typeof opts.limit === "number" && emitted >= opts.limit) break
@@ -459,9 +489,12 @@ export function createUsgovNADAdapter(): CorpusAdapter {
459
489
  // and 82 addresses share the all-zero placeholder UUID (#2894).
460
490
  // The id therefore adds a digest of the rendered address to the UUID.
461
491
  // Two points of one address stay one record, and two addresses under one UUID become two.
492
+ // A row with neither falls back to its position in the file, so a partition
493
+ // reading a row range writes the id an unpartitioned run writes.
494
+ // Release r24 has no such row in 99,226,272.
462
495
  const key = record.UUID && !NAD_PLACEHOLDER_UUID.test(record.UUID) ? record.UUID : record.OID_
463
496
 
464
- const sourceID = `${USGOV_NAD_ADAPTER_ID}-${key ?? `row${emitted}`}-${rawTextDiscriminator(raw)}`
497
+ const sourceID = `${USGOV_NAD_ADAPTER_ID}-${key ?? `row${Number(record.file_row_number)}`}-${rawTextDiscriminator(raw)}`
465
498
 
466
499
  yield {
467
500
  raw,
@@ -22,14 +22,8 @@ import {
22
22
  US_STREET_SUFFIX_LOOKUP,
23
23
  US_UNIT_DESIGNATOR_LOOKUP,
24
24
  } from "@mailwoman/codex/us"
25
- import { foldNFKCWhitespace, stripCombiningMarks } from "@mailwoman/normalize/fold"
26
25
 
27
- import type { ParquetRow } from "#parquet/schema"
28
-
29
- /**
30
- * The text and span triple an address key reads.
31
- */
32
- export type AddressKeyRow = Pick<ParquetRow, "raw" | "span_starts" | "span_ends" | "span_tags">
26
+ import { type AddressKeyRow, aliasedSpanSQL, foldKeyText, labeledSpanText } from "#utils/address-key"
33
27
 
34
28
  /**
35
29
  * The street tags whose spans make up the street, in the order a row writes them.
@@ -41,30 +35,6 @@ const STREET_TAGS: ReadonlySet<string> = new Set(["street_prefix", "street", "st
41
35
  */
42
36
  const ZIP_CODE_DIGITS = 5
43
37
 
44
- /**
45
- * Lower case, marks stripped, every run of characters other than letters and digits one space.
46
- */
47
- function foldKeyText(text: string): string {
48
- return stripCombiningMarks(foldNFKCWhitespace(text))
49
- .replaceAll(/[^\p{L}\p{N}]+/gu, " ")
50
- .trim()
51
- }
52
-
53
- /**
54
- * Every span's text under `tags`, joined in the row's order.
55
- */
56
- function spanText(row: AddressKeyRow, tags: ReadonlySet<string>): string {
57
- const parts: string[] = []
58
-
59
- for (const [index, tag] of row.span_tags.entries()) {
60
- if (tags.has(tag)) {
61
- parts.push(row.raw.slice(row.span_starts[index], row.span_ends[index]))
62
- }
63
- }
64
-
65
- return parts.join(" ")
66
- }
67
-
68
38
  /**
69
39
  * One folded street or unit word in its canonical form: a directional as its USPS
70
40
  * abbreviation, a street suffix or unit designator as its Pub. 28 canonical.
@@ -91,11 +61,11 @@ function canonicalWords(text: string): string {
91
61
  * @returns null when the row has no five-digit ZIP Code or no digit in its house number.
92
62
  */
93
63
  export function nadAddressBlock(row: AddressKeyRow): string | null {
94
- const zip = spanText(row, new Set(["postcode"]))
64
+ const zip = labeledSpanText(row, new Set(["postcode"]))
95
65
  .replaceAll(/\D/gu, "")
96
66
  .slice(0, ZIP_CODE_DIGITS)
97
67
 
98
- const number = spanText(row, new Set(["house_number"])).replaceAll(/\D/gu, "")
68
+ const number = labeledSpanText(row, new Set(["house_number"])).replaceAll(/\D/gu, "")
99
69
 
100
70
  if (zip.length !== ZIP_CODE_DIGITS || !number) return null
101
71
 
@@ -109,16 +79,7 @@ export function nadAddressBlock(row: AddressKeyRow): string | null {
109
79
  * outside the Basic Multilingual Plane before its ZIP Code reads another block and is missed.
110
80
  */
111
81
  export function nadAddressBlockSQL(alias: string): string {
112
- const span = (tag: string) => {
113
- const at = `list_position(${alias}.span_tags, '${tag}')`
114
-
115
- return (
116
- `substr(${alias}.raw, ${alias}.span_starts[${at}] + 1, ` +
117
- `${alias}.span_ends[${at}] - ${alias}.span_starts[${at}])`
118
- )
119
- }
120
-
121
- const digits = (tag: string) => `regexp_replace(coalesce(${span(tag)}, ''), '[^0-9]', '', 'g')`
82
+ const digits = (tag: string) => `regexp_replace(coalesce(${aliasedSpanSQL(alias, tag)}, ''), '[^0-9]', '', 'g')`
122
83
 
123
84
  return `(left(${digits("postcode")}, 5) || '|' || ${digits("house_number")})`
124
85
  }
@@ -130,15 +91,15 @@ export function nadAddressBlockSQL(alias: string): string {
130
91
  * or a street, because such a row identifies no single address.
131
92
  */
132
93
  export function nadAddressKey(row: AddressKeyRow): string | null {
133
- const state = lookupUSState(spanText(row, new Set(["region"])) || null)
94
+ const state = lookupUSState(labeledSpanText(row, new Set(["region"])) || null)
134
95
  const block = nadAddressBlock(row)
135
- const number = foldKeyText(spanText(row, new Set(["house_number"])))
136
- const street = canonicalWords(spanText(row, STREET_TAGS))
96
+ const number = foldKeyText(labeledSpanText(row, new Set(["house_number"])))
97
+ const street = canonicalWords(labeledSpanText(row, STREET_TAGS))
137
98
 
138
99
  if (!state || !block || !number || !street) return null
139
100
 
140
101
  const zip = block.slice(0, ZIP_CODE_DIGITS)
141
- const unit = canonicalWords(spanText(row, new Set(["unit"])))
102
+ const unit = canonicalWords(labeledSpanText(row, new Set(["unit"])))
142
103
 
143
104
  return `${state.toLowerCase()}|${zip}|${number}|${street}|${unit}`
144
105
  }
@@ -13,6 +13,7 @@ import type { PathBuilderLike } from "path-ts"
13
13
  import { CSVSpliterator } from "spliterator"
14
14
 
15
15
  import { stableSourceID } from "#adapters/source-id"
16
+ import { withConventionStreet } from "#adapters/street/convention"
16
17
  import { createUnitSplitter } from "#adapters/street/unit"
17
18
  import { SourceRegister } from "#registers"
18
19
  import { streetIndexOpener } from "#street-index/reader"
@@ -157,7 +158,7 @@ export function createUsgovNPPESAdapter(): CorpusAdapter {
157
158
  postcode,
158
159
  }
159
160
 
160
- const rendered = formatAddressRow(components, "US", { singleLine: true })
161
+ const rendered = formatAddressRow(withConventionStreet(components, "US"), "US", { singleLine: true })
161
162
 
162
163
  if (!rendered) continue
163
164
 
@@ -0,0 +1,57 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
4
+ /**
5
+ * @file The span reads and text folding an evaluation-group address key is built from.
6
+ *
7
+ * A source whose group identity holds an address key (`GROUP_ADDRESS_KEY_SOURCES`) reads its key from a
8
+ * row's labeled spans.
9
+ * Every rendering the corpus writes of one address then gives one key.
10
+ */
11
+
12
+ import { foldNFKCWhitespace, stripCombiningMarks } from "@mailwoman/normalize/fold"
13
+
14
+ import type { ParquetRow } from "#parquet/schema"
15
+
16
+ /**
17
+ * The text and span triple an address key reads.
18
+ */
19
+ export type AddressKeyRow = Pick<ParquetRow, "raw" | "span_starts" | "span_ends" | "span_tags">
20
+
21
+ /**
22
+ * Lower case, marks stripped, every run of characters other than letters and digits one space.
23
+ */
24
+ export function foldKeyText(text: string): string {
25
+ return stripCombiningMarks(foldNFKCWhitespace(text))
26
+ .replaceAll(/[^\p{L}\p{N}]+/gu, " ")
27
+ .trim()
28
+ }
29
+
30
+ /**
31
+ * Every span's text under `tags`, joined by a space in the row's order.
32
+ */
33
+ export function labeledSpanText(row: AddressKeyRow, tags: ReadonlySet<string>): string {
34
+ const parts: string[] = []
35
+
36
+ for (const [index, tag] of row.span_tags.entries()) {
37
+ if (tags.has(tag)) {
38
+ parts.push(row.raw.slice(row.span_starts[index], row.span_ends[index]))
39
+ }
40
+ }
41
+
42
+ return parts.join(" ")
43
+ }
44
+
45
+ /**
46
+ * The text of the first span tagged `tag` in a corpus file aliased `alias`,
47
+ * as a DuckDB expression, NULL when the row has none.
48
+ *
49
+ * DuckDB counts characters by code point and the spans by UTF-16 unit, so in a row
50
+ * holding a character outside the Basic Multilingual Plane before the span the
51
+ * expression reads text shifted by one per such character.
52
+ */
53
+ export function aliasedSpanSQL(alias: string, tag: string): string {
54
+ const at = `list_position(${alias}.span_tags, '${tag}')`
55
+
56
+ return `substr(${alias}.raw, ${alias}.span_starts[${at}] + 1, ${alias}.span_ends[${at}] - ${alias}.span_starts[${at}])`
57
+ }
@@ -146,6 +146,26 @@ export function locateComponentSpans(
146
146
  /**
147
147
  * Align a single row.
148
148
  */
149
+ /**
150
+ * A copy of a row's components with each value in NFC, the form {@linkcode alignRow} writes to a labeled row.
151
+ *
152
+ * A caller that decides a row's split before aligning it reads these,
153
+ * so the decision equals the one made on the aligned row.
154
+ */
155
+ export function nfcComponents(components: CanonicalRow["components"]): CanonicalRow["components"] {
156
+ const normalized = { ...components }
157
+
158
+ for (const key of Object.keys(normalized)) {
159
+ const value = normalized[key as keyof typeof normalized]
160
+
161
+ if (typeof value === "string") {
162
+ normalized[key as keyof typeof normalized] = value.normalize("NFC")
163
+ }
164
+ }
165
+
166
+ return normalized
167
+ }
168
+
149
169
  export function alignRow(row: CanonicalRow, opts: AlignOptions = {}): AlignmentResult {
150
170
  const tokenizer = opts.tokenizer ?? whitespaceTokenizer()
151
171
  const maxEditDistance = opts.maxEditDistance ?? 2
@@ -156,15 +176,7 @@ export function alignRow(row: CanonicalRow, opts: AlignOptions = {}): AlignmentR
156
176
  }
157
177
 
158
178
  const raw = row.raw.normalize("NFC")
159
- const components = { ...row.components }
160
-
161
- for (const key of Object.keys(components)) {
162
- const v = components[key as keyof typeof components]
163
-
164
- if (typeof v === "string") {
165
- components[key as keyof typeof components] = v.normalize("NFC")
166
- }
167
- }
179
+ const components = nfcComponents(row.components)
168
180
 
169
181
  const located = locateComponentSpans(raw, components, { maxEditDistance, caseInsensitive })
170
182
 
@@ -345,7 +357,7 @@ function labelTokens(tokens: readonly TextFragment[], spans: readonly ComponentS
345
357
  for (const token of tokens) {
346
358
  // A token inside one span takes that span's tag.
347
359
  // A token that overlaps exactly one span without lying inside it holds that component
348
- // plus text a layout glued to it, such as `FL-9485` around the postcode `9485`,
360
+ // plus text a layout glued to it, such as `HR-10000` around the postcode `10000`,
349
361
  // so it takes that span's tag too and the token labels agree with the span triple.
350
362
  // A token across two spans stays `O`.
351
363
  let index = spans.findIndex((s) => token.start >= s.start && token.end <= s.end)
@@ -22,14 +22,12 @@ import { sha256File } from "@mailwoman/core/crypto/hash"
22
22
  import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
23
23
  import { resolveModulePath } from "@mailwoman/core/module/resolvers"
24
24
 
25
+ import { OVERTURE_LATAM_SOURCE } from "#adapters/overture/adapter"
26
+ import { overtureAddressBlock, overtureAddressBlockSQL, overtureAddressKey } from "#adapters/overture/address-key"
25
27
  import { recordIDOf } from "#adapters/record-id"
26
28
  import { USGOV_NAD_ADAPTER_ID } from "#us/adapters/usgov/nad/adapter"
27
- import {
28
- type AddressKeyRow,
29
- nadAddressBlock,
30
- nadAddressBlockSQL,
31
- nadAddressKey,
32
- } from "#us/adapters/usgov/nad/address-key"
29
+ import { nadAddressBlock, nadAddressBlockSQL, nadAddressKey } from "#us/adapters/usgov/nad/address-key"
30
+ import type { AddressKeyRow } from "#utils/address-key"
33
31
 
34
32
  /**
35
33
  * The attribute name an evaluation-group file declares.
@@ -63,9 +61,18 @@ export interface GroupAddressKeySource {
63
61
  * The sources whose group identity includes an address key, by corpus `source`.
64
62
  *
65
63
  * Every other source groups by record id only.
64
+ *
65
+ * NAD's releases issue a resubmitted address a new UUID (#3125).
66
+ * An `overture-latam` row's id hashes its components, so the re-run that adds the region
67
+ * and regroups the postcode issues every row a new id (#3457).
66
68
  */
67
69
  export const GROUP_ADDRESS_KEY_SOURCES: Readonly<Record<string, GroupAddressKeySource>> = {
68
70
  [USGOV_NAD_ADAPTER_ID]: { key: nadAddressKey, block: nadAddressBlock, blockSQL: nadAddressBlockSQL },
71
+ [OVERTURE_LATAM_SOURCE]: {
72
+ key: overtureAddressKey,
73
+ block: overtureAddressBlock,
74
+ blockSQL: overtureAddressBlockSQL,
75
+ },
69
76
  }
70
77
 
71
78
  /**
@@ -16,7 +16,7 @@
16
16
  * a holdout to a built corpus would leak rows the model already trained on.
17
17
  */
18
18
 
19
- import { createHash } from "@mailwoman/core/crypto/hash"
19
+ import { sha256Buffer } from "@mailwoman/core/crypto/hash"
20
20
  import { openWriteStream } from "@mailwoman/core/fs/streams"
21
21
  import { writeLocalJSONFile, writeLocalTextFile, makeDirectories, removePath } from "@mailwoman/core/fs/writers"
22
22
  import { spawnProcess } from "@mailwoman/core/scripting/process"
@@ -804,9 +804,29 @@ export function holdoutPolicyFor(holdout: CountryHoldout | null): HoldoutPolicy
804
804
  return Array.isArray(holdout) ? { regions: holdout } : (holdout as HoldoutPolicy)
805
805
  }
806
806
 
807
+ /**
808
+ * Whether a country's declared holdout reads postcode prefixes and no region or locality.
809
+ *
810
+ * Under such a policy a row's split reads only its record and its postcode digits.
811
+ * The corpus augmentations change case, punctuation and abbreviations, and drop a ZIP+4 dash.
812
+ * None of them changes the compacted postcode digits.
813
+ *
814
+ * A variant of a training row therefore trains, and a caller may draw a variant's
815
+ * training share before making it.
816
+ */
817
+ export function holdoutReadsOnlyPostcode(holdout: CountryHoldout | null | undefined): boolean {
818
+ const policy = holdoutPolicyFor(holdout ?? null)
819
+
820
+ return Boolean(policy.postcodePrefixes?.length) && !policy.regions?.length && !policy.localities?.length
821
+ }
822
+
807
823
  interface FoldedHoldoutNames {
808
824
  regions: ReadonlySet<string>
809
825
  localities: ReadonlySet<string>
826
+ /**
827
+ * The policy's postcode prefixes under `compactPostcode`, so a row's test compacts only its own postcode.
828
+ */
829
+ postcodePrefixes: readonly string[]
810
830
  }
811
831
 
812
832
  const foldedNamesCache = new WeakMap<object, FoldedHoldoutNames>()
@@ -825,6 +845,7 @@ function foldedNamesFor(declared: CountryHoldout, policy: HoldoutPolicy): Folded
825
845
  const names: FoldedHoldoutNames = {
826
846
  regions: new Set((policy.regions ?? []).map(foldNFKCWhitespace)),
827
847
  localities: new Set((policy.localities ?? []).map(foldNFKCWhitespace)),
848
+ postcodePrefixes: (policy.postcodePrefixes ?? []).map(compactPostcode),
828
849
  }
829
850
 
830
851
  foldedNamesCache.set(declared, names)
@@ -906,7 +927,7 @@ export function splitForRow(
906
927
 
907
928
  isHeldOut = Boolean(
908
929
  (region && folded.regions.has(foldNFKCWhitespace(region))) ||
909
- (compact && (policy.postcodePrefixes?.some((prefix) => compact.startsWith(compactPostcode(prefix))) ?? false)) ||
930
+ (compact && folded.postcodePrefixes.some((prefix) => compact.startsWith(prefix))) ||
910
931
  (locality && folded.localities.has(foldNFKCWhitespace(locality)))
911
932
  )
912
933
  } else {
@@ -976,7 +997,7 @@ export function hashBucket(id: string, n: number): number {
976
997
  * the value {@link hashBucket} reduces and the validation quota orders groups by.
977
998
  */
978
999
  export function hashUint32(id: string): number {
979
- const digest = createHash("sha256").update(id).digest()
1000
+ const digest = sha256Buffer(id)
980
1001
 
981
1002
  return digest[0]! * 0x01_00_00_00 + digest[1]! * 0x01_00_00 + digest[2]! * 0x01_00 + digest[3]!
982
1003
  }
@@ -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,MAA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`opts.country`.
122
122
  */
123
123
  import { ConventionClaimID, ObservationStance } from "@mailwoman/codex/address/convention-claims";
124
- import { formatAddressRow, scriptOfComponents } from "@mailwoman/codex/address/format";
124
+ import { scriptOfComponents } from "@mailwoman/codex/address/format";
125
125
  import { conventionClaimForCountry, layoutForCountry } from "@mailwoman/codex/address/layouts";
126
126
  import { CountryISO2 } from "@mailwoman/codex/country/codes";
127
127
  import { matchCountry } from "@mailwoman/codex/country/country";
@@ -136,6 +136,7 @@ import { joinRepetitionIndex } from "#adapters/street/repetition";
136
136
  import { createUnitSplitter } from "#adapters/street/unit";
137
137
  import { SourceRegister } from "#registers";
138
138
  import { streetIndexOpener } from "#street-index/reader";
139
+ import { formatCorpusRow } from "#surfaces/corpus-row";
139
140
  import { AddressRole, countDropped, SurfaceOrigin, } from "#types";
140
141
  /**
141
142
  * Registry id for this adapter.
@@ -487,7 +488,7 @@ export function readCORDISRecord(record, lexicon, units) {
487
488
  // That keeps a country's local order whenever its Latin order has fewer slots:
488
489
  // `Weixing Road` and `Changchun` would otherwise print run together in China's
489
490
  // Han-script line, with no separator between them.
490
- const rendered = formatAddressRow(components, country, {
491
+ const rendered = formatCorpusRow(components, country, {
491
492
  singleLine: true,
492
493
  script: scriptOfComponents(components, country),
493
494
  });