@mailwoman/corpus 11.3.0 → 11.4.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 (336) hide show
  1. package/data/PROVENANCE.md +3 -4
  2. package/data/address-source-register.json +4 -4
  3. package/data/builds/v0.8.23-overlay/OVERLAY_PLAN.json +3656 -0
  4. package/data/builds/v0.8.23-prominent-overlay/OVERLAY_PLAN.json +42 -0
  5. package/data/builds/v0.8.23-rebuild/inputs.json +141 -0
  6. package/data/builds/v0.8.24-rebuild/inputs.json +111 -0
  7. package/data/corpus-source-inputs.json +95 -1
  8. package/data/holdout/evaluation-groups.v0.8.24.json +222158 -0
  9. package/data/license-decisions.json +5 -0
  10. package/data/region-slot-second-level.json +1 -1
  11. package/data/training-configs/v8.11.0-base-c6-90k-v0823-s42.yaml +920 -0
  12. package/data/training-configs/v8.12.0-base-c6-wofreps-v0823-s42.yaml +944 -0
  13. package/data/training-configs/v8.13.0-base-c6-wofreps-v0822-s42.yaml +918 -0
  14. package/lib/adapters/cordis/adapter.ts +3 -2
  15. package/lib/adapters/gleif/adapter.ts +123 -20
  16. package/lib/adapters/openaddresses/adapter.ts +2 -2
  17. package/lib/adapters/osm/adapter.ts +62 -4
  18. package/lib/adapters/overture/adapter.ts +97 -15
  19. package/lib/adapters/overture/address-key.ts +89 -0
  20. package/lib/adapters/overture/places-in/adapter.ts +258 -0
  21. package/lib/adapters/street/convention.ts +49 -0
  22. package/lib/adapters/street/country-line.ts +65 -0
  23. package/lib/adapters/wof/admin/json/adapter.ts +4 -4
  24. package/lib/adapters/wof/admin/json/region-codes.ts +98 -0
  25. package/lib/adapters/wof/json-rows.ts +2 -2
  26. package/lib/adapters.ts +2 -0
  27. package/lib/build/align/range.ts +21 -11
  28. package/lib/build/align/totals.ts +20 -0
  29. package/lib/build/align.ts +218 -20
  30. package/lib/build/budget.ts +55 -20
  31. package/lib/build/checkpoint.ts +9 -0
  32. package/lib/build/component-check.ts +97 -3
  33. package/lib/build/inputs.ts +122 -31
  34. package/lib/build/manifest.ts +1 -0
  35. package/lib/build/parallel.ts +140 -23
  36. package/lib/build/{region-names.ts → region/names.ts} +16 -4
  37. package/lib/build/region/recount.ts +153 -0
  38. package/lib/build/reuse.ts +112 -0
  39. package/lib/build/settings.ts +84 -3
  40. package/lib/build/source-record.ts +45 -8
  41. package/lib/build/types.ts +26 -0
  42. package/lib/build/worker.ts +75 -10
  43. package/lib/build.ts +2 -1
  44. package/lib/de/recipes/locale.ts +9 -3
  45. package/lib/evaluation/corpus-adapter.ts +2 -2
  46. package/lib/fi/adapters/ryhti/adapter.ts +2 -2
  47. package/lib/fo/adapters/adressur/adapter.ts +2 -2
  48. package/lib/fr/recipes/lieudit.ts +3 -4
  49. package/lib/in/street-line/segment.ts +370 -0
  50. package/lib/international/recipes/locale.ts +6 -3
  51. package/lib/li/adapters/llv/adapter.ts +2 -2
  52. package/lib/lu/adapters/bd-adresses/adapter.ts +2 -2
  53. package/lib/no/adapters/matrikkelen/adapter.ts +2 -2
  54. package/lib/parquet/streams.ts +18 -3
  55. package/lib/parquet/writers.ts +161 -29
  56. package/lib/recipes/country-balanced.ts +32 -18
  57. package/lib/recipes/fragment-assay/build.ts +8 -5
  58. package/lib/recipes/fragment-assay/rows.ts +4 -4
  59. package/lib/recipes/house/venue.ts +2 -1
  60. package/lib/recipes/postal/guideline/leg.ts +3 -2
  61. package/lib/recipes/prominent/places.ts +4 -4
  62. package/lib/runner.ts +139 -20
  63. package/lib/sg/recipes/register.ts +6 -1
  64. package/lib/source-register/row-license.ts +12 -2
  65. package/lib/surfaces/corpus-row.ts +84 -0
  66. package/lib/surfaces/locale.ts +20 -24
  67. package/lib/synthesizers/house-venue.ts +33 -40
  68. package/lib/synthesizers/no-street.ts +2 -2
  69. package/lib/synthesizers/po-box.ts +3 -3
  70. package/lib/synthesizers/tail.ts +3 -2
  71. package/lib/synthesizers/utils.ts +95 -56
  72. package/lib/test-kit.ts +50 -1
  73. package/lib/tools/fetch/overture-places-in.ts +118 -0
  74. package/lib/tools/fetch/storage.ts +3 -0
  75. package/lib/tools/fetch.ts +2 -0
  76. package/lib/tools/region-slot-census.run.ts +2 -2
  77. package/lib/types.ts +39 -0
  78. package/lib/us/adapters/state/tx-notaries/adapter.ts +2 -1
  79. package/lib/us/adapters/usgov/imls-pls/adapter.ts +2 -1
  80. package/lib/us/adapters/usgov/nad/adapter.ts +32 -4
  81. package/lib/us/adapters/usgov/nad/address-key.ts +8 -47
  82. package/lib/us/adapters/usgov/nppes/adapter.ts +2 -1
  83. package/lib/utils/address-key.ts +57 -0
  84. package/lib/utils/align.ts +22 -10
  85. package/lib/utils/evaluation-groups.ts +13 -6
  86. package/lib/utils/split.ts +24 -3
  87. package/out/adapters/cordis/adapter.d.ts.map +1 -1
  88. package/out/adapters/cordis/adapter.js +3 -2
  89. package/out/adapters/cordis/adapter.js.map +1 -1
  90. package/out/adapters/gleif/adapter.d.ts +4 -0
  91. package/out/adapters/gleif/adapter.d.ts.map +1 -1
  92. package/out/adapters/gleif/adapter.js +100 -20
  93. package/out/adapters/gleif/adapter.js.map +1 -1
  94. package/out/adapters/openaddresses/adapter.js +2 -2
  95. package/out/adapters/openaddresses/adapter.js.map +1 -1
  96. package/out/adapters/osm/adapter.d.ts +9 -0
  97. package/out/adapters/osm/adapter.d.ts.map +1 -1
  98. package/out/adapters/osm/adapter.js +55 -13
  99. package/out/adapters/osm/adapter.js.map +1 -1
  100. package/out/adapters/overture/adapter.d.ts +6 -0
  101. package/out/adapters/overture/adapter.d.ts.map +1 -1
  102. package/out/adapters/overture/adapter.js +72 -9
  103. package/out/adapters/overture/adapter.js.map +1 -1
  104. package/out/adapters/overture/address-key.d.ts +39 -0
  105. package/out/adapters/overture/address-key.d.ts.map +1 -0
  106. package/out/adapters/overture/address-key.js +75 -0
  107. package/out/adapters/overture/address-key.js.map +1 -0
  108. package/out/adapters/overture/places-in/adapter.d.ts +20 -0
  109. package/out/adapters/overture/places-in/adapter.d.ts.map +1 -0
  110. package/out/adapters/overture/places-in/adapter.js +191 -0
  111. package/out/adapters/overture/places-in/adapter.js.map +1 -0
  112. package/out/adapters/street/convention.d.ts +11 -0
  113. package/out/adapters/street/convention.d.ts.map +1 -0
  114. package/out/adapters/street/convention.js +40 -0
  115. package/out/adapters/street/convention.js.map +1 -0
  116. package/out/adapters/street/country-line.d.ts +31 -0
  117. package/out/adapters/street/country-line.d.ts.map +1 -0
  118. package/out/adapters/street/country-line.js +31 -0
  119. package/out/adapters/street/country-line.js.map +1 -0
  120. package/out/adapters/wof/admin/json/adapter.js +4 -4
  121. package/out/adapters/wof/admin/json/adapter.js.map +1 -1
  122. package/out/adapters/wof/admin/json/region-codes.d.ts +5 -0
  123. package/out/adapters/wof/admin/json/region-codes.d.ts.map +1 -1
  124. package/out/adapters/wof/admin/json/region-codes.js +83 -0
  125. package/out/adapters/wof/admin/json/region-codes.js.map +1 -1
  126. package/out/adapters/wof/json-rows.d.ts.map +1 -1
  127. package/out/adapters/wof/json-rows.js +2 -2
  128. package/out/adapters/wof/json-rows.js.map +1 -1
  129. package/out/adapters.d.ts.map +1 -1
  130. package/out/adapters.js +2 -0
  131. package/out/adapters.js.map +1 -1
  132. package/out/build/align/range.d.ts +7 -3
  133. package/out/build/align/range.d.ts.map +1 -1
  134. package/out/build/align/range.js +17 -9
  135. package/out/build/align/range.js.map +1 -1
  136. package/out/build/align/totals.d.ts +12 -0
  137. package/out/build/align/totals.d.ts.map +1 -1
  138. package/out/build/align/totals.js +8 -0
  139. package/out/build/align/totals.js.map +1 -1
  140. package/out/build/align.d.ts +60 -5
  141. package/out/build/align.d.ts.map +1 -1
  142. package/out/build/align.js +136 -12
  143. package/out/build/align.js.map +1 -1
  144. package/out/build/budget.d.ts +35 -11
  145. package/out/build/budget.d.ts.map +1 -1
  146. package/out/build/budget.js +52 -20
  147. package/out/build/budget.js.map +1 -1
  148. package/out/build/checkpoint.d.ts +9 -0
  149. package/out/build/checkpoint.d.ts.map +1 -1
  150. package/out/build/checkpoint.js.map +1 -1
  151. package/out/build/component-check.d.ts +29 -1
  152. package/out/build/component-check.d.ts.map +1 -1
  153. package/out/build/component-check.js +57 -2
  154. package/out/build/component-check.js.map +1 -1
  155. package/out/build/inputs.d.ts +58 -0
  156. package/out/build/inputs.d.ts.map +1 -1
  157. package/out/build/inputs.js +57 -20
  158. package/out/build/inputs.js.map +1 -1
  159. package/out/build/manifest.d.ts.map +1 -1
  160. package/out/build/manifest.js +1 -0
  161. package/out/build/manifest.js.map +1 -1
  162. package/out/build/parallel.d.ts +19 -1
  163. package/out/build/parallel.d.ts.map +1 -1
  164. package/out/build/parallel.js +92 -11
  165. package/out/build/parallel.js.map +1 -1
  166. package/out/build/{region-names.d.ts → region/names.d.ts} +10 -1
  167. package/out/build/region/names.d.ts.map +1 -0
  168. package/out/build/{region-names.js → region/names.js} +16 -5
  169. package/out/build/region/names.js.map +1 -0
  170. package/out/build/region/recount.d.ts +47 -0
  171. package/out/build/region/recount.d.ts.map +1 -0
  172. package/out/build/region/recount.js +105 -0
  173. package/out/build/region/recount.js.map +1 -0
  174. package/out/build/reuse.d.ts +31 -0
  175. package/out/build/reuse.d.ts.map +1 -0
  176. package/out/build/reuse.js +50 -0
  177. package/out/build/reuse.js.map +1 -0
  178. package/out/build/settings.d.ts +38 -0
  179. package/out/build/settings.d.ts.map +1 -1
  180. package/out/build/settings.js +67 -3
  181. package/out/build/settings.js.map +1 -1
  182. package/out/build/source-record.d.ts +32 -7
  183. package/out/build/source-record.d.ts.map +1 -1
  184. package/out/build/source-record.js +17 -4
  185. package/out/build/source-record.js.map +1 -1
  186. package/out/build/types.d.ts +24 -0
  187. package/out/build/types.d.ts.map +1 -1
  188. package/out/build/worker.d.ts +17 -0
  189. package/out/build/worker.d.ts.map +1 -1
  190. package/out/build/worker.js +44 -9
  191. package/out/build/worker.js.map +1 -1
  192. package/out/build.d.ts.map +1 -1
  193. package/out/build.js +2 -1
  194. package/out/build.js.map +1 -1
  195. package/out/de/recipes/locale.d.ts.map +1 -1
  196. package/out/de/recipes/locale.js +9 -3
  197. package/out/de/recipes/locale.js.map +1 -1
  198. package/out/evaluation/corpus-adapter.d.ts +14 -0
  199. package/out/evaluation/corpus-adapter.d.ts.map +1 -1
  200. package/out/evaluation/corpus-adapter.js +2 -16
  201. package/out/evaluation/corpus-adapter.js.map +1 -1
  202. package/out/fi/adapters/ryhti/adapter.js +2 -2
  203. package/out/fi/adapters/ryhti/adapter.js.map +1 -1
  204. package/out/fo/adapters/adressur/adapter.js +2 -2
  205. package/out/fo/adapters/adressur/adapter.js.map +1 -1
  206. package/out/fr/recipes/lieudit.d.ts.map +1 -1
  207. package/out/fr/recipes/lieudit.js +3 -3
  208. package/out/fr/recipes/lieudit.js.map +1 -1
  209. package/out/in/street-line/segment.d.ts +75 -0
  210. package/out/in/street-line/segment.d.ts.map +1 -0
  211. package/out/in/street-line/segment.js +298 -0
  212. package/out/in/street-line/segment.js.map +1 -0
  213. package/out/international/recipes/locale.d.ts.map +1 -1
  214. package/out/international/recipes/locale.js +6 -3
  215. package/out/international/recipes/locale.js.map +1 -1
  216. package/out/li/adapters/llv/adapter.js +2 -2
  217. package/out/li/adapters/llv/adapter.js.map +1 -1
  218. package/out/lu/adapters/bd-adresses/adapter.js +2 -2
  219. package/out/lu/adapters/bd-adresses/adapter.js.map +1 -1
  220. package/out/no/adapters/matrikkelen/adapter.js +2 -2
  221. package/out/no/adapters/matrikkelen/adapter.js.map +1 -1
  222. package/out/parquet/streams.d.ts +9 -0
  223. package/out/parquet/streams.d.ts.map +1 -1
  224. package/out/parquet/streams.js +7 -3
  225. package/out/parquet/streams.js.map +1 -1
  226. package/out/parquet/writers.d.ts +55 -2
  227. package/out/parquet/writers.d.ts.map +1 -1
  228. package/out/parquet/writers.js +109 -27
  229. package/out/parquet/writers.js.map +1 -1
  230. package/out/recipes/country-balanced.d.ts.map +1 -1
  231. package/out/recipes/country-balanced.js +32 -15
  232. package/out/recipes/country-balanced.js.map +1 -1
  233. package/out/recipes/fragment-assay/build.d.ts +5 -2
  234. package/out/recipes/fragment-assay/build.d.ts.map +1 -1
  235. package/out/recipes/fragment-assay/build.js +8 -5
  236. package/out/recipes/fragment-assay/build.js.map +1 -1
  237. package/out/recipes/fragment-assay/rows.d.ts +2 -2
  238. package/out/recipes/fragment-assay/rows.js +4 -4
  239. package/out/recipes/fragment-assay/rows.js.map +1 -1
  240. package/out/recipes/house/venue.d.ts.map +1 -1
  241. package/out/recipes/house/venue.js +2 -1
  242. package/out/recipes/house/venue.js.map +1 -1
  243. package/out/recipes/postal/guideline/leg.d.ts.map +1 -1
  244. package/out/recipes/postal/guideline/leg.js +2 -7
  245. package/out/recipes/postal/guideline/leg.js.map +1 -1
  246. package/out/recipes/prominent/places.js +4 -4
  247. package/out/recipes/prominent/places.js.map +1 -1
  248. package/out/runner.d.ts +28 -0
  249. package/out/runner.d.ts.map +1 -1
  250. package/out/runner.js +85 -18
  251. package/out/runner.js.map +1 -1
  252. package/out/sg/recipes/register.d.ts.map +1 -1
  253. package/out/sg/recipes/register.js +6 -1
  254. package/out/sg/recipes/register.js.map +1 -1
  255. package/out/source-register/row-license.d.ts +8 -0
  256. package/out/source-register/row-license.d.ts.map +1 -1
  257. package/out/source-register/row-license.js +10 -2
  258. package/out/source-register/row-license.js.map +1 -1
  259. package/out/surfaces/corpus-row.d.ts +32 -0
  260. package/out/surfaces/corpus-row.d.ts.map +1 -0
  261. package/out/surfaces/corpus-row.js +70 -0
  262. package/out/surfaces/corpus-row.js.map +1 -0
  263. package/out/surfaces/locale.d.ts.map +1 -1
  264. package/out/surfaces/locale.js +16 -22
  265. package/out/surfaces/locale.js.map +1 -1
  266. package/out/synthesizers/house-venue.d.ts +9 -4
  267. package/out/synthesizers/house-venue.d.ts.map +1 -1
  268. package/out/synthesizers/house-venue.js +25 -35
  269. package/out/synthesizers/house-venue.js.map +1 -1
  270. package/out/synthesizers/no-street.js +2 -9
  271. package/out/synthesizers/no-street.js.map +1 -1
  272. package/out/synthesizers/po-box.js +3 -7
  273. package/out/synthesizers/po-box.js.map +1 -1
  274. package/out/synthesizers/tail.d.ts.map +1 -1
  275. package/out/synthesizers/tail.js +2 -2
  276. package/out/synthesizers/tail.js.map +1 -1
  277. package/out/synthesizers/utils.d.ts +20 -3
  278. package/out/synthesizers/utils.d.ts.map +1 -1
  279. package/out/synthesizers/utils.js +74 -57
  280. package/out/synthesizers/utils.js.map +1 -1
  281. package/out/test-kit.d.ts +11 -0
  282. package/out/test-kit.d.ts.map +1 -1
  283. package/out/test-kit.js +30 -1
  284. package/out/test-kit.js.map +1 -1
  285. package/out/tools/fetch/overture-places-in.d.ts +14 -0
  286. package/out/tools/fetch/overture-places-in.d.ts.map +1 -0
  287. package/out/tools/fetch/overture-places-in.js +82 -0
  288. package/out/tools/fetch/overture-places-in.js.map +1 -0
  289. package/out/tools/fetch/storage.d.ts +2 -0
  290. package/out/tools/fetch/storage.d.ts.map +1 -1
  291. package/out/tools/fetch/storage.js +3 -0
  292. package/out/tools/fetch/storage.js.map +1 -1
  293. package/out/tools/fetch.d.ts +2 -0
  294. package/out/tools/fetch.d.ts.map +1 -1
  295. package/out/tools/fetch.js +2 -0
  296. package/out/tools/fetch.js.map +1 -1
  297. package/out/tools/region-slot-census.run.js +2 -2
  298. package/out/types.d.ts +41 -0
  299. package/out/types.d.ts.map +1 -1
  300. package/out/types.js.map +1 -1
  301. package/out/us/adapters/state/tx-notaries/adapter.d.ts.map +1 -1
  302. package/out/us/adapters/state/tx-notaries/adapter.js +2 -1
  303. package/out/us/adapters/state/tx-notaries/adapter.js.map +1 -1
  304. package/out/us/adapters/usgov/imls-pls/adapter.d.ts.map +1 -1
  305. package/out/us/adapters/usgov/imls-pls/adapter.js +2 -1
  306. package/out/us/adapters/usgov/imls-pls/adapter.js.map +1 -1
  307. package/out/us/adapters/usgov/nad/adapter.d.ts +15 -0
  308. package/out/us/adapters/usgov/nad/adapter.d.ts.map +1 -1
  309. package/out/us/adapters/usgov/nad/adapter.js +21 -3
  310. package/out/us/adapters/usgov/nad/adapter.js.map +1 -1
  311. package/out/us/adapters/usgov/nad/address-key.d.ts +1 -5
  312. package/out/us/adapters/usgov/nad/address-key.d.ts.map +1 -1
  313. package/out/us/adapters/usgov/nad/address-key.js +8 -33
  314. package/out/us/adapters/usgov/nad/address-key.js.map +1 -1
  315. package/out/us/adapters/usgov/nppes/adapter.d.ts.map +1 -1
  316. package/out/us/adapters/usgov/nppes/adapter.js +2 -1
  317. package/out/us/adapters/usgov/nppes/adapter.js.map +1 -1
  318. package/out/utils/address-key.d.ts +23 -0
  319. package/out/utils/address-key.d.ts.map +1 -0
  320. package/out/utils/address-key.js +43 -0
  321. package/out/utils/address-key.js.map +1 -0
  322. package/out/utils/align.d.ts +7 -0
  323. package/out/utils/align.d.ts.map +1 -1
  324. package/out/utils/align.js +18 -8
  325. package/out/utils/align.js.map +1 -1
  326. package/out/utils/evaluation-groups.d.ts +5 -1
  327. package/out/utils/evaluation-groups.d.ts.map +1 -1
  328. package/out/utils/evaluation-groups.js +12 -1
  329. package/out/utils/evaluation-groups.js.map +1 -1
  330. package/out/utils/split.d.ts +11 -0
  331. package/out/utils/split.d.ts.map +1 -1
  332. package/out/utils/split.js +18 -3
  333. package/out/utils/split.js.map +1 -1
  334. package/package.json +19 -19
  335. package/out/build/region-names.d.ts.map +0 -1
  336. package/out/build/region-names.js.map +0 -1
@@ -123,7 +123,7 @@
123
123
  */
124
124
 
125
125
  import { ConventionClaimID, ObservationStance } from "@mailwoman/codex/address/convention-claims"
126
- import { formatAddressRow, scriptOfComponents } from "@mailwoman/codex/address/format"
126
+ import { scriptOfComponents } from "@mailwoman/codex/address/format"
127
127
  import { conventionClaimForCountry, layoutForCountry } from "@mailwoman/codex/address/layouts"
128
128
  import { CountryISO2 } from "@mailwoman/codex/country/codes"
129
129
  import { matchCountry } from "@mailwoman/codex/country/country"
@@ -139,6 +139,7 @@ import { joinRepetitionIndex } from "#adapters/street/repetition"
139
139
  import { createUnitSplitter, type UnitSplitter } from "#adapters/street/unit"
140
140
  import { SourceRegister } from "#registers"
141
141
  import { streetIndexOpener } from "#street-index/reader"
142
+ import { formatCorpusRow } from "#surfaces/corpus-row"
142
143
  import {
143
144
  AddressRole,
144
145
  type AdapterOptions,
@@ -609,7 +610,7 @@ export function readCORDISRecord(
609
610
  // That keeps a country's local order whenever its Latin order has fewer slots:
610
611
  // `Weixing Road` and `Changchun` would otherwise print run together in China's
611
612
  // Han-script line, with no separator between them.
612
- const rendered = formatAddressRow(components, country, {
613
+ const rendered = formatCorpusRow(components, country, {
613
614
  singleLine: true,
614
615
  script: scriptOfComponents(components, country),
615
616
  })
@@ -91,12 +91,26 @@
91
91
  * when it holds a letter, as `Suite 4` does.
92
92
  * A bare number there would render as a second house number.
93
93
  *
94
+ * Where the split refuses a line as `street-number-unplaced` or `street-line-segmented`,
95
+ * a country with its own street-line reader (`streetLineReaderFor`) reads the line instead.
96
+ * India's reader labels `NO. 1034, 3RD FLOOR, 1ST MAIN ROAD` as the premise
97
+ * number `1034` and the street `1ST MAIN ROAD`.
98
+ *
99
+ * A reading that needs a building name is refused, because the legal name holds the row's `venue`.
100
+ *
94
101
  * ## Region
95
102
  *
96
103
  * `Region` is an ISO 3166-2 code such as `SK-KI`, which isn't how an address writes the region.
97
- * It reaches a row only where the code's suffix is the written form.
104
+ * It reaches a row as the form the country's addresses write for it.
105
+ *
106
+ * `matchSubdivisionIn` answers for the United States, Canada and Australia, where addresses write the code.
107
+ * For every other country, `citedSubdivisionForISO` reads the libaddressinput key
108
+ * listed beside the ISO id: `IN-MH` becomes `Maharashtra`.
98
109
  *
99
- * `matchSubdivisionIn` answers for the United States, Canada and Australia.
110
+ * It answers only where the country's codex layout prints a region and its primary citation writes
111
+ * one of those keys in an example, because libaddressinput is a dataset rather than a citation.
112
+ *
113
+ * Any other country gets no region.
100
114
  * A code whose country prefix differs from `Country` refuses the address as contradicting it.
101
115
  *
102
116
  * ## One row per address
@@ -123,13 +137,17 @@ import { Globerator } from "spliterator/node/fs"
123
137
 
124
138
  import { UnsupportedCountryError } from "#adapters/errors"
125
139
  import { stableSourceID } from "#adapters/source-id"
140
+ import { withConventionStreet } from "#adapters/street/convention"
141
+ import { type CountryStreetLineContext, streetLineReaderFor } from "#adapters/street/country-line"
126
142
  import { splitStreetLine, splitTrailingStreetLine } from "#adapters/street/line"
127
143
  import { joinRepetitionIndex, withoutRepetitionIndex } from "#adapters/street/repetition"
128
144
  import { createUnitSplitter, type UnitSplitter } from "#adapters/street/unit"
145
+ import { citedSubdivisionForISO } from "#adapters/wof/admin/json/region-codes"
129
146
  import { FingerprintSet } from "#fingerprints"
130
147
  import { isPlaceholderValue } from "#it/adapters/anac/adapter"
131
148
  import { SourceRegister } from "#registers"
132
149
  import { streetIndexOpener } from "#street-index/reader"
150
+ import { formatCorpusRow } from "#surfaces/corpus-row"
133
151
  import {
134
152
  AddressRole,
135
153
  type AdapterOptions,
@@ -345,7 +363,15 @@ export type GLEIFRecord = Readonly<Record<string, string | undefined>>
345
363
  /**
346
364
  * What one address block yielded: a row, or the reason it yielded none.
347
365
  */
348
- export type GLEIFAddressReading = { readonly admitted: CanonicalRow } | { readonly refused: GLEIFRefusal }
366
+ export type GLEIFAddressReading =
367
+ | {
368
+ readonly admitted: CanonicalRow
369
+ /**
370
+ * Whether the country's own street-line reader read the line after the generic split refused it.
371
+ */
372
+ readonly byCountryReader: boolean
373
+ }
374
+ | { readonly refused: GLEIFRefusal }
349
375
 
350
376
  /**
351
377
  * The address fields a block holds, in the order the CDF lists them.
@@ -577,6 +603,10 @@ export function readGLEIFAddress(
577
603
  }
578
604
 
579
605
  const script = scriptOfComponents({ street: line, locality: city }, country)
606
+ const regionSuffix = regionCode ? regionCode.slice(country.length + 1) : ""
607
+ const codedRegion = regionSuffix && matchSubdivisionIn(country, regionSuffix) ? regionSuffix : null
608
+ const lookedUpRegion = regionSuffix && !codedRegion ? citedSubdivisionForISO(country, regionSuffix) : null
609
+ let byCountryReader = false
580
610
 
581
611
  if (PO_BOX_LINE.test(line)) {
582
612
  components.po_box = line
@@ -592,20 +622,27 @@ export function readGLEIFAddress(
592
622
  script
593
623
  )
594
624
 
595
- if ("refused" in placed) return placed
625
+ if ("refused" in placed) {
626
+ const read = readByCountryReader(placed.refused, line, country, { locality: city, region: lookedUpRegion })
596
627
 
597
- if (placed.house_number) {
598
- components.house_number = placed.house_number
599
- }
628
+ if (!read) return placed
600
629
 
601
- components.street = placed.street
630
+ Object.assign(components, read)
631
+ byCountryReader = true
632
+ } else {
633
+ if (placed.house_number) {
634
+ components.house_number = placed.house_number
635
+ }
602
636
 
603
- const unit = addressField(record, block, "AddressNumberWithinBuilding")
637
+ components.street = placed.street
604
638
 
605
- if (lineUnit) {
606
- components.unit = lineUnit.unit
607
- } else if (unit && /\p{L}/u.test(unit) && !unit.includes(",") && !line.includes(unit)) {
608
- components.unit = unit
639
+ const unit = addressField(record, block, "AddressNumberWithinBuilding")
640
+
641
+ if (lineUnit) {
642
+ components.unit = lineUnit.unit
643
+ } else if (unit && /\p{L}/u.test(unit) && !unit.includes(",") && !line.includes(unit)) {
644
+ components.unit = unit
645
+ }
609
646
  }
610
647
  }
611
648
 
@@ -617,15 +654,13 @@ export function readGLEIFAddress(
617
654
 
618
655
  components.locality = city
619
656
 
620
- if (regionCode) {
621
- const suffix = regionCode.slice(country.length + 1)
657
+ const region = codedRegion ?? lookedUpRegion
622
658
 
623
- if (matchSubdivisionIn(country, suffix)) {
624
- components.region = suffix
625
- }
659
+ if (region) {
660
+ components.region = region
626
661
  }
627
662
 
628
- const rendered = formatAddressRow(components, country, { singleLine: true, script })
663
+ const rendered = formatCorpusRow(withConventionStreet(components, country), country, { singleLine: true, script })
629
664
 
630
665
  if (!rendered) return { refused: GLEIFRefusal.Unrenderable }
631
666
 
@@ -635,16 +670,57 @@ export function readGLEIFAddress(
635
670
  return { refused: GLEIFRefusal.ComponentsTooFew }
636
671
  }
637
672
 
673
+ // A region read through `citedSubdivisionForISO` stays out of the id, so a row built
674
+ // before that lookup existed keeps the id the evaluation groups hold it under.
675
+ const { region: _region, ...withoutLookedUpRegion } = aligned
676
+ const identity = lookedUpRegion ? withoutLookedUpRegion : aligned
677
+
638
678
  return {
639
679
  admitted: {
640
680
  raw,
641
681
  components: aligned,
642
682
  country,
643
683
  source: GLEIF_ADAPTER_ID,
644
- source_id: stableSourceID(GLEIF_ADAPTER_ID, { country, ...aligned }),
684
+ source_id: stableSourceID(GLEIF_ADAPTER_ID, { country, ...identity }),
645
685
  license: GLEIF_LICENSE,
646
686
  addressRole: block === GLEIFAddressBlock.Legal ? AddressRole.RegisteredOffice : AddressRole.Facility,
647
687
  },
688
+ byCountryReader,
689
+ }
690
+ }
691
+
692
+ /**
693
+ * The refusals of the generic split that a country's own street-line reader may still read:
694
+ * a digit the split couldn't place, and a line that joins several comma-separated parts.
695
+ */
696
+ const COUNTRY_READER_REFUSALS: ReadonlySet<GLEIFRefusal> = new Set([
697
+ GLEIFRefusal.StreetNumberUnplaced,
698
+ GLEIFRefusal.StreetLineSegmented,
699
+ ])
700
+
701
+ /**
702
+ * Read a line the generic split refused through the country's own street-line reader
703
+ * (`streetLineReaderFor`), or return `null` when the country has none or the reader refuses it too.
704
+ *
705
+ * A line whose reading needs a building name is refused as well, because the entity's
706
+ * legal name already holds the row's one `venue` slot.
707
+ */
708
+ function readByCountryReader(
709
+ refusal: GLEIFRefusal,
710
+ line: string,
711
+ country: string,
712
+ context: CountryStreetLineContext
713
+ ): Pick<CanonicalRow["components"], "house_number" | "street" | "dependent_locality"> | null {
714
+ if (!COUNTRY_READER_REFUSALS.has(refusal)) return null
715
+
716
+ const read = streetLineReaderFor(country)?.(line, context)
717
+
718
+ if (!read || "refused" in read || read.building) return null
719
+
720
+ return {
721
+ ...(read.house_number ? { house_number: read.house_number } : {}),
722
+ street: read.street,
723
+ ...(read.dependent_locality ? { dependent_locality: read.dependent_locality } : {}),
648
724
  }
649
725
  }
650
726
 
@@ -780,6 +856,8 @@ export function createGLEIFAdapter(): CorpusAdapter {
780
856
  const units = await createUnitSplitter({ streetIndex: streetIndexOpener(opts.streetIndex) })
781
857
  let count = 0
782
858
  let checkedHeader = false
859
+ // The rows a country's street-line reader read, held in memory: 12,722 for India over the 2026-10-03 golden copy.
860
+ const countryReaderRows: CanonicalRow[] = []
783
861
 
784
862
  for await (const record of readGLEIFRecords(opts.inputPath)) {
785
863
  if (opts.signal?.aborted) break
@@ -822,6 +900,12 @@ export function createGLEIFAdapter(): CorpusAdapter {
822
900
 
823
901
  if (wanted && row.country !== wanted) continue
824
902
 
903
+ if (reading.byCountryReader) {
904
+ countryReaderRows.push(row)
905
+
906
+ continue
907
+ }
908
+
825
909
  if (!emitted.add(addressKey(row))) {
826
910
  countDropped(opts, "row:address-already-emitted")
827
911
 
@@ -833,6 +917,25 @@ export function createGLEIFAdapter(): CorpusAdapter {
833
917
  count++
834
918
  }
835
919
  }
920
+
921
+ // A row a country's reader read is held until every row of the generic split has
922
+ // claimed its address, so it never takes the address of a row that corpora built
923
+ // before the reader existed already hold.
924
+ for (const row of countryReaderRows) {
925
+ if (opts.signal?.aborted) break
926
+
927
+ if (typeof opts.limit === "number" && count >= opts.limit) break
928
+
929
+ if (!emitted.add(addressKey(row))) {
930
+ countDropped(opts, "row:address-already-emitted")
931
+
932
+ continue
933
+ }
934
+
935
+ yield row
936
+
937
+ count++
938
+ }
836
939
  },
837
940
  }
838
941
  }
@@ -13,13 +13,13 @@
13
13
  * The adapter omits that field because mapping it would inflate alignment quarantine.
14
14
  */
15
15
 
16
- import { formatAddressRow } from "@mailwoman/codex/address/format"
17
16
  import { tryParsingJSON } from "@mailwoman/core/values/json"
18
17
  import { createLicenseVerdictCache, LicensePolicy } from "@mailwoman/license/policy"
19
18
  import { TextSpliterator } from "spliterator"
20
19
 
21
20
  import { stableSourceID } from "#adapters/source-id"
22
21
  import { SourceRegister } from "#registers"
22
+ import { formatCorpusRow } from "#surfaces/corpus-row"
23
23
  import { AddressRole, type AdapterOptions, type CanonicalRow, type CorpusAdapter, SurfaceOrigin } from "#types"
24
24
 
25
25
  /**
@@ -209,7 +209,7 @@ export function createOpenaddressesAdapter(opts: OpenaddressesAdapterOptions = {
209
209
  components.postcode = postcode
210
210
  }
211
211
 
212
- const rendered = formatAddressRow(components, country, { singleLine: true })
212
+ const rendered = formatCorpusRow(components, country, { singleLine: true })
213
213
 
214
214
  if (!rendered) continue
215
215
 
@@ -11,9 +11,9 @@
11
11
  * That's why `defaultLicense` isn't an option on this adapter.
12
12
  */
13
13
 
14
- import { formatAddressRow } from "@mailwoman/codex/address/format"
15
14
  import type { ComponentTag } from "@mailwoman/codex/component"
16
15
  import { countryDisplayNames } from "@mailwoman/codex/country/display-names"
16
+ import { countriesDeclaredBy, hasCountry } from "@mailwoman/codex/country/sets"
17
17
  import { sha256Hex } from "@mailwoman/core/crypto/hash"
18
18
  import { extractDelimited } from "@mailwoman/core/scripting/arguments"
19
19
  import { tryParsingJSON } from "@mailwoman/core/values/json"
@@ -24,6 +24,7 @@ import { TextSpliterator } from "spliterator"
24
24
  import { OSM_LICENSE } from "#adapters/osm/license"
25
25
  import { stableSourceID } from "#adapters/source-id"
26
26
  import { SourceRegister } from "#registers"
27
+ import { formatCorpusRow } from "#surfaces/corpus-row"
27
28
  import {
28
29
  AddressRole,
29
30
  type AdapterOptions,
@@ -111,6 +112,23 @@ interface OSMCorpusRow {
111
112
 
112
113
  const MAX_STREET_WORDS = 8
113
114
 
115
+ /**
116
+ * The countries whose mappers write the raion that contains the settlement in `addr:district`.
117
+ *
118
+ * Over the October 2026 extracts, every Moldovan `addr:district` value spans more than
119
+ * three settlements (880,282 rows: `Raionul Ialoveni`, `Municipiul Chișinău`).
120
+ * The Russian and Belarusian values do so on 182,210 and 3,042 rows (`Аксайский район`, `Кобрынскі раён`).
121
+ *
122
+ * In other countries the tag holds a part of the city: `Hoàn Kiếm` in Hà Nội,
123
+ * `越秀区` in 广州, `Արաբկիր` in Yerevan.
124
+ * A count of distinct settlements can't separate the two by itself.
125
+ *
126
+ * A city written several ways spans several names too (`黄浦区` under five spellings of Shanghai).
127
+ */
128
+ // country-branch: what `addr:district` denotes is a per-country mapping convention of OpenStreetMap.
129
+ // A WOF ancestry lookup of the district's name above the row's locality would replace this list.
130
+ const OSM_DISTRICT_CONTAINS_LOCALITY = countriesDeclaredBy("OSM addr:district raion convention", ["BY", "MD", "RU"])
131
+
114
132
  /**
115
133
  * Whether `addr:housenumber` holds a street designator — digits with an optional letter,
116
134
  * fraction or dash suffix (`12`, `188a`, `14/E`, `1/1146`, `167-c`) or a one-
@@ -120,9 +138,31 @@ const MAX_STREET_WORDS = 8
120
138
  export function housenumberIsDesignator(value: string): boolean {
121
139
  const trimmed = value.trim()
122
140
 
141
+ if (longestDigitRun(trimmed) > MAX_HOUSE_NUMBER_DIGITS) return false
142
+
123
143
  return /^\d+[A-Za-z]?(?:[/-]\d*[A-Za-z]?)?$/u.test(trimmed) || /^[A-Za-z]{1,2}[-\s]?\d+[A-Za-z]?$/u.test(trimmed)
124
144
  }
125
145
 
146
+ /**
147
+ * The most digits in a row a house number holds.
148
+ *
149
+ * The longest the national registers write are six, the rural grid numbers of the US
150
+ * National Address Database (`129504 US 65 Highway North, Gould, AR`).
151
+ * A run of seven or more in `addr:housenumber` is a telephone number
152
+ * (`22796800` in Costa Rica, `07505156040` in Iraq) or a postcode, in every country's extract alike.
153
+ */
154
+ const MAX_HOUSE_NUMBER_DIGITS = 6
155
+
156
+ function longestDigitRun(value: string): number {
157
+ let longest = 0
158
+
159
+ for (const run of value.match(/\d+/gu) ?? []) {
160
+ longest = Math.max(longest, run.length)
161
+ }
162
+
163
+ return longest
164
+ }
165
+
126
166
  /**
127
167
  * Whether `addr:street` matches the street-name shape.
128
168
  *
@@ -259,10 +299,26 @@ export function componentsForOSMRow(
259
299
  }
260
300
  }
261
301
 
302
+ // Where `addr:district` holds the raion that contains the locality, it is the locality's `subregion`.
303
+ // The country's layout then places it, or drops it and counts the drop.
304
+ const district = clean(row.district)
305
+ const districtContainsLocality = hasCountry(OSM_DISTRICT_CONTAINS_LOCALITY, country)
306
+
307
+ if (district && districtContainsLocality && (!components.locality || !sameName(district, components.locality))) {
308
+ components.subregion = district
309
+ }
310
+
262
311
  // Dependent-locality candidates in priority order (suburb, subdistrict, district, place,
263
312
  // city head, then the containing boundary's name); `district` never becomes `region`,
264
313
  // because Vietnam's country template renders it only when no city is present.
265
- const dependent = [row.suburb, row.subdistrict, row.district, row.place, split?.head, row.boundary_dependent_locality]
314
+ const dependent = [
315
+ row.suburb,
316
+ row.subdistrict,
317
+ districtContainsLocality ? null : row.district,
318
+ row.place,
319
+ split?.head,
320
+ row.boundary_dependent_locality,
321
+ ]
266
322
  .map((value) => clean(value))
267
323
  .find(
268
324
  (value) =>
@@ -292,7 +348,9 @@ export function componentsForOSMRow(
292
348
 
293
349
  // An address row needs another component alongside the street or the streetless house number.
294
350
  // Coarse adapters already teach bare names.
295
- if (Object.keys(components).length === 1) {
351
+ // A subregion doesn't count.
352
+ // The layouts of the countries that write one in `addr:district` print none.
353
+ if (Object.keys(components).filter((tag) => tag !== "subregion").length === 1) {
296
354
  countDropped(tally, street ? "row:street-only" : "row:house-number-only")
297
355
 
298
356
  return null
@@ -378,7 +436,7 @@ export function createOSMAdapter(): CorpusAdapter {
378
436
 
379
437
  if (!components) continue
380
438
 
381
- const rendered = formatAddressRow(components, country, { singleLine: true })
439
+ const rendered = formatCorpusRow(components, country, { singleLine: true })
382
440
 
383
441
  if (!rendered) {
384
442
  countDropped(opts, "row:render-failed")
@@ -8,8 +8,10 @@
8
8
  * The downstream affix-relabel step splits `street_prefix` from that value.
9
9
  */
10
10
 
11
- import { formatAddressRow } from "@mailwoman/codex/address/format"
12
- import { COUNTRY_SURFACE_FORMS } from "@mailwoman/codex/country"
11
+ import { CA_PROVINCES } from "@mailwoman/codex/ca/province"
12
+ import { countryRenderForms } from "@mailwoman/codex/country"
13
+ import { writtenPostcode } from "@mailwoman/codex/labels/postcode/written-groups"
14
+ import { mxStatePostalAbbreviation } from "@mailwoman/codex/mx/state"
13
15
  import { sample } from "@mailwoman/core/math/random"
14
16
  import { mulberry32 as makeMulberry32 } from "@mailwoman/core/utils"
15
17
  import { tryParsingJSON } from "@mailwoman/core/values/json"
@@ -17,12 +19,19 @@ import { TextSpliterator } from "spliterator"
17
19
 
18
20
  import { stableSourceID } from "#adapters/source-id"
19
21
  import { SourceRegister } from "#registers"
22
+ import { formatCorpusRow } from "#surfaces/corpus-row"
20
23
  import { AddressRole, type AdapterOptions, type CanonicalRow, type CorpusAdapter, SurfaceOrigin } from "#types"
21
24
 
22
25
  /**
23
26
  * Registry id stamped into every row this adapter emits, so a corpus record traces back to its dataset.
24
27
  */
25
28
  export const OVERTURE_ADAPTER_ID = "overture"
29
+ /**
30
+ * The `source` the Brazilian, Mexican and Canadian runs of this adapter
31
+ * stamp on their rows (`corpus run overture --source-name overture-latam`),
32
+ * which training configs weight apart from `overture`.
33
+ */
34
+ export const OVERTURE_LATAM_SOURCE = "overture-latam"
26
35
  /**
27
36
  * License assigned by this source (`cdla-Permissive-2.0`, attribution-only
28
37
  * rather than share-alike), attached to every row.
@@ -32,15 +41,15 @@ export const OVERTURE_DEFAULT_LICENSE = "CDLA-Permissive-2.0"
32
41
  const DEFAULT_COUNTRY_SEED = 20_260_922
33
42
 
34
43
  /**
35
- * One attested written form of a country's name.
44
+ * One attested written form of a country's name, never a two-letter code (`countryRenderForms`).
36
45
  *
37
46
  * Raises rather than returning empty when the codex has no entry, so a requested
38
47
  * fraction cannot silently produce no country rows.
39
48
  */
40
49
  function countrySurfaceForm(country: string, random: () => number): string {
41
- const forms = COUNTRY_SURFACE_FORMS[country as keyof typeof COUNTRY_SURFACE_FORMS]
50
+ const forms = countryRenderForms(country)
42
51
 
43
- if (!forms?.length) {
52
+ if (!forms.length) {
44
53
  throw new Error(
45
54
  `No COUNTRY_SURFACE_FORMS entry for ${country} — add it to codex/country/country.ts before using --country-fraction`
46
55
  )
@@ -50,14 +59,77 @@ function countrySurfaceForm(country: string, random: () => number): string {
50
59
  }
51
60
 
52
61
  /**
53
- * The flattened per-row shape emitted by `ingest-overture-addresses.ts --corpus-jsonl`.
62
+ * The flattened per-row shape `mailwoman gazetteer overture-ingest --corpus-jsonl` emits.
63
+ *
64
+ * `region` is Overture's first address level.
65
+ * A file written before the ingest emitted it has none.
54
66
  */
55
67
  interface OvertureCorpusRow {
56
- street?: string
57
- number?: string
58
- unit?: string
59
- postcode?: string
60
- locality?: string
68
+ street?: string | null
69
+ number?: string | null
70
+ unit?: string | null
71
+ postcode?: string | null
72
+ locality?: string | null
73
+ region?: string | null
74
+ }
75
+
76
+ /**
77
+ * What Overture's `unit` field holds in a country where it isn't a secondary unit.
78
+ *
79
+ * - `orientation-number`: the street number (`číslo orientační`) of a building whose
80
+ * `number` is its district-wide descriptive number (`číslo popisné`).
81
+ * The two are written `descriptive/orientation`.
82
+ * - `number-suffix`: a letter written against the house number.
83
+ */
84
+ type OvertureUnitFieldRole = "orientation-number" | "number-suffix"
85
+
86
+ /**
87
+ * The role of Overture's `unit` field in each country where it isn't a secondary unit.
88
+ *
89
+ * Read off the 2026-06-17.0 per-country corpus JSONL: every filled Czech `unit` is digits
90
+ * beside a digit `number` (101,127 of 394,880 rows, such as `Nad Stadiónem` `320` `28`),
91
+ * and in the first 400,000 German rows 17,250 of the 17,304 filled ones are one
92
+ * or two letters (`Neutrale Straße` `28` `a`).
93
+ */
94
+ const OVERTURE_UNIT_FIELD_ROLES: Readonly<Record<string, OvertureUnitFieldRole>> = {
95
+ // UPU, Czech Rep. (02/2018): `The street number often consists of two numbers separated by a slash.
96
+ // The first number is a unique district-related building number [...], the second number is the
97
+ // street number`, as in `Hrušovská 455/10`.
98
+ CZ: "orientation-number",
99
+ // UPU, Germany (01/2015): `Wacholderweg 52a`.
100
+ DE: "number-suffix",
101
+ }
102
+
103
+ /**
104
+ * The house number with the `unit` field joined into it as the country's role for that
105
+ * field states, or `null` when the field doesn't belong in the number.
106
+ */
107
+ function joinUnitIntoNumber(number: string, unit: string, role: OvertureUnitFieldRole | null): string | null {
108
+ if (!role || !/^\d/u.test(number)) return null
109
+
110
+ if (role === "orientation-number") return /^\d+\p{Letter}?$/u.test(unit) ? `${number}/${unit}` : null
111
+
112
+ return /^\p{Letter}{1,2}$/u.test(unit) ? `${number}${unit}` : null
113
+ }
114
+
115
+ /**
116
+ * How a region value in Overture's first address level becomes the form the country's
117
+ * operator prints, for each country where Overture's value can be read as that form.
118
+ *
119
+ * A country absent here renders no region from Overture.
120
+ * Its first level is a unit the operator doesn't print: Italy's is `Sardegna`,
121
+ * where the operator prints the province `RM`.
122
+ */
123
+ const OVERTURE_REGION_FORMS: Readonly<Record<string, (value: string) => string | null>> = {
124
+ // UPU, Brazil (03/2012): `The state abbreviation (two characters) must follow the town's name separated
125
+ // by a dash`, as in `GUARAPUAVA – PR`. Overture writes the two-letter UF (`RS`).
126
+ BR: (value) => (/^[A-Z]{2}$/u.test(value) ? value : null),
127
+ // UPU, Canada (09/2014): `MONTREAL QC H3Z 2Y7`, `QC is the province abbreviation`.
128
+ // Overture writes the ISO 3166-2:CA code, and the code is that abbreviation.
129
+ CA: (value) => (Object.hasOwn(CA_PROVINCES, value) ? value : null),
130
+ // UPU, Mexico (03/2017): `02860 MEXICO, CDMX`.
131
+ // Overture writes the state's name (`Michoacán de Ocampo`).
132
+ MX: mxStatePostalAbbreviation,
61
133
  }
62
134
 
63
135
  /**
@@ -106,6 +178,9 @@ export function createOvertureAdapter(): CorpusAdapter {
106
178
  const country = opts.country
107
179
  const countryFraction = opts.countryFraction ?? 0
108
180
  const random = makeMulberry32(opts.seed ?? DEFAULT_COUNTRY_SEED)
181
+ const code = country.toUpperCase()
182
+ const unitRole = Object.hasOwn(OVERTURE_UNIT_FIELD_ROLES, code) ? OVERTURE_UNIT_FIELD_ROLES[code]! : null
183
+ const regionForm = Object.hasOwn(OVERTURE_REGION_FORMS, code) ? OVERTURE_REGION_FORMS[code]! : null
109
184
 
110
185
  // The path string lets `TextSpliterator` own and dispose the file handle, including on an early `break`.
111
186
  const lines = TextSpliterator.fromAsync(opts.inputPath)
@@ -133,33 +208,40 @@ export function createOvertureAdapter(): CorpusAdapter {
133
208
  if (!postcode && !locality) continue
134
209
 
135
210
  const components: CanonicalRow["components"] = {}
211
+ const joined = unit ? joinUnitIntoNumber(number, unit, unitRole) : null
136
212
 
137
213
  // Overture "S-N" / "S/N" = sin número; only keep a real numeric house number.
138
214
  if (/^\d/.test(number)) {
139
- components.house_number = number
215
+ components.house_number = joined ?? number
140
216
  }
141
217
 
142
218
  components.street = street
143
219
 
144
- if (unitFieldIsDesignator(unit)) {
220
+ if (!joined && unitFieldIsDesignator(unit)) {
145
221
  components.unit = unit
146
222
  }
147
223
 
148
224
  if (postcode) {
149
- components.postcode = postcode
225
+ components.postcode = writtenPostcode(postcode, country)
150
226
  }
151
227
 
152
228
  if (locality) {
153
229
  components.locality = locality
154
230
  }
155
231
 
232
+ const region = regionForm && r.region?.trim() ? regionForm(r.region.trim()) : null
233
+
234
+ if (region) {
235
+ components.region = region
236
+ }
237
+
156
238
  // Overture rows are country-implicit, so the surface form goes into `components`
157
239
  // and each country's layout decides where the country lands in the rendered string.
158
240
  if (countryFraction > 0 && random() < countryFraction) {
159
241
  components.country = countrySurfaceForm(country, random)
160
242
  }
161
243
 
162
- const rendered = formatAddressRow(components, country, { singleLine: true })
244
+ const rendered = formatCorpusRow(components, country, { singleLine: true })
163
245
 
164
246
  if (!rendered) continue
165
247