@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
@@ -3,6 +3,12 @@ import { type CorpusAdapter } from "#types";
3
3
  * Registry id stamped into every row this adapter emits, so a corpus record traces back to its dataset.
4
4
  */
5
5
  export declare const OVERTURE_ADAPTER_ID = "overture";
6
+ /**
7
+ * The `source` the Brazilian, Mexican and Canadian runs of this adapter
8
+ * stamp on their rows (`corpus run overture --source-name overture-latam`),
9
+ * which training configs weight apart from `overture`.
10
+ */
11
+ export declare const OVERTURE_LATAM_SOURCE = "overture-latam";
6
12
  /**
7
13
  * License assigned by this source (`cdla-Permissive-2.0`, attribution-only
8
14
  * rather than share-alike), attached to every row.
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../lib/adapters/overture/adapter.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAuD,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AAE/G;;GAEG;AACH,eAAO,MAAM,mBAAmB,aAAa,CAAA;AAC7C;;;GAGG;AACH,eAAO,MAAM,wBAAwB,wBAAwB,CAAA;AAiC7D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAM5D;AAYD,wBAAgB,qBAAqB,IAAI,aAAa,CA6FrD;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,eAA0B,CAAA"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../lib/adapters/overture/adapter.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAuD,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AAE/G;;GAEG;AACH,eAAO,MAAM,mBAAmB,aAAa,CAAA;AAC7C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,mBAAmB,CAAA;AACrD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,wBAAwB,CAAA;AAgG7D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAM5D;AAYD,wBAAgB,qBAAqB,IAAI,aAAa,CAuGrD;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,eAA0B,CAAA"}
@@ -6,19 +6,28 @@
6
6
  * The `street` value keeps the locale's street keyword verbatim.
7
7
  * The downstream affix-relabel step splits `street_prefix` from that value.
8
8
  */
9
- import { formatAddressRow } from "@mailwoman/codex/address/format";
10
- import { COUNTRY_SURFACE_FORMS } from "@mailwoman/codex/country";
9
+ import { CA_PROVINCES } from "@mailwoman/codex/ca/province";
10
+ import { countryRenderForms } from "@mailwoman/codex/country";
11
+ import { writtenPostcode } from "@mailwoman/codex/labels/postcode/written-groups";
12
+ import { mxStatePostalAbbreviation } from "@mailwoman/codex/mx/state";
11
13
  import { sample } from "@mailwoman/core/math/random";
12
14
  import { mulberry32 as makeMulberry32 } from "@mailwoman/core/utils";
13
15
  import { tryParsingJSON } from "@mailwoman/core/values/json";
14
16
  import { TextSpliterator } from "spliterator";
15
17
  import { stableSourceID } from "#adapters/source-id";
16
18
  import { SourceRegister } from "#registers";
19
+ import { formatCorpusRow } from "#surfaces/corpus-row";
17
20
  import { AddressRole, SurfaceOrigin } from "#types";
18
21
  /**
19
22
  * Registry id stamped into every row this adapter emits, so a corpus record traces back to its dataset.
20
23
  */
21
24
  export const OVERTURE_ADAPTER_ID = "overture";
25
+ /**
26
+ * The `source` the Brazilian, Mexican and Canadian runs of this adapter
27
+ * stamp on their rows (`corpus run overture --source-name overture-latam`),
28
+ * which training configs weight apart from `overture`.
29
+ */
30
+ export const OVERTURE_LATAM_SOURCE = "overture-latam";
22
31
  /**
23
32
  * License assigned by this source (`cdla-Permissive-2.0`, attribution-only
24
33
  * rather than share-alike), attached to every row.
@@ -26,18 +35,64 @@ export const OVERTURE_ADAPTER_ID = "overture";
26
35
  export const OVERTURE_DEFAULT_LICENSE = "CDLA-Permissive-2.0";
27
36
  const DEFAULT_COUNTRY_SEED = 20_260_922;
28
37
  /**
29
- * One attested written form of a country's name.
38
+ * One attested written form of a country's name, never a two-letter code (`countryRenderForms`).
30
39
  *
31
40
  * Raises rather than returning empty when the codex has no entry, so a requested
32
41
  * fraction cannot silently produce no country rows.
33
42
  */
34
43
  function countrySurfaceForm(country, random) {
35
- const forms = COUNTRY_SURFACE_FORMS[country];
36
- if (!forms?.length) {
44
+ const forms = countryRenderForms(country);
45
+ if (!forms.length) {
37
46
  throw new Error(`No COUNTRY_SURFACE_FORMS entry for ${country} — add it to codex/country/country.ts before using --country-fraction`);
38
47
  }
39
48
  return sample(forms, random);
40
49
  }
50
+ /**
51
+ * The role of Overture's `unit` field in each country where it isn't a secondary unit.
52
+ *
53
+ * Read off the 2026-06-17.0 per-country corpus JSONL: every filled Czech `unit` is digits
54
+ * beside a digit `number` (101,127 of 394,880 rows, such as `Nad Stadiónem` `320` `28`),
55
+ * and in the first 400,000 German rows 17,250 of the 17,304 filled ones are one
56
+ * or two letters (`Neutrale Straße` `28` `a`).
57
+ */
58
+ const OVERTURE_UNIT_FIELD_ROLES = {
59
+ // UPU, Czech Rep. (02/2018): `The street number often consists of two numbers separated by a slash.
60
+ // The first number is a unique district-related building number [...], the second number is the
61
+ // street number`, as in `Hrušovská 455/10`.
62
+ CZ: "orientation-number",
63
+ // UPU, Germany (01/2015): `Wacholderweg 52a`.
64
+ DE: "number-suffix",
65
+ };
66
+ /**
67
+ * The house number with the `unit` field joined into it as the country's role for that
68
+ * field states, or `null` when the field doesn't belong in the number.
69
+ */
70
+ function joinUnitIntoNumber(number, unit, role) {
71
+ if (!role || !/^\d/u.test(number))
72
+ return null;
73
+ if (role === "orientation-number")
74
+ return /^\d+\p{Letter}?$/u.test(unit) ? `${number}/${unit}` : null;
75
+ return /^\p{Letter}{1,2}$/u.test(unit) ? `${number}${unit}` : null;
76
+ }
77
+ /**
78
+ * How a region value in Overture's first address level becomes the form the country's
79
+ * operator prints, for each country where Overture's value can be read as that form.
80
+ *
81
+ * A country absent here renders no region from Overture.
82
+ * Its first level is a unit the operator doesn't print: Italy's is `Sardegna`,
83
+ * where the operator prints the province `RM`.
84
+ */
85
+ const OVERTURE_REGION_FORMS = {
86
+ // UPU, Brazil (03/2012): `The state abbreviation (two characters) must follow the town's name separated
87
+ // by a dash`, as in `GUARAPUAVA – PR`. Overture writes the two-letter UF (`RS`).
88
+ BR: (value) => (/^[A-Z]{2}$/u.test(value) ? value : null),
89
+ // UPU, Canada (09/2014): `MONTREAL QC H3Z 2Y7`, `QC is the province abbreviation`.
90
+ // Overture writes the ISO 3166-2:CA code, and the code is that abbreviation.
91
+ CA: (value) => (Object.hasOwn(CA_PROVINCES, value) ? value : null),
92
+ // UPU, Mexico (03/2017): `02860 MEXICO, CDMX`.
93
+ // Overture writes the state's name (`Michoacán de Ocampo`).
94
+ MX: mxStatePostalAbbreviation,
95
+ };
41
96
  /**
42
97
  * Whether an Overture `unit` value is a secondary-unit designator
43
98
  * (a digit or a single bare word) rather than a name.
@@ -75,6 +130,9 @@ export function createOvertureAdapter() {
75
130
  const country = opts.country;
76
131
  const countryFraction = opts.countryFraction ?? 0;
77
132
  const random = makeMulberry32(opts.seed ?? DEFAULT_COUNTRY_SEED);
133
+ const code = country.toUpperCase();
134
+ const unitRole = Object.hasOwn(OVERTURE_UNIT_FIELD_ROLES, code) ? OVERTURE_UNIT_FIELD_ROLES[code] : null;
135
+ const regionForm = Object.hasOwn(OVERTURE_REGION_FORMS, code) ? OVERTURE_REGION_FORMS[code] : null;
78
136
  // The path string lets `TextSpliterator` own and dispose the file handle, including on an early `break`.
79
137
  const lines = TextSpliterator.fromAsync(opts.inputPath);
80
138
  let emitted = 0;
@@ -97,26 +155,31 @@ export function createOvertureAdapter() {
97
155
  if (!postcode && !locality)
98
156
  continue;
99
157
  const components = {};
158
+ const joined = unit ? joinUnitIntoNumber(number, unit, unitRole) : null;
100
159
  // Overture "S-N" / "S/N" = sin número; only keep a real numeric house number.
101
160
  if (/^\d/.test(number)) {
102
- components.house_number = number;
161
+ components.house_number = joined ?? number;
103
162
  }
104
163
  components.street = street;
105
- if (unitFieldIsDesignator(unit)) {
164
+ if (!joined && unitFieldIsDesignator(unit)) {
106
165
  components.unit = unit;
107
166
  }
108
167
  if (postcode) {
109
- components.postcode = postcode;
168
+ components.postcode = writtenPostcode(postcode, country);
110
169
  }
111
170
  if (locality) {
112
171
  components.locality = locality;
113
172
  }
173
+ const region = regionForm && r.region?.trim() ? regionForm(r.region.trim()) : null;
174
+ if (region) {
175
+ components.region = region;
176
+ }
114
177
  // Overture rows are country-implicit, so the surface form goes into `components`
115
178
  // and each country's layout decides where the country lands in the rendered string.
116
179
  if (countryFraction > 0 && random() < countryFraction) {
117
180
  components.country = countrySurfaceForm(country, random);
118
181
  }
119
- const rendered = formatAddressRow(components, country, { singleLine: true });
182
+ const rendered = formatCorpusRow(components, country, { singleLine: true });
120
183
  if (!rendered)
121
184
  continue;
122
185
  const { raw, components: aligned } = rendered;
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../lib/adapters/overture/adapter.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AACpD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,OAA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IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;gBAElF,IAAI,MAAM,EAAE,CAAC;oBACZ,UAAU,CAAC,MAAM,GAAG,MAAM,CAAA;gBAC3B,CAAC;gBAED,iFAAiF;gBACjF,oFAAoF;gBACpF,IAAI,eAAe,GAAG,CAAC,IAAI,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;oBACvD,UAAU,CAAC,OAAO,GAAG,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;gBACzD,CAAC;gBAED,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;gBAE3E,IAAI,CAAC,QAAQ;oBAAE,SAAQ;gBAEvB,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAA;gBAE7C,MAAM;oBACL,GAAG;oBACH,UAAU,EAAE,OAAO;oBACnB,OAAO;oBACP,MAAM,EAAE,mBAAmB;oBAC3B,SAAS,EAAE,cAAc,CAAC,mBAAmB,EAAE,OAAO,CAAC;oBACvD,OAAO,EAAE,wBAAwB;iBACjC,CAAA;gBAED,OAAO,EAAE,CAAA;YACV,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @file The address key that joins an Overture row to every other rendering of the same address.
3
+ *
4
+ * An Overture row's `source_id` is a hash of its aligned components (`stableSourceID`).
5
+ * A re-run that adds the region or writes the postcode in another grouping gives the same address a new id,
6
+ * and the record id the split groups by doesn't hold across the re-run (#3457).
7
+ * The key reads the postcode, the locality, the house number, the street and the unit, each folded.
8
+ * It leaves out the region and the country, the two components a re-run adds to some rows and not others.
9
+ * A postcode keeps only its letters and digits, so `K7K6R2` and `K7K 6R2`, `54420-240` and `54420240` are
10
+ * one postcode.
11
+ *
12
+ * The key's text comes from Overture's own fields.
13
+ * The adapter writes `street`, `number`, `unit` and `locality` verbatim and regroups only the postcode.
14
+ */
15
+ import { type AddressKeyRow } from "#utils/address-key";
16
+ /**
17
+ * The folded postcode and the house number's digits, the part of the key a column scan can compute.
18
+ *
19
+ * @returns null when the row holds neither a postcode nor a locality.
20
+ * The adapter writes no such row.
21
+ */
22
+ export declare function overtureAddressBlock(row: AddressKeyRow): string | null;
23
+ /**
24
+ * {@linkcode overtureAddressBlock} as a DuckDB expression over a corpus file aliased `alias`.
25
+ *
26
+ * `lower` and the ASCII class agree with the JavaScript fold for the postcodes
27
+ * Overture writes in Brazil, Mexico and Canada.
28
+ * Those hold only ASCII letters, digits, a space and a hyphen.
29
+ */
30
+ export declare function overtureAddressBlockSQL(alias: string): string;
31
+ /**
32
+ * The address key of one Overture row, `<postcode>|<locality>|<house number>|<street>|<unit>`.
33
+ *
34
+ * A row without a house number keys by its street within its postcode and locality.
35
+ *
36
+ * @returns null when the row has no street, or neither a postcode nor a locality.
37
+ */
38
+ export declare function overtureAddressKey(row: AddressKeyRow): string | null;
39
+ //# sourceMappingURL=address-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-key.d.ts","sourceRoot":"","sources":["../../../lib/adapters/overture/address-key.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAgD,MAAM,oBAAoB,CAAA;AAqBrG;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAOtE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO7D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAWpE"}
@@ -0,0 +1,75 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ /**
4
+ * @file The address key that joins an Overture row to every other rendering of the same address.
5
+ *
6
+ * An Overture row's `source_id` is a hash of its aligned components (`stableSourceID`).
7
+ * A re-run that adds the region or writes the postcode in another grouping gives the same address a new id,
8
+ * and the record id the split groups by doesn't hold across the re-run (#3457).
9
+ * The key reads the postcode, the locality, the house number, the street and the unit, each folded.
10
+ * It leaves out the region and the country, the two components a re-run adds to some rows and not others.
11
+ * A postcode keeps only its letters and digits, so `K7K6R2` and `K7K 6R2`, `54420-240` and `54420240` are
12
+ * one postcode.
13
+ *
14
+ * The key's text comes from Overture's own fields.
15
+ * The adapter writes `street`, `number`, `unit` and `locality` verbatim and regroups only the postcode.
16
+ */
17
+ import { aliasedSpanSQL, foldKeyText, labeledSpanText } from "#utils/address-key";
18
+ /**
19
+ * The street tags whose spans make up the street.
20
+ *
21
+ * The affix relabel may split a street keyword into its own span,
22
+ * and the joined text is the same either way.
23
+ */
24
+ const STREET_TAGS = new Set(["street_prefix", "street", "street_suffix"]);
25
+ const POSTCODE_TAGS = new Set(["postcode"]);
26
+ const HOUSE_NUMBER_TAGS = new Set(["house_number"]);
27
+ /**
28
+ * A postcode's letters and digits, lower case.
29
+ */
30
+ function foldPostcode(text) {
31
+ return foldKeyText(text).replaceAll(" ", "");
32
+ }
33
+ /**
34
+ * The folded postcode and the house number's digits, the part of the key a column scan can compute.
35
+ *
36
+ * @returns null when the row holds neither a postcode nor a locality.
37
+ * The adapter writes no such row.
38
+ */
39
+ export function overtureAddressBlock(row) {
40
+ const postcode = foldPostcode(labeledSpanText(row, POSTCODE_TAGS));
41
+ const number = labeledSpanText(row, HOUSE_NUMBER_TAGS).replaceAll(/\D/gu, "");
42
+ if (!postcode && !row.span_tags.includes("locality"))
43
+ return null;
44
+ return `${postcode}|${number}`;
45
+ }
46
+ /**
47
+ * {@linkcode overtureAddressBlock} as a DuckDB expression over a corpus file aliased `alias`.
48
+ *
49
+ * `lower` and the ASCII class agree with the JavaScript fold for the postcodes
50
+ * Overture writes in Brazil, Mexico and Canada.
51
+ * Those hold only ASCII letters, digits, a space and a hyphen.
52
+ */
53
+ export function overtureAddressBlockSQL(alias) {
54
+ const text = (tag) => `coalesce(${aliasedSpanSQL(alias, tag)}, '')`;
55
+ return (`(regexp_replace(lower(${text("postcode")}), '[^0-9a-z]', '', 'g') || '|' || ` +
56
+ `regexp_replace(${text("house_number")}, '[^0-9]', '', 'g'))`);
57
+ }
58
+ /**
59
+ * The address key of one Overture row, `<postcode>|<locality>|<house number>|<street>|<unit>`.
60
+ *
61
+ * A row without a house number keys by its street within its postcode and locality.
62
+ *
63
+ * @returns null when the row has no street, or neither a postcode nor a locality.
64
+ */
65
+ export function overtureAddressKey(row) {
66
+ const street = foldKeyText(labeledSpanText(row, STREET_TAGS));
67
+ const postcode = foldPostcode(labeledSpanText(row, POSTCODE_TAGS));
68
+ const locality = foldKeyText(labeledSpanText(row, new Set(["locality"])));
69
+ if (!street || (!postcode && !locality))
70
+ return null;
71
+ const number = foldKeyText(labeledSpanText(row, HOUSE_NUMBER_TAGS));
72
+ const unit = foldKeyText(labeledSpanText(row, new Set(["unit"])));
73
+ return `${postcode}|${locality}|${number}|${street}|${unit}`;
74
+ }
75
+ //# sourceMappingURL=address-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-key.js","sourceRoot":"","sources":["../../../lib/adapters/overture/address-key.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAsB,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAErG;;;;;GAKG;AACH,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,QAA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C,GAAG,EAAE,aAAa,CAAC,CAAC,CAAA;IAClE,MAAM,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAEzE,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAA;IAEpD,MAAM,MAAM,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAA;IACnE,MAAM,IAAI,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAEjE,OAAO,GAAG,QAAQ,IAAI,QAAQ,IAAI,MAAM,IAAI,MAAM,IAAI,IAAI,EAAE,CAAA;AAC7D,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type RegionNames } from "#build/region/names";
2
+ import { type CorpusAdapter } from "#types";
3
+ /**
4
+ * Options for {@link createOverturePlacesINAdapter}.
5
+ */
6
+ export interface OverturePlacesINAdapterOptions {
7
+ /**
8
+ * Reads India's first-level division names.
9
+ *
10
+ * Defaults to the Who's On First admin database with GeoNames' first-level names.
11
+ * The adapter refuses to run without one.
12
+ */
13
+ regionNames?: () => Promise<Pick<RegionNames, "holds"> | null>;
14
+ }
15
+ export declare function createOverturePlacesINAdapter(options?: OverturePlacesINAdapterOptions): CorpusAdapter;
16
+ /**
17
+ * The configured adapter instance registered with the corpus builder.
18
+ */
19
+ export declare const overturePlacesINAdapter: CorpusAdapter;
20
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../lib/adapters/overture/places-in/adapter.ts"],"names":[],"mappings":"AAmDA,OAAO,EAAE,KAAK,WAAW,EAA6B,MAAM,qBAAqB,CAAA;AAIjF,OAAO,EAAuD,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AAyI/G;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;CAC9D;AAED,wBAAgB,6BAA6B,CAAC,OAAO,GAAE,8BAAmC,GAAG,aAAa,CA+CzG;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,eAAkC,CAAA"}
@@ -0,0 +1,191 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ /**
4
+ * `overture-places-in`: the street addresses of Indian places in the Overture Maps places theme.
5
+ *
6
+ * Input is the parquet file `#tools/fetch/overture-places-in` copies out of one Overture release.
7
+ * It holds each Indian place's first address as `freeform` (the street line),
8
+ * `locality`, `region` and `postcode`, with the dataset Overture took the place from
9
+ * (Microsoft, Meta, Foursquare, AllThePlaces, DAC, PinMeTo).
10
+ *
11
+ * ## The rendered order
12
+ *
13
+ * Each row renders through the IN layout in `@mailwoman/codex/address/layouts`.
14
+ * The share `WRITTEN_LAYOUTS` records renders through the written order, with the state before the PIN.
15
+ *
16
+ * India Post's UPU description (`https://www.upu.int/UPU/media/upu/PostalEntitiesFiles/addressingUnit/indEn.pdf`,
17
+ * 01/2013, sha256 `f8ac2ed37a59ecece8cd11e2ac5088411148b1e3d69304c118e655e275fa2a3e`) writes the
18
+ * premise number, a comma and the street (`4, Amrita Shergill Road`, `32/1, 2nd Main Road`).
19
+ * The sub-locality (`Jayanagar`), the locality, the state and the PIN
20
+ * follow (`Bangalore / Karnataka / 560082`).
21
+ *
22
+ * A hash of the Overture id draws between the two orders, so a rebuild renders each place the same way.
23
+ *
24
+ * ## What a row holds
25
+ *
26
+ * `segmentINStreetLine` (`#in/street-line/segment`) labels the street line,
27
+ * and keeps a line only where each part has one reading.
28
+ * The place's own name is never read, because a Meta or Foursquare listing can be
29
+ * a person's (`HDFC ERGO Insurance Agent: <name>`).
30
+ *
31
+ * A state is kept only where Who's On First or GeoNames holds it as one of India's
32
+ * first-level divisions, and only in a written-out form.
33
+ * AllThePlaces writes districts there (`Erode`, `Palakkad`), and DAC and Meta write
34
+ * ISO 3166-2 suffixes (`MH`), which Indian addresses spell out.
35
+ *
36
+ * A PIN is six digits, and a locality is letters without a comma.
37
+ *
38
+ * ## License
39
+ *
40
+ * Overture's places theme is CDLA Permissive 2.0 for Meta, Microsoft, DAC and PinMeTo,
41
+ * Apache 2.0 for Foursquare and CC0 1.0 for AllThePlaces, as the register's elected
42
+ * decision for `us-geodata-aggregate-1` records.
43
+ */
44
+ import { formatAddressRow } from "@mailwoman/codex/address/format";
45
+ import { writtenLayoutForCountry } from "@mailwoman/codex/address/layouts";
46
+ import { foldName } from "@mailwoman/codex/names/normalize";
47
+ import { sha256Hex } from "@mailwoman/core/crypto/hash";
48
+ import { mulberry32 } from "@mailwoman/core/math/random";
49
+ import { tryReadDefaultRegionNames } from "#build/region/names";
50
+ import { INStreetLineRefusal, isINSubProvince, segmentINStreetLine } from "#in/street-line/segment";
51
+ import { openParquetRowStream } from "#parquet/streams";
52
+ import { SourceRegister } from "#registers";
53
+ import { AddressRole, SurfaceOrigin } from "#types";
54
+ /**
55
+ * Registry id for this adapter, stamped as the `source` of every row it emits.
56
+ */
57
+ const OVERTURE_PLACES_IN_ADAPTER_ID = "overture-places-in";
58
+ /**
59
+ * The license stamped on each row: the places theme's license for the CDLA datasets.
60
+ *
61
+ * The register decision records the Apache 2.0 and CC0 datasets.
62
+ */
63
+ const OVERTURE_PLACES_IN_DEFAULT_LICENSE = "CDLA-Permissive-2.0";
64
+ /**
65
+ * Why a record emitted no row: the street line's own refusals, and the fields beside it.
66
+ */
67
+ const OverturePlaceINRefusal = {
68
+ ...INStreetLineRefusal,
69
+ StreetLineAbsent: "street-line-absent",
70
+ LocalityUnread: "locality-unread",
71
+ PostcodeUnread: "postcode-unread",
72
+ };
73
+ /**
74
+ * A PIN code as the address writes it: six digits, the first one to eight,
75
+ * with an optional space after the third.
76
+ */
77
+ const PIN = /^([1-8]\d{2})\s?(\d{3})$/u;
78
+ /**
79
+ * A locality written in letters, with the spaces, dots, hyphens and apostrophes a name holds.
80
+ */
81
+ const LOCALITY = /^[\p{L}\p{M}][\p{L}\p{M} .'-]*$/u;
82
+ /**
83
+ * The longest region value read as an ISO 3166-2 suffix (`MH`, `UP`) rather than a state's written name.
84
+ */
85
+ const MAX_SUBDIVISION_CODE_LENGTH = 3;
86
+ /**
87
+ * A uniform draw in `[0, 1)` fixed by the Overture id.
88
+ */
89
+ function drawFor(id) {
90
+ return mulberry32(Number.parseInt(sha256Hex(id).slice(0, 8), 16))();
91
+ }
92
+ /**
93
+ * Read one record into a row's components, or the reason it holds none.
94
+ */
95
+ function readOverturePlaceIN(record, regionNames) {
96
+ const freeform = record.freeform?.trim();
97
+ if (!freeform)
98
+ return { refused: OverturePlaceINRefusal.StreetLineAbsent };
99
+ const locality = record.locality?.trim() ?? "";
100
+ if (!LOCALITY.test(locality) || isINSubProvince(locality))
101
+ return { refused: OverturePlaceINRefusal.LocalityUnread };
102
+ const pin = PIN.exec(record.postcode?.trim() ?? "");
103
+ if (!pin)
104
+ return { refused: OverturePlaceINRefusal.PostcodeUnread };
105
+ const postcode = `${pin[1]}${pin[2]}`;
106
+ const regionValue = record.region?.trim() ?? "";
107
+ const region = regionValue.length > MAX_SUBDIVISION_CODE_LENGTH &&
108
+ foldName(regionValue) !== foldName(locality) &&
109
+ regionNames.holds("IN", regionValue)
110
+ ? regionValue
111
+ : undefined;
112
+ const line = segmentINStreetLine(freeform, { locality, region: regionValue });
113
+ if ("refused" in line)
114
+ return { refused: line.refused };
115
+ const { omitted: _omitted, ...parts } = line;
116
+ if (parts.dependent_locality && foldName(parts.dependent_locality) === foldName(locality)) {
117
+ delete parts.dependent_locality;
118
+ }
119
+ return {
120
+ components: {
121
+ ...parts,
122
+ locality,
123
+ ...(region ? { region } : {}),
124
+ postcode,
125
+ },
126
+ };
127
+ }
128
+ /**
129
+ * Render one record as a corpus row, in the postal or the written order its id draws,
130
+ * or `null` when it holds none.
131
+ */
132
+ function renderOverturePlaceIN(record, regionNames) {
133
+ const reading = readOverturePlaceIN(record, regionNames);
134
+ if ("refused" in reading)
135
+ return null;
136
+ const layout = writtenLayoutForCountry("IN", drawFor(record.id));
137
+ const rendered = formatAddressRow(reading.components, "IN", { singleLine: true, ...(layout ? { layout } : {}) });
138
+ if (!rendered)
139
+ return null;
140
+ return {
141
+ raw: rendered.raw,
142
+ components: rendered.components,
143
+ country: "IN",
144
+ locale: "en-IN",
145
+ source: OVERTURE_PLACES_IN_ADAPTER_ID,
146
+ source_id: `${OVERTURE_PLACES_IN_ADAPTER_ID}-${record.id}`,
147
+ license: OVERTURE_PLACES_IN_DEFAULT_LICENSE,
148
+ };
149
+ }
150
+ export function createOverturePlacesINAdapter(options = {}) {
151
+ const loadRegionNames = options.regionNames ?? tryReadDefaultRegionNames;
152
+ return {
153
+ id: OVERTURE_PLACES_IN_ADAPTER_ID,
154
+ defaultLicense: OVERTURE_PLACES_IN_DEFAULT_LICENSE,
155
+ addressRole: AddressRole.Facility,
156
+ register: SourceRegister.Overture,
157
+ surface: SurfaceOrigin.Rendered,
158
+ description: "Overture Maps places in India — the street address of each place (CDLA Permissive 2.0 / Apache 2.0 / CC0), rendered in India Post's order.",
159
+ async *rows(opts) {
160
+ // A street-line reader for another country's Overture places would replace
161
+ // this refusal. country-branch: the street-line reader and the PIN
162
+ // and state checks follow India Post's conventions.
163
+ if (opts.country && opts.country !== "IN") {
164
+ throw new Error(`${OVERTURE_PLACES_IN_ADAPTER_ID} adapter: only IN supported, got country=${opts.country}`);
165
+ }
166
+ const regionNames = await loadRegionNames();
167
+ if (!regionNames) {
168
+ throw new Error(`${OVERTURE_PLACES_IN_ADAPTER_ID} adapter: the Who's On First admin database that holds India's states isn't on this host`);
169
+ }
170
+ let emitted = 0;
171
+ for await (const record of openParquetRowStream(opts.inputPath, {
172
+ columns: ["id", "freeform", "locality", "region", "postcode"],
173
+ })) {
174
+ if (opts.signal?.aborted)
175
+ break;
176
+ if (typeof opts.limit === "number" && emitted >= opts.limit)
177
+ break;
178
+ const row = renderOverturePlaceIN(record, regionNames);
179
+ if (!row)
180
+ continue;
181
+ yield row;
182
+ emitted++;
183
+ }
184
+ },
185
+ };
186
+ }
187
+ /**
188
+ * The configured adapter instance registered with the corpus builder.
189
+ */
190
+ export const overturePlacesINAdapter = createOverturePlacesINAdapter();
191
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../lib/adapters/overture/places-in/adapter.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,OAAO,EAAoB,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AACjF,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AACnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,WAAW,EAA8D,aAAa,EAAE,MAAM,QAAQ,CAAA;AAE/G;;GAEG;AACH,MAAM,6BAA6B,GAAG,oBAAoB,CAAA;AAE1D;;;;GAIG;AACH,MAA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CAAA;YAE3C,IAAI,CAAC,WAAW,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CACd,GAAG,6BAA6B,0FAA0F,CAC1H,CAAA;YACF,CAAC;YAED,IAAI,OAAO,GAAG,CAAC,CAAA;YAEf,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,oBAAoB,CAAwB,IAAI,CAAC,SAAS,EAAE;gBACtF,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC;aAC7D,CAAC,EAAE,CAAC;gBACJ,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO;oBAAE,MAAK;gBAE/B,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,CAAC,KAAK;oBAAE,MAAK;gBAElE,MAAM,GAAG,GAAG,qBAAqB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;gBAEtD,IAAI,CAAC,GAAG;oBAAE,SAAQ;gBAElB,MAAM,GAAG,CAAA;gBAET,OAAO,EAAE,CAAA;YACV,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,6BAA6B,EAAE,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { CanonicalRow } from "#types";
2
+ /**
3
+ * Returns `components` with a whole `street` split into `street_prefix`, `street`
4
+ * and `street_suffix` when `country`'s convention is `split` and the row labels no street affix.
5
+ *
6
+ * The split reads the dictionaries the TIGER adapter's {@linkcode decomposeStreet} reads,
7
+ * so every US source labels one street one way.
8
+ * A street with no directional or type keyword keeps its one span.
9
+ */
10
+ export declare function withConventionStreet(components: CanonicalRow["components"], country: string): CanonicalRow["components"];
11
+ //# sourceMappingURL=convention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convention.d.ts","sourceRoot":"","sources":["../../../lib/adapters/street/convention.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAG1C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,EACtC,OAAO,EAAE,MAAM,GACb,YAAY,CAAC,YAAY,CAAC,CAiB5B"}
@@ -0,0 +1,40 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ /**
4
+ * A row's street components, written under its country's street span convention.
5
+ *
6
+ * `docs/engineering/reference/SCHEMA.mdx` labels a US street's directional
7
+ * and type as `street_prefix` and `street_suffix` spans.
8
+ * An adapter that reads one street line, such as the NPPES practice location
9
+ * or a notary register's address, emits the whole line as `street`.
10
+ *
11
+ * The model then learns both forms for one US street.
12
+ * The evaluation reads the whole form as an unlabeled affix.
13
+ */
14
+ import { streetSpanConventionFor } from "@mailwoman/codex/labels/street/convention";
15
+ import { decomposeStreet } from "#us/adapters/tiger/street-decompose";
16
+ /**
17
+ * Returns `components` with a whole `street` split into `street_prefix`, `street`
18
+ * and `street_suffix` when `country`'s convention is `split` and the row labels no street affix.
19
+ *
20
+ * The split reads the dictionaries the TIGER adapter's {@linkcode decomposeStreet} reads,
21
+ * so every US source labels one street one way.
22
+ * A street with no directional or type keyword keeps its one span.
23
+ */
24
+ export function withConventionStreet(components, country) {
25
+ const street = components.street;
26
+ if (!street || streetSpanConventionFor(country) !== "split")
27
+ return components;
28
+ if (components.street_prefix || components.street_suffix || components.street_prefix_particle)
29
+ return components;
30
+ const { prefix, street: name, suffix } = decomposeStreet(street);
31
+ if (!prefix && !suffix)
32
+ return components;
33
+ return {
34
+ ...components,
35
+ ...(prefix ? { street_prefix: prefix } : {}),
36
+ street: name,
37
+ ...(suffix ? { street_suffix: suffix } : {}),
38
+ };
39
+ }
40
+ //# sourceMappingURL=convention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convention.js","sourceRoot":"","sources":["../../../lib/adapters/street/convention.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAA;AAGnF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAErE;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAAsC,EACtC,OAAe;IAEf,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;IAEhC,IAAI,CAAC,MAAM,IAAI,uBAAuB,CAAC,OAAO,CAAC,KAAK,OAAO;QAAE,OAAO,UAAU,CAAA;IAE9E,IAAI,UAAU,CAAC,aAAa,IAAI,UAAU,CAAC,aAAa,IAAI,UAAU,CAAC,sBAAsB;QAAE,OAAO,UAAU,CAAA;IAEhH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;IAEhE,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAA;IAEzC,OAAO;QACN,GAAG,UAAU;QACb,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,MAAM,EAAE,IAAI;QACZ,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAA;AACF,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The parts a country's reader labels in one street line.
3
+ */
4
+ export interface CountryStreetLineParts {
5
+ house_number?: string;
6
+ street: string;
7
+ dependent_locality?: string;
8
+ /**
9
+ * A building or complex name written before the street (`Tagore Road Hostel`).
10
+ */
11
+ building?: string;
12
+ }
13
+ /**
14
+ * The record fields beside the line.
15
+ * The line may repeat their values.
16
+ */
17
+ export interface CountryStreetLineContext {
18
+ locality?: string | null;
19
+ region?: string | null;
20
+ }
21
+ /**
22
+ * Reads one street line, or returns the reason it can't be labeled.
23
+ */
24
+ export type CountryStreetLineReader = (line: string, context: CountryStreetLineContext) => CountryStreetLineParts | {
25
+ refused: string;
26
+ };
27
+ /**
28
+ * The street-line reader of `country`, or `null` when its directory supplies none.
29
+ */
30
+ export declare function streetLineReaderFor(country: string): CountryStreetLineReader | null;
31
+ //# sourceMappingURL=country-line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country-line.d.ts","sourceRoot":"","sources":["../../../lib/adapters/street/country-line.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,wBAAwB,KAC7B,sBAAsB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAiBjD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAEnF"}