@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
package/lib/runner.ts CHANGED
@@ -10,8 +10,9 @@
10
10
  import { isAlpha2CodeShape } from "@mailwoman/codex/country"
11
11
  import { openWriteStream, type WriteStream } from "@mailwoman/core/fs/streams"
12
12
  import { writeLocalJSONFile, makeDirectories } from "@mailwoman/core/fs/writers"
13
- import { stringifyJSON } from "@mailwoman/core/values/json"
13
+ import { parseJSONStrict, stringifyJSON } from "@mailwoman/core/values/json"
14
14
  import { type PathBuilderLike, resolvePathBuilder } from "path-ts"
15
+ import { TextSpliterator } from "spliterator"
15
16
 
16
17
  import { canonicalDedupKey } from "#adapters/dedup-key"
17
18
  import type { AdapterRegistry } from "#adapters/registry"
@@ -207,11 +208,144 @@ export interface AdapterRunManifest {
207
208
  * Drive a single adapter to completion, writing its jsonl and manifest under `outputDir/<adapter.id>/`.
208
209
  */
209
210
  export async function runAdapter(opts: RunAdapterOptions): Promise<AdapterRunManifest> {
210
- const { adapter, outputDir, corpusVersion } = opts
211
211
  // A caller that passes its own map reads the counts back from it.
212
212
  // Otherwise the runner supplies one, so every manifest records the adapter's drop reasons.
213
213
  const dropped = opts.adapterOptions.dropped ?? new Map<string, number>()
214
214
  const adapterOptions: AdapterOptions = { ...opts.adapterOptions, dropped }
215
+
216
+ return writeAdapterRun(
217
+ opts,
218
+ emittedLines(opts.adapter, adapterOptions, opts.sourceName),
219
+ dropped,
220
+ adapterOptions.signal
221
+ )
222
+ }
223
+
224
+ /**
225
+ * One emitted row as the run loop reads it: its dedup key and its canonical JSONL line.
226
+ */
227
+ interface EmittedLine {
228
+ key: string
229
+ line: string
230
+ }
231
+
232
+ /**
233
+ * The adapter's rows, each held to its own id and stamped with the runner's fields.
234
+ */
235
+ async function* emittedLines(
236
+ adapter: CorpusAdapter,
237
+ adapterOptions: AdapterOptions,
238
+ sourceName: string | undefined
239
+ ): AsyncGenerator<EmittedLine> {
240
+ for await (const row of adapter.rows(adapterOptions)) {
241
+ if (adapterOptions.signal?.aborted) {
242
+ throw new DOMException("Adapter run aborted by signal", "AbortError")
243
+ }
244
+
245
+ assertEmittedRow(adapter, row)
246
+
247
+ const stamped: CanonicalRow = {
248
+ ...row,
249
+ // The rename is the runner's, after `assertEmittedRow` has held the adapter to emitting its own id.
250
+ source: sourceName ?? row.source,
251
+ addressRole: row.addressRole ?? adapter.addressRole,
252
+ // `register` is nullable and null is a statement rather than an absence,
253
+ // so only an undefined field takes the adapter's declaration.
254
+ register: row.register || adapter.register,
255
+ surface: row.surface ?? adapter.surface,
256
+ }
257
+
258
+ yield { key: canonicalDedupKey(stamped), line: `${stringifyJSON(stamped)}\n` }
259
+ }
260
+ }
261
+
262
+ /**
263
+ * Run one partition of an adapter's input, the rows `adapterOptions.rowRange` selects, into `outputPath`.
264
+ *
265
+ * Each line holds a row's dedup key as a JSON string, a tab, and its canonical line.
266
+ * The partition writes every row it reads. {@linkcode mergeAdapterPartitions} reads
267
+ * every partition in input order and deduplicates across them.
268
+ *
269
+ * The merged run therefore writes the bytes one unpartitioned run writes.
270
+ */
271
+ export async function runAdapterPartition(opts: {
272
+ adapter: CorpusAdapter
273
+ adapterOptions: AdapterOptions
274
+ sourceName?: string
275
+ outputPath: PathBuilderLike
276
+ }): Promise<AdapterPartitionRecord> {
277
+ const dropped = new Map<string, number>()
278
+ const adapterOptions: AdapterOptions = { ...opts.adapterOptions, dropped }
279
+ const stream = openWriteStream(opts.outputPath, { encoding: "utf8" })
280
+ let yielded = 0
281
+
282
+ try {
283
+ for await (const { key, line } of emittedLines(opts.adapter, adapterOptions, opts.sourceName)) {
284
+ yielded++
285
+
286
+ // JSON escapes a tab inside the key, so the first tab ends it.
287
+ if (!stream.write(`${stringifyJSON(key)}\t${line}`)) {
288
+ await once(stream, "drain")
289
+ }
290
+ }
291
+ } finally {
292
+ stream.end()
293
+ await once(stream, "close")
294
+ }
295
+
296
+ adapterOptions.signal?.throwIfAborted()
297
+
298
+ return { path: opts.outputPath.toString(), yielded, dropped: [...dropped] }
299
+ }
300
+
301
+ /**
302
+ * What one partition of an adapter run wrote.
303
+ */
304
+ export interface AdapterPartitionRecord {
305
+ path: string
306
+ yielded: number
307
+ dropped: [string, number][]
308
+ }
309
+
310
+ /**
311
+ * Merge an adapter's partitions, in input order, into the canonical file
312
+ * and manifest one unpartitioned run writes.
313
+ */
314
+ export async function mergeAdapterPartitions(
315
+ opts: RunAdapterOptions,
316
+ partitions: readonly AdapterPartitionRecord[]
317
+ ): Promise<AdapterRunManifest> {
318
+ const dropped = new Map<string, number>()
319
+
320
+ for (const partition of partitions) {
321
+ for (const [reason, count] of partition.dropped) {
322
+ dropped.set(reason, (dropped.get(reason) ?? 0) + count)
323
+ }
324
+ }
325
+
326
+ async function* lines(): AsyncGenerator<EmittedLine> {
327
+ for (const partition of partitions) {
328
+ for await (const text of TextSpliterator.fromAsync(partition.path)) {
329
+ const tab = text.indexOf("\t")
330
+
331
+ yield { key: parseJSONStrict<string>(text.slice(0, tab)), line: `${text.slice(tab + 1)}\n` }
332
+ }
333
+ }
334
+ }
335
+
336
+ return writeAdapterRun(opts, lines(), dropped, opts.adapterOptions.signal)
337
+ }
338
+
339
+ /**
340
+ * Deduplicate emitted lines into `<outputDir>/<adapter.id>/canonical.jsonl` and write the run's manifest.
341
+ */
342
+ async function writeAdapterRun(
343
+ opts: RunAdapterOptions,
344
+ emitted: AsyncIterable<EmittedLine>,
345
+ dropped: ReadonlyMap<string, number>,
346
+ signal: AbortSignal | undefined
347
+ ): Promise<AdapterRunManifest> {
348
+ const { adapter, outputDir, corpusVersion } = opts
215
349
  const progressEvery = opts.progressEvery ?? 1000
216
350
 
217
351
  const adapterDir = resolvePathBuilder(outputDir, adapter.id)
@@ -252,26 +386,12 @@ export async function runAdapter(opts: RunAdapterOptions): Promise<AdapterRunMan
252
386
  }
253
387
 
254
388
  try {
255
- for await (const row of adapter.rows(adapterOptions)) {
256
- if (adapterOptions.signal?.aborted) {
389
+ for await (const { key, line } of emitted) {
390
+ if (signal?.aborted) {
257
391
  throw new DOMException("Adapter run aborted by signal", "AbortError")
258
392
  }
259
393
 
260
394
  yielded++
261
- assertEmittedRow(adapter, row)
262
-
263
- const stamped: CanonicalRow = {
264
- ...row,
265
- // The rename is the runner's, after `assertEmittedRow` has held the adapter to emitting its own id.
266
- source: opts.sourceName ?? row.source,
267
- addressRole: row.addressRole ?? adapter.addressRole,
268
- // `register` is nullable and null is a statement rather than an absence,
269
- // so only an undefined field takes the adapter's declaration.
270
- register: row.register || adapter.register,
271
- surface: row.surface ?? adapter.surface,
272
- }
273
-
274
- const key = canonicalDedupKey(stamped)
275
395
 
276
396
  if (fingerprints) {
277
397
  // The table holds every key the run has seen, so a duplicate is refused wherever it arrives.
@@ -313,7 +433,6 @@ export async function runAdapter(opts: RunAdapterOptions): Promise<AdapterRunMan
313
433
  }
314
434
  }
315
435
 
316
- const line = `${stringifyJSON(stamped)}\n`
317
436
  hasher.update(line)
318
437
  bytes += Buffer.byteLength(line, "utf8")
319
438
 
@@ -334,7 +453,7 @@ export async function runAdapter(opts: RunAdapterOptions): Promise<AdapterRunMan
334
453
 
335
454
  // Every adapter honors `signal` by returning instead, so without this a truncated
336
455
  // `canonical.jsonl` would be recorded as a finished run.
337
- adapterOptions.signal?.throwIfAborted()
456
+ signal?.throwIfAborted()
338
457
 
339
458
  const endedAt = new Date()
340
459
  const elapsed_ms = performance.now() - t0
@@ -42,7 +42,12 @@ const GENERIC_ABBREVIATIONS: ReadonlyArray<readonly [full: string, short: string
42
42
  */
43
43
  const ESTATE_TAILS = ["ESTATE", "CONSERVATION AREA", "HILLS", "PARK", "GARDENS", "GARDEN", "HEIGHTS", "GROVE", "VILLE"]
44
44
 
45
- // The official form receives the probability left after the block, bracketed-postcode and building-led forms.
45
+ // The official form receives the probability left after the block,
46
+ // bracketed-postcode and building-led forms.
47
+ // SingPost prints `SINGAPORE <postcode>` after the
48
+ // street: `Blk 35 Mandalay Road / # 13–37 Mandalay Towers / SINGAPORE 308215`.
49
+ // The block, building-led and official forms write it.
50
+ // The bracketed `S(308215)` form is typed rather than printed, so it stays a minority.
46
51
  const P_BLOCK = 0.4
47
52
  const P_BRACKET_POSTCODE = 0.25
48
53
  const P_BUILDING_LED = 0.15
@@ -184,10 +184,20 @@ let committed: Promise<RowLicenses> | null = null
184
184
  * It reads both files without auditing them, because the audit runs where a build admits its sources.
185
185
  */
186
186
  export function committedRowLicenses(): Promise<RowLicenses> {
187
+ const inputs = committedRowLicenseInputs()
188
+
187
189
  committed ??= Promise.all([
188
- readLocalJSONFile<AddressSourceRegister>(addressSourceRegisterPath()),
189
- readLocalJSONFile<CorpusSourceInputsFile>(corpusSourceInputsPath()),
190
+ readLocalJSONFile<AddressSourceRegister>(inputs.register),
191
+ readLocalJSONFile<CorpusSourceInputsFile>(inputs.corpusSourceInputs),
190
192
  ]).then(([register, file]) => createRowLicenses(register, indexCorpusSourceInputs(file)))
191
193
 
192
194
  return committed
193
195
  }
196
+
197
+ /**
198
+ * The two committed files {@linkcode committedRowLicenses} reads, so a build
199
+ * can fingerprint the license ids it stamped.
200
+ */
201
+ export function committedRowLicenseInputs(): { register: string; corpusSourceInputs: string } {
202
+ return { register: addressSourceRegisterPath().toString(), corpusSourceInputs: corpusSourceInputsPath().toString() }
203
+ }
@@ -0,0 +1,84 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
4
+ /**
5
+ * Renders a corpus row through its country's layout, printing each form the postal
6
+ * operator documents for a value in that form's share of rows.
7
+ *
8
+ * Croatia's operator prints `HR-10000 ZAGREB` on mail from abroad,
9
+ * and the bare `10000 ZAGREB` is its domestic form.
10
+ * The layout's slot lists both, and the parser reads both, so the corpus writes both.
11
+ *
12
+ * The form is drawn from the row's identity, its country and its components,
13
+ * so a rebuild renders every row in the form it rendered before, and the draw
14
+ * takes no number from a recipe's seeded stream.
15
+ */
16
+
17
+ import { formatAddressRow, type AddressRow, type FormatAddressOptions } from "@mailwoman/codex/address/format"
18
+ import { writersPrintRegionBesideLayout } from "@mailwoman/codex/address/layouts"
19
+ import type { ComponentDict } from "@mailwoman/codex/address/render"
20
+ import type { ComponentTag } from "@mailwoman/codex/component"
21
+ import { hashFNV1a } from "@mailwoman/core/coarse-placer/fnv-hash"
22
+ import { mulberry32 } from "@mailwoman/core/math/random"
23
+
24
+ /**
25
+ * A number in [0, 1) read from `salt`, `country` and `components`, so a rebuild draws the same number for a row.
26
+ *
27
+ * The key joins the sorted tags and values with the separators `stableSourceID` uses.
28
+ */
29
+ function rowDraw(salt: string, country: string, components: ComponentDict): number {
30
+ const payload = (Object.keys(components) as ComponentTag[])
31
+ .toSorted()
32
+ .map((tag) => `${tag}=${components[tag] ?? ""}`)
33
+ .join("\u001F")
34
+
35
+ return mulberry32(hashFNV1a(`${salt}\u001E${country.toUpperCase()}\u001E${payload}`))()
36
+ }
37
+
38
+ /**
39
+ * The number in [0, 1) that picks a row's printed forms.
40
+ */
41
+ function corpusFormDraw(country: string, components: ComponentDict): number {
42
+ return rowDraw("postcode-form", country, components)
43
+ }
44
+
45
+ /**
46
+ * The share of corpus rows that print a region their postal layout leaves out, after the
47
+ * locality, in a country whose writers print it (`writersPrintRegionBesideLayout`).
48
+ *
49
+ * The postal layouts of Argentina, Romania, Lithuania and others omit the region
50
+ * because the operator's examples don't print it.
51
+ * Writers in those countries print it, as in `6400 Trenque Lauquen, Buenos Aires`.
52
+ *
53
+ * Half the rows keep the operator's form, and half keep the region and its label.
54
+ */
55
+ export const REGION_AFTER_LOCALITY_SHARE = 0.5
56
+
57
+ /**
58
+ * The number in [0, 1) that decides whether a row prints a region its layout leaves out.
59
+ *
60
+ * It reads the same key as {@linkcode corpusFormDraw} under its own salt, so the two draws are independent.
61
+ */
62
+ function regionDraw(country: string, components: ComponentDict): number {
63
+ return rowDraw("region-after-locality", country, components)
64
+ }
65
+
66
+ /**
67
+ * {@linkcode formatAddressRow} for a corpus row: each slot with documented forms prints the
68
+ * one {@linkcode corpusFormDraw} picks for the row, and a region the layout leaves out prints
69
+ * after the locality on {@linkcode REGION_AFTER_LOCALITY_SHARE} of rows that hold one.
70
+ */
71
+ export function formatCorpusRow(
72
+ components: ComponentDict,
73
+ country: string,
74
+ opts: Omit<FormatAddressOptions, "formDraw" | "regionAfterLocality"> = {}
75
+ ): AddressRow | null {
76
+ return formatAddressRow(components, country, {
77
+ ...opts,
78
+ formDraw: corpusFormDraw(country, components),
79
+ regionAfterLocality:
80
+ Boolean(components.region) &&
81
+ writersPrintRegionBesideLayout(country, opts.script ?? undefined) &&
82
+ regionDraw(country, components) < REGION_AFTER_LOCALITY_SHARE,
83
+ })
84
+ }
@@ -15,9 +15,10 @@
15
15
  * and the `synth-*` spelling it retired on 2026-09-26.
16
16
  */
17
17
 
18
- import { formatAddress } from "@mailwoman/codex/address/format"
18
+ import { writtenPostcode } from "@mailwoman/codex/labels/postcode/written-groups"
19
19
  import { mulberry32 } from "@mailwoman/core/utils"
20
20
 
21
+ import { formatCorpusRow } from "#surfaces/corpus-row"
21
22
  import type { CanonicalRow } from "#types"
22
23
 
23
24
  /* oxlint-disable sister-software/no-unnamed-threshold -- the bare decimals below are weighted-sampler
@@ -116,25 +117,6 @@ const LOCALE_TAG: Record<string, string> = {
116
117
  NZ: "en-NZ",
117
118
  }
118
119
 
119
- /**
120
- * Canonicalize a postcode to the form the country's template renders,
121
- * so the stored component aligns verbatim against `raw`.
122
- *
123
- * NL is the main case: OA may store `1011AB`, while the NL template emits `1011 AB`.
124
- * Other countries pass through unchanged.
125
- */
126
- function normalizePostcode(postcode: string, country: string): string {
127
- // country-branch: the NL postcode is the one whose source spells it without the space the layout writes.
128
- // The codex postal regimes' canonical spacing per country would replace this.
129
- if (country === "NL") {
130
- const m = /^(\d{4})\s*([A-Za-z]{2})$/.exec(postcode)
131
-
132
- if (m) return `${m[1]} ${m[2]!.toUpperCase()}`
133
- }
134
-
135
- return postcode
136
- }
137
-
138
120
  /**
139
121
  * True when `value` appears verbatim and as a standalone token.
140
122
  */
@@ -185,12 +167,19 @@ export function renderLocaleRow(
185
167
  // Canonicalization uses the country's rendered form.
186
168
  // `postcodeShape: "as-source"` is applied after rendering.
187
169
  if (base.postcode && random() < 0.85) {
188
- components.postcode = normalizePostcode(base.postcode, country)
170
+ // The written form aligns verbatim against `raw`: OA may store `1011AB` where the NL template writes `1011 AB`.
171
+ components.postcode = writtenPostcode(base.postcode, country)
189
172
  }
190
173
 
191
174
  // The region costs no random draw, so a row without one renders exactly as before.
192
175
  // A region the country's layout cannot place, or that doesn't align, falls back to the row without it.
193
- if (opts.withRegion && base.region) {
176
+ // A region that's the locality itself, as the city-state Berlin is, would write the name twice.
177
+ // Such a row (`12347 Berlin, Berlin`) renders without it.
178
+ if (
179
+ opts.withRegion &&
180
+ base.region &&
181
+ base.region.localeCompare(base.locality, undefined, { sensitivity: "base" }) !== 0
182
+ ) {
194
183
  const withRegion = finishLocaleRow({ ...components, region: base.region }, base, country, opts)
195
184
 
196
185
  if (withRegion) return withRegion
@@ -209,9 +198,16 @@ function finishLocaleRow(
209
198
  opts: LocaleRenderOpts
210
199
  ): RenderedLocaleRow | null {
211
200
  const separator = opts.separator ?? ", "
212
- let raw = formatAddress(components, country, { separator, withRegion: Boolean(components.region) })
201
+ const rendered = formatCorpusRow(components, country, { separator, withRegion: Boolean(components.region) })
202
+
203
+ if (!rendered?.raw) return null
213
204
 
214
- if (!raw) return null
205
+ let raw = rendered.raw
206
+
207
+ // The postcode is labeled as the layout printed it: `HR-10000` with its prefix, or the bare domestic `10000`.
208
+ if (components.postcode && rendered.components.postcode) {
209
+ components.postcode = rendered.components.postcode
210
+ }
215
211
 
216
212
  // Optional rewrite: `<street>, <hn>` -> `<street> <hn>`.
217
213
  if (separator === ", " && opts.nativeHouseJoin === "space" && components.house_number) {
@@ -5,6 +5,7 @@
5
5
  * Generates addresses in which a house number, a street and a venue appear together.
6
6
  */
7
7
 
8
+ import { countryRenderForms } from "@mailwoman/codex/country"
8
9
  import { sample } from "@mailwoman/core/math/random"
9
10
 
10
11
  import { layoutAdminTail } from "#synthesizers/tail"
@@ -13,7 +14,8 @@ import type { CanonicalRow } from "#types"
13
14
 
14
15
  /**
15
16
  * The address context for one row.
16
- * The synthesizer fills a missing street or house number.
17
+ *
18
+ * The synthesizer draws a missing house number and refuses a tuple without a street.
17
19
  */
18
20
  export interface HouseVenueBaseTuple {
19
21
  locality: string
@@ -116,28 +118,6 @@ const GB_VENUES: ReadonlyArray<string> = [
116
118
 
117
119
  // #endregion
118
120
 
119
- // #region Fallback street pool
120
-
121
- const FALLBACK_STREETS: ReadonlyArray<string> = [
122
- "Main St",
123
- "Oak Ave",
124
- "Pine Rd",
125
- "Elm Dr",
126
- "Cedar Ln",
127
- "Maple Blvd",
128
- "Birch Ct",
129
- "Walnut Pl",
130
- "Cherry Way",
131
- "Spruce St",
132
- "Park Ave",
133
- "Lake Dr",
134
- "Hill Rd",
135
- "River Ln",
136
- "Forest Blvd",
137
- ]
138
-
139
- // #endregion
140
-
141
121
  // #region House-number generator
142
122
 
143
123
  function randomHouseNumber(random: () => number): string {
@@ -153,26 +133,32 @@ function randomHouseNumber(random: () => number): string {
153
133
 
154
134
  // #region Synthesis
155
135
 
136
+ /**
137
+ * The share of rows that write the venue after the street, as a typed query does.
138
+ *
139
+ * An example of that order is `23 St Aelreds Way, The Royal Oak, York`.
140
+ * The postal operators print the building or business name above the thoroughfare
141
+ * (Royal Mail: `Victoria House / 15 The Street`), so the venue-first order is the majority.
142
+ */
143
+ const VENUE_AFTER_STREET_SHARE = 0.25
144
+
156
145
  const GB_VENUE_POOL_RATE = 0.7
157
146
 
158
147
  const GB_RANGE_NUMBER_RATE = 0.15
159
148
 
149
+ /**
150
+ * The share of rows that end in the country, written in one of `countryRenderForms`.
151
+ */
160
152
  const COUNTRY_APPEND_RATE = 0.3
161
153
 
162
- // Repeated entries weight the sample toward the more common form.
163
- const COUNTRY_SURFACES: Readonly<Record<string, ReadonlyArray<string>>> = {
164
- US: ["United States", "USA"],
165
- GB: ["United Kingdom", "United Kingdom", "United Kingdom", "UK"],
166
- FR: ["France"],
167
- CA: ["Canada"],
168
- AU: ["Australia"],
169
- DE: ["Germany", "Deutschland"],
170
- }
171
-
172
154
  /**
173
- * Synthesizes one row with a house number, a street, a venue and the tuple's admin tail,
174
- * rendered through the country's codex layout.
175
- * A country with no layout yields `null`.
155
+ * Synthesizes one row with a house number, a street, a venue and the tuple's admin tail.
156
+ *
157
+ * The row renders through the country's codex layout.
158
+ * A country with no layout yields `null`, and so does a tuple without a street of its own.
159
+ *
160
+ * A drawn street would write one language's vocabulary into another country's address,
161
+ * as `8 Pine Rd, Le Petit Bistrot, Srikakulam` did.
176
162
  *
177
163
  * GB rows sometimes use British venue names and ranged house numbers.
178
164
  */
@@ -180,16 +166,21 @@ export function synthesizeHouseVenueRow(
180
166
  base: HouseVenueBaseTuple,
181
167
  opts: HouseVenueSynthesisOpts = {}
182
168
  ): SynthesizedHouseVenueRow | null {
169
+ const street = base.street?.trim()
170
+
171
+ if (!street) return null
172
+
183
173
  const random = opts.random ?? Math.random
184
174
  const locale = countryToLocale(base.country)
185
- const template = opts.forceTemplate ?? (random() < 0.5 ? "venue-after-street" : "venue-before-street")
175
+
176
+ const template =
177
+ opts.forceTemplate ?? (random() < VENUE_AFTER_STREET_SHARE ? "venue-after-street" : "venue-before-street")
186
178
 
187
179
  // country-branch: the British venue pool and the ranged house number are GB English data.
188
180
  // A per-country venue pool from the Overture names file would replace the branch.
189
181
  const gbPools = base.country === "GB"
190
182
 
191
183
  const venue = gbPools && random() < GB_VENUE_POOL_RATE ? sample(GB_VENUES, random) : sample(PLAIN_VENUES, random)
192
- const street = base.street ?? sample(FALLBACK_STREETS, random)
193
184
  let houseNumber = base.houseNumber ?? randomHouseNumber(random)
194
185
 
195
186
  if (gbPools && random() < GB_RANGE_NUMBER_RATE && /^\d+$/.test(houseNumber)) {
@@ -199,8 +190,10 @@ export function synthesizeHouseVenueRow(
199
190
  houseNumber = `${start}-${start + span}`
200
191
  }
201
192
 
202
- const countrySurfaces = COUNTRY_SURFACES[base.country]
203
- const countrySurface = countrySurfaces && random() < COUNTRY_APPEND_RATE ? sample(countrySurfaces, random) : undefined
193
+ const countrySurfaces = countryRenderForms(base.country)
194
+
195
+ const countrySurface =
196
+ countrySurfaces.length && random() < COUNTRY_APPEND_RATE ? sample(countrySurfaces, random) : undefined
204
197
 
205
198
  // The layout decides the tail's order and which parts it prints: FR prints no region,
206
199
  // VE keeps the region after the postcode, GB puts the postcode after the locality.
@@ -9,11 +9,11 @@
9
9
  * Output components never include street-side tags.
10
10
  */
11
11
 
12
- import { formatAddressRow } from "@mailwoman/codex/address/format"
13
12
  import type { ComponentDict } from "@mailwoman/codex/address/render"
14
13
  import { countryCodeForTable } from "@mailwoman/codex/country"
15
14
  import { sample } from "@mailwoman/core/math/random"
16
15
 
16
+ import { formatCorpusRow } from "#surfaces/corpus-row"
17
17
  import { countryToLocale } from "#synthesizers/utils"
18
18
  import type { CanonicalRow } from "#types"
19
19
 
@@ -186,7 +186,7 @@ export function synthesizeNoStreetRow(
186
186
  dict.postcode = base.postcode
187
187
  }
188
188
 
189
- const rendered = formatAddressRow(dict, iso2, { singleLine: true })
189
+ const rendered = formatCorpusRow(dict, iso2, { singleLine: true })
190
190
 
191
191
  if (!rendered) return null
192
192
 
@@ -6,11 +6,11 @@
6
6
  * and number form one `po_box` span.
7
7
  */
8
8
 
9
- import { formatAddressRow } from "@mailwoman/codex/address/format"
10
9
  import type { ComponentDict } from "@mailwoman/codex/address/render"
11
10
  import { countryCodeForTable } from "@mailwoman/codex/country"
12
11
  import { sample } from "@mailwoman/core/math/random"
13
12
 
13
+ import { formatCorpusRow } from "#surfaces/corpus-row"
14
14
  import { countryToLocale as baseCountryToLocale, tieredNumber } from "#synthesizers/utils"
15
15
  import type { CanonicalRow } from "#types"
16
16
 
@@ -213,7 +213,7 @@ export function synthesizePoBoxRow(
213
213
  dict.house_number = base.houseNumber
214
214
  }
215
215
 
216
- const rendered = formatAddressRow(dict, iso2, { singleLine: true })
216
+ const rendered = formatCorpusRow(dict, iso2, { singleLine: true })
217
217
 
218
218
  if (!rendered) return null
219
219
 
@@ -225,7 +225,7 @@ export function synthesizePoBoxRow(
225
225
  }
226
226
  }
227
227
 
228
- const rendered = formatAddressRow({ ...adminTail, po_box: poBoxPhrase }, iso2, { singleLine: true })
228
+ const rendered = formatCorpusRow({ ...adminTail, po_box: poBoxPhrase }, iso2, { singleLine: true })
229
229
 
230
230
  if (!rendered) return null
231
231
 
@@ -17,10 +17,11 @@
17
17
  * records beside the postal one.
18
18
  */
19
19
 
20
- import { formatAddressRow } from "@mailwoman/codex/address/format"
21
20
  import { lineJoinForCountry, WRITTEN_LAYOUTS, writtenLayoutForCountry } from "@mailwoman/codex/address/layouts"
22
21
  import type { ComponentDict } from "@mailwoman/codex/address/render"
23
22
 
23
+ import { formatCorpusRow } from "#surfaces/corpus-row"
24
+
24
25
  /**
25
26
  * The admin parts a synthesizer has for a row.
26
27
  */
@@ -73,7 +74,7 @@ export function layoutAdminTail(
73
74
 
74
75
  const code = country.trim().toUpperCase()
75
76
  const layout = opts.random && WRITTEN_LAYOUTS[code] ? writtenLayoutForCountry(code, opts.random()) : null
76
- const row = formatAddressRow(components, country, layout ? { layout } : {})
77
+ const row = formatCorpusRow(components, country, layout ? { layout } : {})
77
78
 
78
79
  if (!row || !row.raw.trim()) return null
79
80