@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
@@ -5,7 +5,6 @@
5
5
  * Synthesis and augmentation utilities.
6
6
  */
7
7
 
8
- import { formatAddressRow } from "@mailwoman/codex/address/format"
9
8
  import type { BIOLabel, ComponentTag } from "@mailwoman/codex/component"
10
9
  import {
11
10
  US_STREET_SUFFIX_PREFERRED_ABBR,
@@ -19,14 +18,43 @@ import { isPresent } from "@mailwoman/core/values/objects"
19
18
  import { stripCombiningMarks } from "@mailwoman/normalize/fold"
20
19
  import { matchCase } from "spliterator"
21
20
 
21
+ import { formatCorpusRow } from "#surfaces/corpus-row"
22
22
  import type { CanonicalRow, LabeledRow, QuarantinedRow } from "#types"
23
23
  import { alignRow, assertSpanInvariants, type ComponentSpan } from "#utils/align"
24
24
  import { whitespaceTokenizer, type Tokenizer } from "#utils/tokenize"
25
25
 
26
26
  /**
27
- * A row augmentation.
27
+ * One augmentation: a function from a row to its variant, or `null` when the row
28
+ * offers no text to vary, with its method name.
29
+ *
30
+ * The variant writes that name as its `augmentation.name` and as its `source_id` suffix.
31
+ *
32
+ * The name lets a caller decide whether it wants a variant before the augmentation runs.
33
+ */
34
+ export interface Augmentation {
35
+ (row: CanonicalRow): CanonicalRow | null
36
+ readonly method: string
37
+ }
38
+
39
+ /**
40
+ * Builds the variant of the row an augmentation's body was given, under the augmentation's method name.
41
+ */
42
+ type EmitVariant = (newRaw: string, newComponents: ComponentDict) => CanonicalRow
43
+
44
+ /**
45
+ * Defines an augmentation whose method name is `method`.
46
+ *
47
+ * Its body builds the variant through `emit`, so the name is written once.
28
48
  */
29
- export type Augmentation = (row: CanonicalRow) => CanonicalRow | null
49
+ function augmentation(
50
+ method: string,
51
+ body: (row: CanonicalRow, emit: EmitVariant) => CanonicalRow | null
52
+ ): Augmentation {
53
+ const apply = (row: CanonicalRow): CanonicalRow | null =>
54
+ body(row, (newRaw, newComponents) => withAugmentation(row, method, newRaw, newComponents))
55
+
56
+ return Object.assign(apply, { method })
57
+ }
30
58
 
31
59
  type ComponentDict = Partial<Record<ComponentTag, string>>
32
60
 
@@ -55,7 +83,7 @@ function withAugmentation(
55
83
  /**
56
84
  * Upper-case raw and components.
57
85
  */
58
- export const caseUpper: Augmentation = (row) => {
86
+ export const caseUpper = augmentation("case-upper", (row, emit) => {
59
87
  if (row.raw === row.raw.toUpperCase()) return null
60
88
  const upRaw = row.raw.toUpperCase()
61
89
  const upComponents: ComponentDict = {}
@@ -66,13 +94,13 @@ export const caseUpper: Augmentation = (row) => {
66
94
  }
67
95
  }
68
96
 
69
- return withAugmentation(row, "case-upper", upRaw, upComponents)
70
- }
97
+ return emit(upRaw, upComponents)
98
+ })
71
99
 
72
100
  /**
73
101
  * Lower-case raw and components.
74
102
  */
75
- export const caseLower: Augmentation = (row) => {
103
+ export const caseLower = augmentation("case-lower", (row, emit) => {
76
104
  if (row.raw === row.raw.toLowerCase()) return null
77
105
  const downRaw = row.raw.toLowerCase()
78
106
  const downComponents: ComponentDict = {}
@@ -83,8 +111,8 @@ export const caseLower: Augmentation = (row) => {
83
111
  }
84
112
  }
85
113
 
86
- return withAugmentation(row, "case-lower", downRaw, downComponents)
87
- }
114
+ return emit(downRaw, downComponents)
115
+ })
88
116
 
89
117
  /**
90
118
  * Drop commas from raw and from every component, each the same way.
@@ -93,7 +121,7 @@ export const caseLower: Augmentation = (row) => {
93
121
  * The aligner places a span of the component's length, so a component left one character
94
122
  * longer than its text in raw ends its span on the space after it.
95
123
  */
96
- export const dropCommas: Augmentation = (row) => {
124
+ export const dropCommas = augmentation("drop-commas", (row, emit) => {
97
125
  if (!row.raw.includes(",")) return null
98
126
  const strip = (text: string) => text.replaceAll(",", "").replaceAll(/\s+/g, " ").trim()
99
127
  const components: ComponentDict = {}
@@ -104,13 +132,13 @@ export const dropCommas: Augmentation = (row) => {
104
132
  }
105
133
  }
106
134
 
107
- return withAugmentation(row, "drop-commas", strip(row.raw), components)
108
- }
135
+ return emit(strip(row.raw), components)
136
+ })
109
137
 
110
138
  /**
111
139
  * Double spaces in raw and components.
112
140
  */
113
- export const doubleSpace: Augmentation = (row) => {
141
+ export const doubleSpace = augmentation("double-space", (row, emit) => {
114
142
  if (!/ /.test(row.raw)) return null
115
143
  const newRaw = row.raw.replaceAll(" ", " ")
116
144
  const newComponents: ComponentDict = {}
@@ -121,8 +149,8 @@ export const doubleSpace: Augmentation = (row) => {
121
149
  }
122
150
  }
123
151
 
124
- return withAugmentation(row, "double-space", newRaw, newComponents)
125
- }
152
+ return emit(newRaw, newComponents)
153
+ })
126
154
 
127
155
  /**
128
156
  * The share of rows that get a line-break variant, chosen per row from its source id.
@@ -136,22 +164,22 @@ const LINE_BREAK_SHARE = 0.25
136
164
  * The variant's components are the ones the layout printed.
137
165
  * A row whose layout puts everything on one line, or a country with no layout, gets no variant.
138
166
  */
139
- export const lineBreaks: Augmentation = (row) => {
167
+ export const lineBreaks = augmentation("line-breaks", (row, emit) => {
140
168
  if (/[\r\n]/.test(row.raw)) return null
141
169
 
142
170
  if (mulberry32(hashString(`${row.source_id}:line-breaks`))() >= LINE_BREAK_SHARE) return null
143
171
 
144
- const rendered = formatAddressRow(row.components, row.country)
172
+ const rendered = formatCorpusRow(row.components, row.country)
145
173
 
146
174
  if (!rendered?.raw.includes("\n")) return null
147
175
 
148
- return withAugmentation(row, "line-breaks", rendered.raw, rendered.components)
149
- }
176
+ return emit(rendered.raw, rendered.components)
177
+ })
150
178
 
151
179
  /**
152
180
  * Strip accents/diacritics from raw and components.
153
181
  */
154
- export const accentStrip: Augmentation = (row) => {
182
+ export const accentStrip = augmentation("accent-strip", (row, emit) => {
155
183
  const stripped = stripCombiningMarks(row.raw)
156
184
 
157
185
  if (stripped === row.raw) return null
@@ -163,8 +191,8 @@ export const accentStrip: Augmentation = (row) => {
163
191
  }
164
192
  }
165
193
 
166
- return withAugmentation(row, "accent-strip", stripped, newComponents)
167
- }
194
+ return emit(stripped, newComponents)
195
+ })
168
196
 
169
197
  // Typo helpers are deterministic per row.
170
198
 
@@ -221,7 +249,7 @@ function hashString(s: string): number {
221
249
  /**
222
250
  * Inject one deterministic typo into an eligible component.
223
251
  */
224
- export const typoInject: Augmentation = (row) => {
252
+ export const typoInject = augmentation("typo-inject", (row, emit) => {
225
253
  const rng = mulberry32(hashString(`${row.source_id}:typo`))
226
254
 
227
255
  // Only edit an unambiguous component value.
@@ -274,8 +302,8 @@ export const typoInject: Augmentation = (row) => {
274
302
  const newRaw = row.raw.replace(value, typed)
275
303
 
276
304
  // `replace(string, …)` updates the first literal match.
277
- return withAugmentation(row, "typo-inject", newRaw, { ...row.components, [tag]: typed })
278
- }
305
+ return emit(newRaw, { ...row.components, [tag]: typed })
306
+ })
279
307
 
280
308
  // US-specific augmentations.
281
309
 
@@ -359,7 +387,11 @@ function replaceRegionWord(raw: string, region: string, replacement: string): st
359
387
  return raw.slice(0, match.index) + replacement + raw.slice(match.index + region.length)
360
388
  }
361
389
 
362
- export const stateExpand: Augmentation = (row) => {
390
+ /**
391
+ * Writes a US row's state abbreviation as the state's full name (`AK` to `Alaska`),
392
+ * in the text and the region.
393
+ */
394
+ export const stateExpand = augmentation("state-expand", (row, emit) => {
363
395
  // country-branch: the state, directional, street-suffix, unit and ZIP+4
364
396
  // augmentations below read US vocabulary tables.
365
397
  // Per-country abbreviation tables in the codex would let
@@ -381,13 +413,13 @@ export const stateExpand: Augmentation = (row) => {
381
413
  if (!newRaw) return null
382
414
  const newComponents: ComponentDict = { ...row.components, region: full }
383
415
 
384
- return withAugmentation(row, "state-expand", newRaw, newComponents)
385
- }
416
+ return emit(newRaw, newComponents)
417
+ })
386
418
 
387
419
  /**
388
420
  * Abbreviate full state name to alpha-2.
389
421
  */
390
- export const stateAbbreviate: Augmentation = (row) => {
422
+ export const stateAbbreviate = augmentation("state-abbreviate", (row, emit) => {
391
423
  // country-branch: see `stateExpand`.
392
424
  if (row.country !== "US") return null
393
425
  const region = row.components.region
@@ -401,8 +433,8 @@ export const stateAbbreviate: Augmentation = (row) => {
401
433
  if (!newRaw) return null
402
434
  const newComponents: ComponentDict = { ...row.components, region: abbr }
403
435
 
404
- return withAugmentation(row, "state-abbreviate", newRaw, newComponents)
405
- }
436
+ return emit(newRaw, newComponents)
437
+ })
406
438
 
407
439
  const DIRECTIONAL_FULL_TO_ABBR: Record<string, string> = {
408
440
  North: "N",
@@ -422,7 +454,7 @@ const DIRECTIONAL_ABBR_TO_FULL: Record<string, string> = Object.fromEntries(
422
454
  /**
423
455
  * Expand directional abbreviations.
424
456
  */
425
- export const directionalExpand: Augmentation = (row) => {
457
+ export const directionalExpand = augmentation("directional-expand", (row, emit) => {
426
458
  // country-branch: see `stateExpand`.
427
459
  if (row.country !== "US") return null
428
460
  const tagsToCheck: ComponentTag[] = ["street", "street_suffix", "street_prefix"]
@@ -447,13 +479,13 @@ export const directionalExpand: Augmentation = (row) => {
447
479
 
448
480
  if (!changed) return null
449
481
 
450
- return withAugmentation(row, "directional-expand", newRaw, newComponents)
451
- }
482
+ return emit(newRaw, newComponents)
483
+ })
452
484
 
453
485
  /**
454
486
  * Abbreviate directional words.
455
487
  */
456
- export const directionalAbbreviate: Augmentation = (row) => {
488
+ export const directionalAbbreviate = augmentation("directional-abbreviate", (row, emit) => {
457
489
  // country-branch: see `stateExpand`.
458
490
  if (row.country !== "US") return null
459
491
  const tagsToCheck: ComponentTag[] = ["street", "street_suffix", "street_prefix"]
@@ -482,8 +514,8 @@ export const directionalAbbreviate: Augmentation = (row) => {
482
514
 
483
515
  if (!changed) return null
484
516
 
485
- return withAugmentation(row, "directional-abbreviate", newRaw, newComponents)
486
- }
517
+ return emit(newRaw, newComponents)
518
+ })
487
519
 
488
520
  /**
489
521
  * An augmentation rewrites one component's text in `raw`.
@@ -515,7 +547,7 @@ function siblingHoldsValue(components: ComponentDict, editedTag: ComponentTag, v
515
547
  /**
516
548
  * Abbreviate trailing US street suffix.
517
549
  */
518
- export const streetSuffixAbbreviate: Augmentation = (row) => {
550
+ export const streetSuffixAbbreviate = augmentation("us-street-suffix-abbreviate", (row, emit) => {
519
551
  // country-branch: see `stateExpand`.
520
552
  if (row.country !== "US") return null
521
553
  const street = row.components.street
@@ -541,13 +573,13 @@ export const streetSuffixAbbreviate: Augmentation = (row) => {
541
573
 
542
574
  if (newRaw === row.raw) return null
543
575
 
544
- return withAugmentation(row, "us-street-suffix-abbreviate", newRaw, newComponents)
545
- }
576
+ return emit(newRaw, newComponents)
577
+ })
546
578
 
547
579
  /**
548
580
  * Expand trailing US street suffix.
549
581
  */
550
- export const streetSuffixExpand: Augmentation = (row) => {
582
+ export const streetSuffixExpand = augmentation("us-street-suffix-expand", (row, emit) => {
551
583
  // country-branch: see `stateExpand`.
552
584
  if (row.country !== "US") return null
553
585
  const street = row.components.street
@@ -572,13 +604,13 @@ export const streetSuffixExpand: Augmentation = (row) => {
572
604
 
573
605
  if (newRaw === row.raw) return null
574
606
 
575
- return withAugmentation(row, "us-street-suffix-expand", newRaw, newComponents)
576
- }
607
+ return emit(newRaw, newComponents)
608
+ })
577
609
 
578
610
  /**
579
611
  * Abbreviate leading US unit designator.
580
612
  */
581
- export const unitDesignatorAbbreviate: Augmentation = (row) => {
613
+ export const unitDesignatorAbbreviate = augmentation("us-unit-designator-abbreviate", (row, emit) => {
582
614
  // country-branch: see `stateExpand`.
583
615
  if (row.country !== "US") return null
584
616
  const unit = row.components.unit
@@ -604,13 +636,13 @@ export const unitDesignatorAbbreviate: Augmentation = (row) => {
604
636
 
605
637
  if (newRaw === row.raw) return null
606
638
 
607
- return withAugmentation(row, "us-unit-designator-abbreviate", newRaw, newComponents)
608
- }
639
+ return emit(newRaw, newComponents)
640
+ })
609
641
 
610
642
  /**
611
643
  * Expand leading US unit designator.
612
644
  */
613
- export const unitDesignatorExpand: Augmentation = (row) => {
645
+ export const unitDesignatorExpand = augmentation("us-unit-designator-expand", (row, emit) => {
614
646
  // country-branch: see `stateExpand`.
615
647
  if (row.country !== "US") return null
616
648
  const unit = row.components.unit
@@ -635,13 +667,13 @@ export const unitDesignatorExpand: Augmentation = (row) => {
635
667
 
636
668
  if (newRaw === row.raw) return null
637
669
 
638
- return withAugmentation(row, "us-unit-designator-expand", newRaw, newComponents)
639
- }
670
+ return emit(newRaw, newComponents)
671
+ })
640
672
 
641
673
  /**
642
674
  * Drop dash from ZIP+4.
643
675
  */
644
- export const zipPlus4DashDrop: Augmentation = (row) => {
676
+ export const zipPlus4DashDrop = augmentation("zip-plus4-dash-drop", (row, emit) => {
645
677
  // country-branch: see `stateExpand`.
646
678
  if (row.country !== "US") return null
647
679
  const postcode = row.components.postcode
@@ -652,15 +684,15 @@ export const zipPlus4DashDrop: Augmentation = (row) => {
652
684
 
653
685
  if (newRaw === row.raw) return null
654
686
 
655
- return withAugmentation(row, "zip-plus4-dash-drop", newRaw, { ...row.components, postcode: noDash })
656
- }
687
+ return emit(newRaw, { ...row.components, postcode: noDash })
688
+ })
657
689
 
658
690
  // French-specific augmentations.
659
691
 
660
692
  /**
661
693
  * Drop French street particle.
662
694
  */
663
- export const particleStrip: Augmentation = (row) => {
695
+ export const particleStrip = augmentation("particle-strip", (row, emit) => {
664
696
  // country-branch: the particle list is French.
665
697
  // A per-language particle table in the codex would replace this.
666
698
  if (row.country !== "FR") return null
@@ -675,8 +707,8 @@ export const particleStrip: Augmentation = (row) => {
675
707
  if (!re.test(row.raw)) return null
676
708
  const newRaw = row.raw.replaceAll(re, " ").replaceAll(/\s+/g, " ").trim()
677
709
 
678
- return withAugmentation(row, "particle-strip", newRaw, newComponents)
679
- }
710
+ return emit(newRaw, newComponents)
711
+ })
680
712
 
681
713
  // Stable augmentation registry.
682
714
 
@@ -738,9 +770,16 @@ export function defaultAugmentationsForCountry(country: string): readonly Augmen
738
770
  */
739
771
  export function* synthesizeRow(
740
772
  row: CanonicalRow,
741
- augmentations: readonly Augmentation[] = defaultAugmentationsForCountry(row.country)
773
+ augmentations: readonly Augmentation[] = defaultAugmentationsForCountry(row.country),
774
+ /**
775
+ * Whether the caller wants the variant an augmentation's method writes. An augmentation it doesn't want isn't
776
+ * run, so a caller that would drop the variant skips its work.
777
+ */
778
+ wants?: (method: string) => boolean
742
779
  ): Generator<CanonicalRow> {
743
780
  for (const aug of augmentations) {
781
+ if (wants && !wants(aug.method)) continue
782
+
744
783
  const out = aug(row)
745
784
 
746
785
  if (out) {
package/lib/test-kit.ts CHANGED
@@ -13,7 +13,8 @@
13
13
 
14
14
  import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
15
15
  import { temporaryDirectory, type TemporaryDirectory } from "@mailwoman/core/fs/temporary"
16
- import { writeLocalJSONFile } from "@mailwoman/core/fs/writers"
16
+ import { writeLocalJSONFile, writeLocalTextFile } from "@mailwoman/core/fs/writers"
17
+ import { workspacePath } from "@mailwoman/core/paths"
17
18
  import { stringifyJSON } from "@mailwoman/core/values/json"
18
19
  import { PathBuilder, type PathBuilderLike } from "path-ts"
19
20
  import { createNewlineWriter, JSONSpliterator } from "spliterator"
@@ -21,6 +22,8 @@ import { afterEach, beforeEach, expect } from "vitest"
21
22
 
22
23
  import type { ParquetRow } from "#parquet/schema"
23
24
  import type { CanonicalRow } from "#types"
25
+ import { NAD_RECORD_COLUMNS } from "#us/adapters/usgov/nad/adapter"
26
+ import { convertNADToParquet } from "#us/tools/fetch/nad/parquet"
24
27
 
25
28
  /**
26
29
  * A per-test scratch directory.
@@ -191,6 +194,52 @@ export class ReferenceFixture<T extends object> {
191
194
  }
192
195
  }
193
196
 
197
+ /**
198
+ * The NAD adapter's fixture records, one JSON object per line.
199
+ */
200
+ export const NAD_FIXTURE = workspacePath(
201
+ "corpus",
202
+ "lib",
203
+ "us",
204
+ "adapters",
205
+ "usgov",
206
+ "nad",
207
+ "fixtures",
208
+ "fixture.ndjson"
209
+ )
210
+
211
+ /**
212
+ * Writes `records` as NAD release text with every column the adapter reads into `dir`,
213
+ * and converts it to `NAD_test.parquet` there the way the fetcher does.
214
+ *
215
+ * Without `records`, it writes {@linkcode NAD_FIXTURE}'s.
216
+ */
217
+ export async function writeNADReleaseParquet(
218
+ dir: PathBuilder,
219
+ records?: ReadonlyArray<Record<string, unknown>>
220
+ ): Promise<PathBuilder> {
221
+ const rows = records ?? (await Array.fromAsync(JSONSpliterator.fromAsync<Record<string, unknown>>(NAD_FIXTURE)))
222
+
223
+ const cell = (value: unknown) => {
224
+ const text = value == null ? "" : String(value)
225
+
226
+ return /[",\r\n]/u.test(text) ? `"${text.replaceAll('"', '""')}"` : text
227
+ }
228
+
229
+ const lines = [
230
+ NAD_RECORD_COLUMNS.join(","),
231
+ ...rows.map((record) => NAD_RECORD_COLUMNS.map((column) => cell(record[column])).join(",")),
232
+ ]
233
+
234
+ const textPath = dir("NAD_test.txt")
235
+ const parquetPath = dir("NAD_test.parquet")
236
+
237
+ await writeLocalTextFile(`${lines.join("\n")}\n`, textPath)
238
+ await convertNADToParquet({ textPath, parquetPath, sourceSHA256: "test", member: "NAD_test.txt" })
239
+
240
+ return parquetPath
241
+ }
242
+
194
243
  /**
195
244
  * One GB parquet row whose postcode sits at the end of `raw`, the shape `rendered-gb-os-open` renders.
196
245
  *
@@ -0,0 +1,118 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+
4
+ /**
5
+ * Copies the Indian places of an Overture Maps release, with their first address,
6
+ * into the `overture-places-in/<release>/` snapshot the `overture-places-in` adapter reads.
7
+ *
8
+ * The places theme sits on Overture's public bucket,
9
+ * `s3://overturemaps-us-west-2/release/<release>/theme=places/`, which needs no credential.
10
+ * The query reads only the row groups whose bounding boxes fall in India's
11
+ * (68–98° E, 6–37.5° N) and keeps the rows whose first address has the country `IN`,
12
+ * so the copy reads a few hundred megabytes of the theme rather than all of it.
13
+ *
14
+ * Overture's attribution page lists the places theme's contributors under CDLA Permissive 2.0,
15
+ * Foursquare under Apache 2.0 and AllThePlaces under CC0 1.0.
16
+ * Each row keeps the dataset of its first source, so a count can be split by contributor.
17
+ */
18
+
19
+ import { sha256File } from "@mailwoman/core/crypto/hash"
20
+ import { statPath } from "@mailwoman/core/fs/readers/stat"
21
+ import { DEFAULT_RELEASE } from "@mailwoman/gazetteer/tools/pipeline/poi/defaults"
22
+ import type { PathBuilder } from "path-ts"
23
+
24
+ import { escapeSQLString, openDuckDB } from "#parquet/duckdb"
25
+ import { countParquetRows } from "#parquet/readers"
26
+ import type { FetchSummary } from "#tools/fetch/download"
27
+ import { writeManifest } from "#tools/fetch/download"
28
+ import { fetchSnapshot, type SnapshotFetchOptions } from "#tools/fetch/storage"
29
+
30
+ const SLUG = "overture-places-in"
31
+
32
+ /**
33
+ * The file the snapshot holds.
34
+ */
35
+ const OVERTURE_PLACES_IN_FILE = "places-in.parquet"
36
+
37
+ export interface FetchOverturePlacesINOptions extends SnapshotFetchOptions {
38
+ /**
39
+ * The Overture release to copy, such as `2026-09-23.1`.
40
+ * It is also the snapshot's vintage.
41
+ */
42
+ release?: string | null
43
+ }
44
+
45
+ /**
46
+ * The places theme's files in one release.
47
+ */
48
+ function placesGlob(release: string): string {
49
+ return `s3://overturemaps-us-west-2/release/${release}/theme=places/type=place/*.parquet`
50
+ }
51
+
52
+ /**
53
+ * Copies the release's Indian places with an address into its snapshot.
54
+ */
55
+ export async function fetchOverturePlacesIN(
56
+ options: FetchOverturePlacesINOptions,
57
+ report?: (line: string) => void
58
+ ): Promise<FetchSummary> {
59
+ // Without a release from the caller, the one the gazetteer's places build pins.
60
+ const release = options.release || options.snapshots.vintage || DEFAULT_RELEASE
61
+
62
+ report?.(`=== ${SLUG} (Overture release ${release})`)
63
+
64
+ return fetchSnapshot(options.snapshots, SLUG, release, (directory) => copyPlaces(release, directory, report), report)
65
+ }
66
+
67
+ async function copyPlaces(
68
+ release: string,
69
+ directory: PathBuilder,
70
+ report?: (line: string) => void
71
+ ): Promise<FetchSummary> {
72
+ const glob = placesGlob(release)
73
+ const dest = directory(OVERTURE_PLACES_IN_FILE)
74
+ const started = Date.now()
75
+
76
+ {
77
+ using db = await openDuckDB({ threads: 4 })
78
+
79
+ await db.run("INSTALL httpfs; LOAD httpfs;")
80
+ await db.run("SET s3_region='us-west-2';")
81
+
82
+ report?.(` Reading ${glob} ...`)
83
+
84
+ await db.run(`COPY (
85
+ SELECT
86
+ id,
87
+ addresses[1].freeform AS freeform,
88
+ addresses[1].locality AS locality,
89
+ addresses[1].region AS region,
90
+ addresses[1].postcode AS postcode,
91
+ sources[1].dataset AS dataset,
92
+ sources[1].record_id AS record_id
93
+ FROM read_parquet('${escapeSQLString(glob)}', hive_partitioning = false)
94
+ WHERE bbox.xmin BETWEEN 68 AND 98 AND bbox.ymin BETWEEN 6 AND 37.5
95
+ AND addresses[1].country = 'IN'
96
+ ) TO '${escapeSQLString(dest.toString())}' (FORMAT parquet, COMPRESSION zstd)`)
97
+ }
98
+
99
+ const rows = await countParquetRows(dest)
100
+ const bytes = (await statPath(dest)).size
101
+ const sha256 = await sha256File(dest)
102
+
103
+ await writeManifest(directory("MANIFEST.json"), {
104
+ source_url: glob,
105
+ downloaded_at: new Date().toISOString(),
106
+ filename: OVERTURE_PLACES_IN_FILE,
107
+ sha256,
108
+ bytes,
109
+ publisher_version: release,
110
+ rows,
111
+ })
112
+
113
+ report?.(
114
+ ` ✓ ${rows} places, ${(bytes / 1024 / 1024).toFixed(1)} MB in ${((Date.now() - started) / 1000).toFixed(0)} s`
115
+ )
116
+
117
+ return { fetched: 1, skipped: 0, failed: 0, failedCodes: [] }
118
+ }
@@ -102,6 +102,8 @@ export const SOURCE_STORAGE_CLASSES = {
102
102
  "nga-wpi": StorageClass.current,
103
103
  openaddresses: StorageClass.current,
104
104
  ourairports: StorageClass.current,
105
+ // One Overture release's Indian places, under the release id as the vintage.
106
+ "overture-places-in": StorageClass.snapshot,
105
107
  "ro-retea-scolara": StorageClass.current,
106
108
  ryhti: StorageClass.current,
107
109
  "sk-inspire": StorageClass.current,
@@ -221,6 +223,7 @@ export const FETCH_SOURCE_DIRECTORIES = {
221
223
  nppes: ["usgov-nppes"],
222
224
  openaddresses: ["openaddresses"],
223
225
  ourairports: ["ourairports"],
226
+ "overture-places-in": ["overture-places-in"],
224
227
  "ro-retea-scolara": ["ro-retea-scolara"],
225
228
  ryhti: ["ryhti"],
226
229
  "sk-inspire": ["sk-inspire"],
@@ -42,6 +42,7 @@ import { fetchGeonamesPostal } from "#tools/fetch/geonames/postal"
42
42
  import { fetchGLEIF } from "#tools/fetch/gleif"
43
43
  import { fetchOpenAddresses } from "#tools/fetch/openaddresses"
44
44
  import { fetchOurAirports } from "#tools/fetch/ourairports"
45
+ import { fetchOverturePlacesIN } from "#tools/fetch/overture-places-in"
45
46
  import { fetchVlaanderenAD } from "#tools/fetch/vlaanderen-ad"
46
47
  import { fetchWikidataSubVenue } from "#tools/fetch/wikidata/subvenue"
47
48
  import { fetchWikidataVitalPlaces } from "#tools/fetch/wikidata/vital-places"
@@ -102,6 +103,7 @@ export const FETCH_SOURCES = {
102
103
  "nga-wpi": fetchNGAWPI,
103
104
  openaddresses: fetchOpenAddresses,
104
105
  ourairports: fetchOurAirports,
106
+ "overture-places-in": fetchOverturePlacesIN,
105
107
  vlaanderen: fetchVlaanderenAD,
106
108
  wallonie: fetchWallonie,
107
109
  "state-sources": fetchStateSources,
@@ -23,7 +23,7 @@ import {
23
23
  readSecondLevelNames,
24
24
  secondLevelAdmitted,
25
25
  type SecondLevelRegionTable,
26
- } from "#build/region-names"
26
+ } from "#build/region/names"
27
27
  import { escapeSQLString, openDuckDB } from "#parquet/duckdb"
28
28
  import { parquetColumnNames } from "#parquet/readers"
29
29
  import { localManifestFilePath } from "#tools/overlay/manifest"
@@ -155,7 +155,7 @@ const table: SecondLevelRegionTable = {
155
155
  $description:
156
156
  "Per country, the base rows with a region and those whose region is a second-level (WOF county) name " +
157
157
  "of the country and no region name of it. Written by packages/corpus/lib/tools/region-slot-census.run.ts; " +
158
- "secondLevelAdmitted in packages/corpus/lib/build/region-names.ts decides which countries the region:unknown rule admits.",
158
+ "secondLevelAdmitted in packages/corpus/lib/build/region/names.ts decides which countries the region:unknown rule admits.",
159
159
  manifest: manifestPath,
160
160
  countries: Object.fromEntries(
161
161
  countries
package/lib/types.ts CHANGED
@@ -387,6 +387,36 @@ export interface AdapterOptions {
387
387
  */
388
388
  sample?: RowSample | null
389
389
 
390
+ /**
391
+ * The share of the source's training rows a build keeps, from 0 to 1, or no value to keep them all.
392
+ *
393
+ * Align applies it after each row's split is decided, so validation and test keep every row.
394
+ * A training row is kept when a salted hash of its id up to the last `#` falls
395
+ * under the share (`keepsTrainRow`).
396
+ *
397
+ * An id with no `#` draws per row, so a record's variants draw apart.
398
+ * The adapter ignores it.
399
+ */
400
+ trainShare?: number | null
401
+
402
+ /**
403
+ * The input rows to read, by position in the input file from `start` up to `end`,
404
+ * for an adapter that declares {@linkcode CorpusAdapter.inputRowCount}.
405
+ *
406
+ * A parallel build runs one partition of a large input per range and merges them in order,
407
+ * so a row's output must depend only on the row: its id comes from its own fields
408
+ * or its position in the file, never from a count of the rows before it.
409
+ */
410
+ rowRange?: { start: number; end: number } | null
411
+
412
+ /**
413
+ * Limits for the DuckDB instance an adapter reading parquet opens, set by a parallel
414
+ * build's partition worker so several partitions fit the host at once.
415
+ *
416
+ * An adapter without DuckDB ignores it, and it changes no row.
417
+ */
418
+ duckdb?: { memoryLimitBytes: number; threads: number } | null
419
+
390
420
  /**
391
421
  * A cancellation signal that adapters should check at each iteration.
392
422
  */
@@ -535,4 +565,13 @@ export interface CorpusAdapter {
535
565
  * They mustn't mutate rows already yielded.
536
566
  */
537
567
  rows(opts: AdapterOptions): AsyncIterable<CanonicalRow>
568
+
569
+ /**
570
+ * The number of rows in the input `opts.inputPath` names, for an adapter that
571
+ * reads {@linkcode AdapterOptions.rowRange}.
572
+ *
573
+ * Its presence declares that the adapter can read its input in row ranges,
574
+ * so a parallel build may split a large input across workers.
575
+ */
576
+ inputRowCount?(opts: AdapterOptions): Promise<number>
538
577
  }