@mailwoman/corpus 11.1.0 → 11.2.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 (474) hide show
  1. package/README.md +20 -14
  2. package/data/address-source-register.json +618 -13
  3. package/data/builds/v0.8.19-overlay/OVERLAY_PLAN.json +4778 -0
  4. package/data/builds/v0.8.19-rebuild/inputs.json +128 -0
  5. package/data/builds/v0.8.20-overlay/OVERLAY_PLAN.json +3595 -0
  6. package/data/builds/v0.8.20-rebuild/inputs.json +131 -0
  7. package/data/builds/v0.8.21-overlay/OVERLAY_PLAN.json +72 -0
  8. package/data/corpus-source-inputs.json +104 -2
  9. package/data/holdout/evaluation-groups.v0.8.18.json +90511 -0
  10. package/data/holdout/evaluation-groups.v0.8.19.json +100537 -0
  11. package/data/holdout/evaluation-groups.v0.8.20.json +129215 -0
  12. package/data/holdout/evaluation-groups.v0.8.21.json +173286 -0
  13. package/data/holdout/probe-text-collisions.v0.8.20.json +1478 -0
  14. package/data/license-decisions.json +393 -3
  15. package/data/licenses/PROVENANCE.md +15 -9
  16. package/data/licenses/au-acnc-cc-by-3.0-au.md +37 -0
  17. package/data/licenses/es-sanidad-aviso-legal.md +26 -0
  18. package/data/licenses/it-miur-iodl-2.0.md +41 -0
  19. package/data/licenses/nz-charities-cc-by-3.0-nz.md +36 -0
  20. package/data/region-slot-second-level.json +966 -0
  21. package/data/source-additions.json +126 -6
  22. package/data/source-resolutions.json +97 -0
  23. package/data/training-configs/v8.7.0-base-c6-90k-usgs-structures-s42.yaml +801 -0
  24. package/data/training-configs/v8.7.0-base-c6-90k-usgs-structures-s43.yaml +726 -0
  25. package/data/training-configs/v8.8.0-base-c6-90k-v0820-county-s42.yaml +944 -0
  26. package/data/training-configs/v8.9.0-base-c6-90k-v0821-s42.yaml +848 -0
  27. package/data/training-manifests/v0.8.19-retention-overlay.json +4553 -0
  28. package/data/training-manifests/v0.8.20-retention-overlay.json +4579 -0
  29. package/data/training-manifests/v0.8.21-retention-overlay.effective.json +2521 -0
  30. package/data/training-manifests/v0.8.21-retention-overlay.json +4579 -0
  31. package/lib/adapters/cordis/adapter.ts +10 -2
  32. package/lib/adapters/gleif/adapter.ts +23 -5
  33. package/lib/adapters/osm/adapter.ts +2 -2
  34. package/lib/adapters/street/repetition.ts +87 -0
  35. package/lib/adapters/street/unit.ts +14 -0
  36. package/lib/adapters/wof/admin/json/adapter.ts +34 -21
  37. package/lib/adapters/wof/admin/json/dual-role.ts +274 -0
  38. package/lib/adapters/wof/admin/json/explore.ts +4 -4
  39. package/lib/adapters/wof/admin/json/region-codes.ts +74 -3
  40. package/lib/adapters/wof/json-rows.ts +36 -21
  41. package/lib/adapters/wof/postalcode-json/adapter.ts +10 -28
  42. package/lib/adapters/wof/sample.ts +15 -3
  43. package/lib/adapters/wof/stored-records.ts +162 -0
  44. package/lib/adapters.ts +18 -6
  45. package/lib/au/adapters/acnc-register/adapter.ts +40 -0
  46. package/lib/au/evaluation/acnc-register.ts +144 -0
  47. package/lib/build/align/range.ts +9 -0
  48. package/lib/build/align/totals.ts +23 -0
  49. package/lib/build/align.ts +74 -4
  50. package/lib/build/budget.ts +11 -45
  51. package/lib/build/checkpoint.ts +11 -0
  52. package/lib/build/component-check.ts +99 -3
  53. package/lib/build/manifest.ts +4 -0
  54. package/lib/build/parallel.ts +8 -34
  55. package/lib/build/region-names.ts +609 -0
  56. package/lib/build/source-record.ts +7 -0
  57. package/lib/build/types.ts +20 -0
  58. package/lib/build/worker.ts +3 -1
  59. package/lib/build.ts +3 -6
  60. package/lib/de/recipes/locale.ts +3 -2
  61. package/lib/env.ts +0 -6
  62. package/lib/es/adapters/sanidad-centros-ap/adapter.ts +40 -0
  63. package/lib/es/evaluation/sanidad-centros-ap.ts +164 -0
  64. package/lib/evaluation/corpus-adapter.ts +153 -0
  65. package/lib/evaluation/source.ts +209 -0
  66. package/lib/evaluation/sources.ts +25 -0
  67. package/lib/fr/adapters/laposte-poincont/adapter.ts +381 -0
  68. package/lib/fr/recipes/unit-line-guideline.ts +9 -4
  69. package/lib/fr/structures/laposte.ts +139 -0
  70. package/lib/fr/tools/fetch/laposte-poincont.ts +234 -0
  71. package/lib/it/adapters/miur-scuole/adapter.ts +39 -0
  72. package/lib/it/evaluation/miur-scuole.ts +125 -0
  73. package/lib/jp/adapters/wof-admin/adapter.ts +4 -4
  74. package/lib/nc/adapters/opt-nc/adapter.ts +237 -0
  75. package/lib/nc/structures/opt-nc.ts +101 -0
  76. package/lib/nc/tools/fetch/opt-nc.ts +249 -0
  77. package/lib/nz/adapters/charities-register/adapter.ts +40 -0
  78. package/lib/nz/evaluation/charities-register.ts +149 -0
  79. package/lib/recipes/bare/postcode.ts +14 -11
  80. package/lib/recipes/deepseek/batches.ts +8 -8
  81. package/lib/recipes/po/box/cedex/recipe.ts +12 -1
  82. package/lib/recipes/po/box/cedex/us.ts +43 -2
  83. package/lib/recipes/scaffold.ts +1 -1
  84. package/lib/recipes/sources.ts +16 -0
  85. package/lib/recipes.ts +2 -0
  86. package/lib/registers.ts +28 -2
  87. package/lib/{post-offices → structures}/source.ts +49 -16
  88. package/lib/structures/sources.ts +26 -0
  89. package/lib/synthesizers/house-venue.ts +11 -6
  90. package/lib/synthesizers/tail.ts +27 -3
  91. package/lib/tools/audit.ts +1 -1
  92. package/lib/tools/fetch/storage.ts +18 -4
  93. package/lib/tools/fetch.ts +10 -2
  94. package/lib/tools/overlay/kryptonite.ts +6 -2
  95. package/lib/tools/overlay/split/attribute.ts +14 -2
  96. package/lib/tools/overlay/split/overlay.ts +36 -7
  97. package/lib/tools/postcode/triples.ts +3 -3
  98. package/lib/tools/region-slot-census.run.ts +184 -0
  99. package/lib/training/config/load.ts +19 -0
  100. package/lib/training/config/schema.ts +6 -0
  101. package/lib/tw/registers.ts +15 -4
  102. package/lib/tw/structures/chunghwa-post.ts +191 -0
  103. package/lib/tw/tools/fetch/chunghwa-post.ts +174 -0
  104. package/lib/us/adapters/state/ny-notaries/adapter.ts +7 -2
  105. package/lib/us/adapters/state/tx-notaries/adapter.ts +126 -21
  106. package/lib/us/adapters/usgov/nad/adapter.ts +111 -31
  107. package/lib/us/adapters/usgov/nppes/adapter.ts +8 -11
  108. package/lib/us/adapters/usgov/{usgs-post-offices → usgs-structures}/adapter.ts +65 -35
  109. package/lib/us/recipes/county.ts +474 -0
  110. package/lib/us/street-unit.ts +15 -5
  111. package/lib/us/structures/usgs/layers.ts +171 -0
  112. package/lib/us/structures/usgs/national-map.ts +95 -0
  113. package/lib/us/tools/fetch/usgs/gnis.ts +288 -0
  114. package/lib/us/tools/fetch/usgs/structures.ts +362 -0
  115. package/lib/utils/align.ts +2 -2
  116. package/lib/utils/evaluation-groups.ts +172 -0
  117. package/lib/utils/split.ts +40 -4
  118. package/lib/utils/tokenize.ts +7 -7
  119. package/lib/utils/validation-groups.ts +292 -0
  120. package/lib/utils/wof-json.ts +96 -134
  121. package/out/adapters/cordis/adapter.d.ts +3 -1
  122. package/out/adapters/cordis/adapter.d.ts.map +1 -1
  123. package/out/adapters/cordis/adapter.js +8 -2
  124. package/out/adapters/cordis/adapter.js.map +1 -1
  125. package/out/adapters/gleif/adapter.d.ts.map +1 -1
  126. package/out/adapters/gleif/adapter.js +19 -5
  127. package/out/adapters/gleif/adapter.js.map +1 -1
  128. package/out/adapters/osm/adapter.js +2 -2
  129. package/out/adapters/osm/adapter.js.map +1 -1
  130. package/out/adapters/street/repetition.d.ts +19 -0
  131. package/out/adapters/street/repetition.d.ts.map +1 -0
  132. package/out/adapters/street/repetition.js +71 -0
  133. package/out/adapters/street/repetition.js.map +1 -0
  134. package/out/adapters/street/unit.d.ts +10 -0
  135. package/out/adapters/street/unit.d.ts.map +1 -1
  136. package/out/adapters/street/unit.js +6 -0
  137. package/out/adapters/street/unit.js.map +1 -1
  138. package/out/adapters/wof/admin/json/adapter.d.ts +8 -0
  139. package/out/adapters/wof/admin/json/adapter.d.ts.map +1 -1
  140. package/out/adapters/wof/admin/json/adapter.js +26 -22
  141. package/out/adapters/wof/admin/json/adapter.js.map +1 -1
  142. package/out/adapters/wof/admin/json/dual-role.d.ts +83 -0
  143. package/out/adapters/wof/admin/json/dual-role.d.ts.map +1 -0
  144. package/out/adapters/wof/admin/json/dual-role.js +183 -0
  145. package/out/adapters/wof/admin/json/dual-role.js.map +1 -0
  146. package/out/adapters/wof/admin/json/explore.d.ts.map +1 -1
  147. package/out/adapters/wof/admin/json/explore.js +4 -4
  148. package/out/adapters/wof/admin/json/explore.js.map +1 -1
  149. package/out/adapters/wof/admin/json/region-codes.d.ts +16 -0
  150. package/out/adapters/wof/admin/json/region-codes.d.ts.map +1 -1
  151. package/out/adapters/wof/admin/json/region-codes.js +62 -3
  152. package/out/adapters/wof/admin/json/region-codes.js.map +1 -1
  153. package/out/adapters/wof/json-rows.d.ts +28 -6
  154. package/out/adapters/wof/json-rows.d.ts.map +1 -1
  155. package/out/adapters/wof/json-rows.js +9 -15
  156. package/out/adapters/wof/json-rows.js.map +1 -1
  157. package/out/adapters/wof/postalcode-json/adapter.d.ts +1 -1
  158. package/out/adapters/wof/postalcode-json/adapter.d.ts.map +1 -1
  159. package/out/adapters/wof/postalcode-json/adapter.js +9 -26
  160. package/out/adapters/wof/postalcode-json/adapter.js.map +1 -1
  161. package/out/adapters/wof/sample.d.ts +8 -1
  162. package/out/adapters/wof/sample.d.ts.map +1 -1
  163. package/out/adapters/wof/sample.js +12 -4
  164. package/out/adapters/wof/sample.js.map +1 -1
  165. package/out/adapters/wof/stored-records.d.ts +62 -0
  166. package/out/adapters/wof/stored-records.d.ts.map +1 -0
  167. package/out/adapters/wof/stored-records.js +91 -0
  168. package/out/adapters/wof/stored-records.js.map +1 -0
  169. package/out/adapters.d.ts +1 -1
  170. package/out/adapters.d.ts.map +1 -1
  171. package/out/adapters.js +15 -3
  172. package/out/adapters.js.map +1 -1
  173. package/out/au/adapters/acnc-register/adapter.d.ts +9 -0
  174. package/out/au/adapters/acnc-register/adapter.d.ts.map +1 -0
  175. package/out/au/adapters/acnc-register/adapter.js +37 -0
  176. package/out/au/adapters/acnc-register/adapter.js.map +1 -0
  177. package/out/au/evaluation/acnc-register.d.ts +56 -0
  178. package/out/au/evaluation/acnc-register.d.ts.map +1 -0
  179. package/out/au/evaluation/acnc-register.js +84 -0
  180. package/out/au/evaluation/acnc-register.js.map +1 -0
  181. package/out/build/align/range.d.ts.map +1 -1
  182. package/out/build/align/range.js +9 -0
  183. package/out/build/align/range.js.map +1 -1
  184. package/out/build/align/totals.d.ts +5 -0
  185. package/out/build/align/totals.d.ts.map +1 -1
  186. package/out/build/align/totals.js +15 -0
  187. package/out/build/align/totals.js.map +1 -1
  188. package/out/build/align.d.ts +26 -0
  189. package/out/build/align.d.ts.map +1 -1
  190. package/out/build/align.js +35 -2
  191. package/out/build/align.js.map +1 -1
  192. package/out/build/budget.d.ts +9 -26
  193. package/out/build/budget.d.ts.map +1 -1
  194. package/out/build/budget.js +10 -31
  195. package/out/build/budget.js.map +1 -1
  196. package/out/build/checkpoint.d.ts +11 -0
  197. package/out/build/checkpoint.d.ts.map +1 -1
  198. package/out/build/checkpoint.js.map +1 -1
  199. package/out/build/component-check.d.ts +55 -1
  200. package/out/build/component-check.d.ts.map +1 -1
  201. package/out/build/component-check.js +65 -3
  202. package/out/build/component-check.js.map +1 -1
  203. package/out/build/manifest.d.ts.map +1 -1
  204. package/out/build/manifest.js +4 -0
  205. package/out/build/manifest.js.map +1 -1
  206. package/out/build/parallel.d.ts.map +1 -1
  207. package/out/build/parallel.js +8 -24
  208. package/out/build/parallel.js.map +1 -1
  209. package/out/build/region-names.d.ts +120 -0
  210. package/out/build/region-names.d.ts.map +1 -0
  211. package/out/build/region-names.js +430 -0
  212. package/out/build/region-names.js.map +1 -0
  213. package/out/build/source-record.d.ts.map +1 -1
  214. package/out/build/source-record.js +4 -0
  215. package/out/build/source-record.js.map +1 -1
  216. package/out/build/types.d.ts +20 -0
  217. package/out/build/types.d.ts.map +1 -1
  218. package/out/build/worker.js +3 -1
  219. package/out/build/worker.js.map +1 -1
  220. package/out/build.d.ts +0 -1
  221. package/out/build.d.ts.map +1 -1
  222. package/out/build.js +3 -5
  223. package/out/build.js.map +1 -1
  224. package/out/de/recipes/locale.d.ts.map +1 -1
  225. package/out/de/recipes/locale.js +3 -2
  226. package/out/de/recipes/locale.js.map +1 -1
  227. package/out/env.d.ts +0 -2
  228. package/out/env.d.ts.map +1 -1
  229. package/out/env.js +0 -5
  230. package/out/env.js.map +1 -1
  231. package/out/es/adapters/sanidad-centros-ap/adapter.d.ts +9 -0
  232. package/out/es/adapters/sanidad-centros-ap/adapter.d.ts.map +1 -0
  233. package/out/es/adapters/sanidad-centros-ap/adapter.js +36 -0
  234. package/out/es/adapters/sanidad-centros-ap/adapter.js.map +1 -0
  235. package/out/es/evaluation/sanidad-centros-ap.d.ts +34 -0
  236. package/out/es/evaluation/sanidad-centros-ap.d.ts.map +1 -0
  237. package/out/es/evaluation/sanidad-centros-ap.js +128 -0
  238. package/out/es/evaluation/sanidad-centros-ap.js.map +1 -0
  239. package/out/evaluation/corpus-adapter.d.ts +60 -0
  240. package/out/evaluation/corpus-adapter.d.ts.map +1 -0
  241. package/out/evaluation/corpus-adapter.js +100 -0
  242. package/out/evaluation/corpus-adapter.js.map +1 -0
  243. package/out/evaluation/source.d.ts +134 -0
  244. package/out/evaluation/source.d.ts.map +1 -0
  245. package/out/evaluation/source.js +80 -0
  246. package/out/evaluation/source.js.map +1 -0
  247. package/out/evaluation/sources.d.ts +6 -0
  248. package/out/evaluation/sources.d.ts.map +1 -0
  249. package/out/evaluation/sources.js +22 -0
  250. package/out/evaluation/sources.js.map +1 -0
  251. package/out/fr/adapters/laposte-poincont/adapter.d.ts +110 -0
  252. package/out/fr/adapters/laposte-poincont/adapter.d.ts.map +1 -0
  253. package/out/fr/adapters/laposte-poincont/adapter.js +315 -0
  254. package/out/fr/adapters/laposte-poincont/adapter.js.map +1 -0
  255. package/out/fr/recipes/unit-line-guideline.d.ts.map +1 -1
  256. package/out/fr/recipes/unit-line-guideline.js +8 -4
  257. package/out/fr/recipes/unit-line-guideline.js.map +1 -1
  258. package/out/fr/structures/laposte.d.ts +27 -0
  259. package/out/fr/structures/laposte.d.ts.map +1 -0
  260. package/out/fr/structures/laposte.js +96 -0
  261. package/out/fr/structures/laposte.js.map +1 -0
  262. package/out/fr/tools/fetch/laposte-poincont.d.ts +95 -0
  263. package/out/fr/tools/fetch/laposte-poincont.d.ts.map +1 -0
  264. package/out/fr/tools/fetch/laposte-poincont.js +135 -0
  265. package/out/fr/tools/fetch/laposte-poincont.js.map +1 -0
  266. package/out/it/adapters/miur-scuole/adapter.d.ts +9 -0
  267. package/out/it/adapters/miur-scuole/adapter.d.ts.map +1 -0
  268. package/out/it/adapters/miur-scuole/adapter.js +35 -0
  269. package/out/it/adapters/miur-scuole/adapter.js.map +1 -0
  270. package/out/it/evaluation/miur-scuole.d.ts +53 -0
  271. package/out/it/evaluation/miur-scuole.d.ts.map +1 -0
  272. package/out/it/evaluation/miur-scuole.js +68 -0
  273. package/out/it/evaluation/miur-scuole.js.map +1 -0
  274. package/out/jp/adapters/wof-admin/adapter.js +4 -4
  275. package/out/nc/adapters/opt-nc/adapter.d.ts +84 -0
  276. package/out/nc/adapters/opt-nc/adapter.d.ts.map +1 -0
  277. package/out/nc/adapters/opt-nc/adapter.js +173 -0
  278. package/out/nc/adapters/opt-nc/adapter.js.map +1 -0
  279. package/out/nc/structures/opt-nc.d.ts +12 -0
  280. package/out/nc/structures/opt-nc.d.ts.map +1 -0
  281. package/out/nc/structures/opt-nc.js +64 -0
  282. package/out/nc/structures/opt-nc.js.map +1 -0
  283. package/out/nc/tools/fetch/opt-nc.d.ts +81 -0
  284. package/out/nc/tools/fetch/opt-nc.d.ts.map +1 -0
  285. package/out/nc/tools/fetch/opt-nc.js +162 -0
  286. package/out/nc/tools/fetch/opt-nc.js.map +1 -0
  287. package/out/nz/adapters/charities-register/adapter.d.ts +9 -0
  288. package/out/nz/adapters/charities-register/adapter.d.ts.map +1 -0
  289. package/out/nz/adapters/charities-register/adapter.js +36 -0
  290. package/out/nz/adapters/charities-register/adapter.js.map +1 -0
  291. package/out/nz/evaluation/charities-register.d.ts +60 -0
  292. package/out/nz/evaluation/charities-register.d.ts.map +1 -0
  293. package/out/nz/evaluation/charities-register.js +84 -0
  294. package/out/nz/evaluation/charities-register.js.map +1 -0
  295. package/out/recipes/bare/postcode.d.ts +2 -1
  296. package/out/recipes/bare/postcode.d.ts.map +1 -1
  297. package/out/recipes/bare/postcode.js +14 -11
  298. package/out/recipes/bare/postcode.js.map +1 -1
  299. package/out/recipes/deepseek/batches.d.ts +11 -1
  300. package/out/recipes/deepseek/batches.d.ts.map +1 -1
  301. package/out/recipes/deepseek/batches.js +8 -7
  302. package/out/recipes/deepseek/batches.js.map +1 -1
  303. package/out/recipes/po/box/cedex/recipe.d.ts.map +1 -1
  304. package/out/recipes/po/box/cedex/recipe.js +12 -1
  305. package/out/recipes/po/box/cedex/recipe.js.map +1 -1
  306. package/out/recipes/po/box/cedex/us.d.ts +12 -0
  307. package/out/recipes/po/box/cedex/us.d.ts.map +1 -1
  308. package/out/recipes/po/box/cedex/us.js +36 -2
  309. package/out/recipes/po/box/cedex/us.js.map +1 -1
  310. package/out/recipes/scaffold.d.ts +1 -1
  311. package/out/recipes/sources.d.ts.map +1 -1
  312. package/out/recipes/sources.js +16 -0
  313. package/out/recipes/sources.js.map +1 -1
  314. package/out/recipes.d.ts.map +1 -1
  315. package/out/recipes.js +2 -0
  316. package/out/recipes.js.map +1 -1
  317. package/out/registers.d.ts +28 -2
  318. package/out/registers.d.ts.map +1 -1
  319. package/out/registers.js +28 -2
  320. package/out/registers.js.map +1 -1
  321. package/out/{post-offices → structures}/source.d.ts +34 -16
  322. package/out/structures/source.d.ts.map +1 -0
  323. package/out/structures/source.js +39 -0
  324. package/out/structures/source.js.map +1 -0
  325. package/out/structures/sources.d.ts +6 -0
  326. package/out/structures/sources.d.ts.map +1 -0
  327. package/out/structures/sources.js +23 -0
  328. package/out/structures/sources.js.map +1 -0
  329. package/out/synthesizers/house-venue.d.ts.map +1 -1
  330. package/out/synthesizers/house-venue.js +2 -1
  331. package/out/synthesizers/house-venue.js.map +1 -1
  332. package/out/synthesizers/tail.d.ts +15 -1
  333. package/out/synthesizers/tail.d.ts.map +1 -1
  334. package/out/synthesizers/tail.js +8 -3
  335. package/out/synthesizers/tail.js.map +1 -1
  336. package/out/tools/audit.js +1 -1
  337. package/out/tools/audit.js.map +1 -1
  338. package/out/tools/fetch/storage.d.ts +10 -2
  339. package/out/tools/fetch/storage.d.ts.map +1 -1
  340. package/out/tools/fetch/storage.js +18 -4
  341. package/out/tools/fetch/storage.js.map +1 -1
  342. package/out/tools/fetch.d.ts +10 -2
  343. package/out/tools/fetch.d.ts.map +1 -1
  344. package/out/tools/fetch.js +10 -2
  345. package/out/tools/fetch.js.map +1 -1
  346. package/out/tools/overlay/kryptonite.d.ts.map +1 -1
  347. package/out/tools/overlay/kryptonite.js +5 -2
  348. package/out/tools/overlay/kryptonite.js.map +1 -1
  349. package/out/tools/overlay/split/attribute.d.ts +7 -1
  350. package/out/tools/overlay/split/attribute.d.ts.map +1 -1
  351. package/out/tools/overlay/split/attribute.js +4 -1
  352. package/out/tools/overlay/split/attribute.js.map +1 -1
  353. package/out/tools/overlay/split/overlay.d.ts +10 -0
  354. package/out/tools/overlay/split/overlay.d.ts.map +1 -1
  355. package/out/tools/overlay/split/overlay.js +17 -4
  356. package/out/tools/overlay/split/overlay.js.map +1 -1
  357. package/out/tools/postcode/triples.js +3 -3
  358. package/out/tools/postcode/triples.js.map +1 -1
  359. package/out/tools/region-slot-census.run.d.ts +2 -0
  360. package/out/tools/region-slot-census.run.d.ts.map +1 -0
  361. package/out/tools/region-slot-census.run.js +134 -0
  362. package/out/tools/region-slot-census.run.js.map +1 -0
  363. package/out/training/config/load.d.ts.map +1 -1
  364. package/out/training/config/load.js +10 -0
  365. package/out/training/config/load.js.map +1 -1
  366. package/out/training/config/schema.d.ts +13 -0
  367. package/out/training/config/schema.d.ts.map +1 -1
  368. package/out/training/config/schema.js +6 -0
  369. package/out/training/config/schema.js.map +1 -1
  370. package/out/tw/registers.d.ts +9 -0
  371. package/out/tw/registers.d.ts.map +1 -1
  372. package/out/tw/registers.js +11 -4
  373. package/out/tw/registers.js.map +1 -1
  374. package/out/tw/structures/chunghwa-post.d.ts +39 -0
  375. package/out/tw/structures/chunghwa-post.d.ts.map +1 -0
  376. package/out/tw/structures/chunghwa-post.js +150 -0
  377. package/out/tw/structures/chunghwa-post.js.map +1 -0
  378. package/out/tw/tools/fetch/chunghwa-post.d.ts +55 -0
  379. package/out/tw/tools/fetch/chunghwa-post.d.ts.map +1 -0
  380. package/out/tw/tools/fetch/chunghwa-post.js +110 -0
  381. package/out/tw/tools/fetch/chunghwa-post.js.map +1 -0
  382. package/out/us/adapters/state/ny-notaries/adapter.d.ts.map +1 -1
  383. package/out/us/adapters/state/ny-notaries/adapter.js +7 -2
  384. package/out/us/adapters/state/ny-notaries/adapter.js.map +1 -1
  385. package/out/us/adapters/state/tx-notaries/adapter.d.ts +42 -0
  386. package/out/us/adapters/state/tx-notaries/adapter.d.ts.map +1 -1
  387. package/out/us/adapters/state/tx-notaries/adapter.js +92 -19
  388. package/out/us/adapters/state/tx-notaries/adapter.js.map +1 -1
  389. package/out/us/adapters/usgov/nad/adapter.d.ts +35 -2
  390. package/out/us/adapters/usgov/nad/adapter.d.ts.map +1 -1
  391. package/out/us/adapters/usgov/nad/adapter.js +90 -27
  392. package/out/us/adapters/usgov/nad/adapter.js.map +1 -1
  393. package/out/us/adapters/usgov/nppes/adapter.d.ts.map +1 -1
  394. package/out/us/adapters/usgov/nppes/adapter.js +8 -11
  395. package/out/us/adapters/usgov/nppes/adapter.js.map +1 -1
  396. package/out/us/adapters/usgov/usgs-structures/adapter.d.ts +87 -0
  397. package/out/us/adapters/usgov/usgs-structures/adapter.d.ts.map +1 -0
  398. package/out/us/adapters/usgov/{usgs-post-offices → usgs-structures}/adapter.js +36 -27
  399. package/out/us/adapters/usgov/usgs-structures/adapter.js.map +1 -0
  400. package/out/us/recipes/county.d.ts +124 -0
  401. package/out/us/recipes/county.d.ts.map +1 -0
  402. package/out/us/recipes/county.js +295 -0
  403. package/out/us/recipes/county.js.map +1 -0
  404. package/out/us/street-unit.d.ts +10 -3
  405. package/out/us/street-unit.d.ts.map +1 -1
  406. package/out/us/street-unit.js +14 -6
  407. package/out/us/street-unit.js.map +1 -1
  408. package/out/us/structures/usgs/layers.d.ts +57 -0
  409. package/out/us/structures/usgs/layers.d.ts.map +1 -0
  410. package/out/us/structures/usgs/layers.js +121 -0
  411. package/out/us/structures/usgs/layers.js.map +1 -0
  412. package/out/us/structures/usgs/national-map.d.ts +14 -0
  413. package/out/us/structures/usgs/national-map.d.ts.map +1 -0
  414. package/out/us/{post-offices/usgs-national-map.js → structures/usgs/national-map.js} +16 -14
  415. package/out/us/structures/usgs/national-map.js.map +1 -0
  416. package/out/us/tools/fetch/usgs/gnis.d.ts +118 -0
  417. package/out/us/tools/fetch/usgs/gnis.d.ts.map +1 -0
  418. package/out/us/tools/fetch/usgs/gnis.js +177 -0
  419. package/out/us/tools/fetch/usgs/gnis.js.map +1 -0
  420. package/out/us/tools/fetch/usgs/structures.d.ts +99 -0
  421. package/out/us/tools/fetch/usgs/structures.d.ts.map +1 -0
  422. package/out/us/tools/fetch/usgs/structures.js +233 -0
  423. package/out/us/tools/fetch/usgs/structures.js.map +1 -0
  424. package/out/utils/align.js.map +1 -1
  425. package/out/utils/evaluation-groups.d.ts +98 -0
  426. package/out/utils/evaluation-groups.d.ts.map +1 -0
  427. package/out/utils/evaluation-groups.js +92 -0
  428. package/out/utils/evaluation-groups.js.map +1 -0
  429. package/out/utils/split.d.ts +26 -1
  430. package/out/utils/split.d.ts.map +1 -1
  431. package/out/utils/split.js +28 -3
  432. package/out/utils/split.js.map +1 -1
  433. package/out/utils/tokenize.d.ts +3 -3
  434. package/out/utils/tokenize.d.ts.map +1 -1
  435. package/out/utils/tokenize.js.map +1 -1
  436. package/out/utils/validation-groups.d.ts +168 -0
  437. package/out/utils/validation-groups.d.ts.map +1 -0
  438. package/out/utils/validation-groups.js +135 -0
  439. package/out/utils/validation-groups.js.map +1 -0
  440. package/out/utils/wof-json.d.ts +31 -57
  441. package/out/utils/wof-json.d.ts.map +1 -1
  442. package/out/utils/wof-json.js +81 -98
  443. package/out/utils/wof-json.js.map +1 -1
  444. package/package.json +18 -18
  445. package/lib/adapters/wof/record-cache.ts +0 -118
  446. package/lib/build/heap.ts +0 -60
  447. package/lib/post-offices/sources.ts +0 -18
  448. package/lib/us/post-offices/usgs-national-map.ts +0 -89
  449. package/lib/us/tools/fetch/usgs-post-offices.ts +0 -362
  450. package/out/adapters/wof/record-cache.d.ts +0 -22
  451. package/out/adapters/wof/record-cache.d.ts.map +0 -1
  452. package/out/adapters/wof/record-cache.js +0 -89
  453. package/out/adapters/wof/record-cache.js.map +0 -1
  454. package/out/build/heap.d.ts +0 -26
  455. package/out/build/heap.d.ts.map +0 -1
  456. package/out/build/heap.js +0 -52
  457. package/out/build/heap.js.map +0 -1
  458. package/out/post-offices/source.d.ts.map +0 -1
  459. package/out/post-offices/source.js +0 -21
  460. package/out/post-offices/source.js.map +0 -1
  461. package/out/post-offices/sources.d.ts +0 -13
  462. package/out/post-offices/sources.d.ts.map +0 -1
  463. package/out/post-offices/sources.js +0 -8
  464. package/out/post-offices/sources.js.map +0 -1
  465. package/out/us/adapters/usgov/usgs-post-offices/adapter.d.ts +0 -66
  466. package/out/us/adapters/usgov/usgs-post-offices/adapter.d.ts.map +0 -1
  467. package/out/us/adapters/usgov/usgs-post-offices/adapter.js.map +0 -1
  468. package/out/us/post-offices/usgs-national-map.d.ts +0 -14
  469. package/out/us/post-offices/usgs-national-map.d.ts.map +0 -1
  470. package/out/us/post-offices/usgs-national-map.js.map +0 -1
  471. package/out/us/tools/fetch/usgs-post-offices.d.ts +0 -99
  472. package/out/us/tools/fetch/usgs-post-offices.d.ts.map +0 -1
  473. package/out/us/tools/fetch/usgs-post-offices.js +0 -246
  474. package/out/us/tools/fetch/usgs-post-offices.js.map +0 -1
@@ -0,0 +1,110 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ /**
4
+ * Fetches Chunghwa Post's list of its post offices (中華郵政全國營業據點, data.gov.tw dataset 5950),
5
+ * the source of Taiwan's post offices in the structures layer (`#tw/structures/chunghwa-post`).
6
+ *
7
+ * The dataset record at `https://data.gov.tw/api/v2/rest/dataset/5950` names the provider
8
+ * (提供機關 中華郵政股份有限公司), the license (政府資料開放授權條款-第1版, the Open Government Data License, Taiwan, v1.0)
9
+ * and the CSV distribution on `www.post.gov.tw`.
10
+ * The record is saved beside the CSV as `dataset.json`, because it holds the license
11
+ * and the update date the attribution cites.
12
+ *
13
+ * The CSV is downloaded to a staging file and moves into place only once it parses
14
+ * and holds the columns the adapter reads.
15
+ * A failed run leaves the previous file as it was.
16
+ *
17
+ * Invoke via `mailwoman corpus fetch tw-chunghwa-post-offices`.
18
+ */
19
+ import { APIClient } from "@mailwoman/core/api";
20
+ import { isSuccessStatus } from "@mailwoman/core/api/responses";
21
+ import { ByteFormatter } from "@mailwoman/core/fs/formatters";
22
+ import { statPath } from "@mailwoman/core/fs/readers/stat";
23
+ import { makeDirectories, movePath, removePathIfPresent, stagingSiblingPath, writeLocalJSONFile, } from "@mailwoman/core/fs/writers";
24
+ import { sha256File } from "@mailwoman/core/hash";
25
+ import { PathBuilder } from "path-ts";
26
+ import { readCSVRecords } from "#recipes/scaffold";
27
+ import { DEFAULT_RETRY_DELAY_MS, streamDownload, writeManifest } from "#tools/fetch/download";
28
+ import { TW_CHUNGHWA_POST_COLUMNS, TW_CHUNGHWA_POST_FILENAME, TW_CHUNGHWA_POST_SOURCE_ID, } from "#tw/structures/chunghwa-post";
29
+ /**
30
+ * The dataset record on data.gov.tw.
31
+ */
32
+ export const TW_CHUNGHWA_POST_DATASET_URL = "https://data.gov.tw/api/v2/rest/dataset/5950";
33
+ /**
34
+ * The CSV distribution the dataset record names.
35
+ */
36
+ export const TW_CHUNGHWA_POST_CSV_URL = "https://www.post.gov.tw/post/internet/Templates/getOpenDataFile.jsp?vkey=B484EB27-B3F0-4D02-8F62-047D20C64078";
37
+ /**
38
+ * The file the dataset record is saved to, beside the CSV.
39
+ */
40
+ export const TW_CHUNGHWA_POST_DATASET_FILENAME = "dataset.json";
41
+ const SLUG = TW_CHUNGHWA_POST_SOURCE_ID;
42
+ /**
43
+ * Downloads the CSV into `<outputDir>/post-offices.csv` and writes the dataset record and the manifest.
44
+ *
45
+ * @throws When the CSV answers an error status, or lacks a column the adapter reads.
46
+ */
47
+ export async function downloadTWChunghwaPost(client, options) {
48
+ const { report } = options;
49
+ const destDir = PathBuilder.from(options.outputDir);
50
+ const csvPath = destDir(TW_CHUNGHWA_POST_FILENAME);
51
+ report?.(`=== ${SLUG} / ${TW_CHUNGHWA_POST_FILENAME}`);
52
+ const { data: dataset } = await client.fetch({ url: TW_CHUNGHWA_POST_DATASET_URL });
53
+ const result = dataset?.result ?? {};
54
+ report?.(` ${result.title ?? "untitled"}; modified ${result.modifiedDate ?? "unstated"}`);
55
+ await makeDirectories(destDir);
56
+ const staging = stagingSiblingPath(csvPath);
57
+ let records = 0;
58
+ try {
59
+ const status = await streamDownload(TW_CHUNGHWA_POST_CSV_URL, staging, {
60
+ timeoutMs: 300_000,
61
+ retries: 3,
62
+ retryDelayMs: options.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS,
63
+ });
64
+ if (!isSuccessStatus(status))
65
+ throw new Error(`${SLUG}: ${TW_CHUNGHWA_POST_CSV_URL} answered HTTP ${status}`);
66
+ for await (const record of readCSVRecords(staging)) {
67
+ if (records === 0) {
68
+ const missing = TW_CHUNGHWA_POST_COLUMNS.filter((column) => !(column in record));
69
+ if (missing.length)
70
+ throw new Error(`${SLUG}: the CSV has no column ${missing.join(", ")}`);
71
+ }
72
+ records++;
73
+ }
74
+ if (!records)
75
+ throw new Error(`${SLUG}: the CSV holds no row`);
76
+ await movePath(staging, csvPath);
77
+ }
78
+ finally {
79
+ await removePathIfPresent(staging);
80
+ }
81
+ await writeLocalJSONFile((dataset ?? {}), destDir(TW_CHUNGHWA_POST_DATASET_FILENAME));
82
+ const sha256 = await sha256File(csvPath);
83
+ const { size: bytes } = await statPath(csvPath);
84
+ const manifest = {
85
+ source_url: TW_CHUNGHWA_POST_CSV_URL,
86
+ dataset_url: TW_CHUNGHWA_POST_DATASET_URL,
87
+ filename: TW_CHUNGHWA_POST_FILENAME,
88
+ records,
89
+ bytes,
90
+ sha256,
91
+ ...(result.modifiedDate ? { publisher_version: result.modifiedDate } : {}),
92
+ downloaded_at: new Date().toISOString(),
93
+ };
94
+ await writeManifest(destDir("MANIFEST.json"), manifest);
95
+ report?.(` ✓ ${records.toLocaleString()} rows, ${ByteFormatter.formatIEC(bytes)} sha256=${sha256}`);
96
+ return { fetched: 1, skipped: 0, failed: 0, failedCodes: [] };
97
+ }
98
+ /**
99
+ * The registry entry.
100
+ */
101
+ export async function fetchTWChunghwaPost(options, report) {
102
+ await using client = new APIClient({ displayName: SLUG, retry: true });
103
+ // Awaited rather than returned: `await using` disposes the client when this scope exits.
104
+ return await downloadTWChunghwaPost(client, {
105
+ outputDir: options.outRoot(SLUG),
106
+ retryDelayMs: options.retryDelayMs,
107
+ report,
108
+ });
109
+ }
110
+ //# sourceMappingURL=chunghwa-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunghwa-post.js","sourceRoot":"","sources":["../../../../lib/tw/tools/fetch/chunghwa-post.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,aAAa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AAO,CAAC,IAAI,CAAC;QAChC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,MAAM;KACN,CAAC,CAAA;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../lib/us/adapters/state/ny-notaries/adapter.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAuD,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AAI/G;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,sBAAsB,CAAA;AAC/D;;;GAGG;AACH,eAAO,MAAM,iCAAiC,kBAAkB,CAAA;AAEhE,wBAAgB,4BAA4B,IAAI,aAAa,CAwF5D;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,eAAiC,CAAA"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../lib/us/adapters/state/ny-notaries/adapter.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAuD,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AAI/G;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,sBAAsB,CAAA;AAC/D;;;GAGG;AACH,eAAO,MAAM,iCAAiC,kBAAkB,CAAA;AAEhE,wBAAgB,4BAA4B,IAAI,aAAa,CA6F5D;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,eAAiC,CAAA"}
@@ -20,7 +20,7 @@ import { SourceRegister } from "#registers";
20
20
  import { streetIndexOpener } from "#street-index/reader";
21
21
  import { AddressRole, SurfaceOrigin } from "#types";
22
22
  import { lookupStateAbbreviation } from "#us/fips-state";
23
- import { splitUSStreetLine } from "#us/street-unit";
23
+ import { splitUSStreetLine, usPOBoxLine } from "#us/street-unit";
24
24
  /**
25
25
  * Registry id for this adapter.
26
26
  *
@@ -69,8 +69,13 @@ export function createStateNyNotariesAdapter() {
69
69
  const state = lookupStateAbbreviation(stateAbbr);
70
70
  if (!state)
71
71
  continue;
72
+ // A business line followed by a box line (`ONE PLEASANT AVE`, `POB 1424`)
73
+ // is delivered to the box, the line above the city.
74
+ // When either line is a whole-line box, the row keeps that line as its `po_box`
75
+ // and leaves the other line out.
76
+ const boxLine = usPOBoxLine(address2) ?? usPOBoxLine(address1);
72
77
  const fullAddress = [address1, address2].filter(isPresent).join(" ");
73
- const line = splitUSStreetLine(fullAddress, units);
78
+ const line = boxLine ?? splitUSStreetLine(fullAddress, units);
74
79
  if (!line)
75
80
  continue;
76
81
  const venue = businessName || holderName || undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../../lib/us/adapters/state/ny-notaries/adapter.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,WAAW,EAA8D,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC/G,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAAA;AAC/D;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,eAAe,CAAA;AAEhE,MAAM,UAAU,4BAA4B;IAC3C,OAAO;QACN,EAAE,EAAE,4BAA4B;QAChC,cAAc,EAAE,iCAAiC;QACjD,WAAW,EAAE,WAAW,CAAC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"#types";
2
+ import { type USStateInfo } from "#us/fips-state";
2
3
  /**
3
4
  * Registry id for this adapter.
4
5
  *
@@ -10,6 +11,47 @@ export declare const STATE_TX_NOTARIES_ADAPTER_ID = "state-tx-notaries";
10
11
  * consumers inherit the terms rather than having to look them up.
11
12
  */
12
13
  export declare const STATE_TX_NOTARIES_DEFAULT_LICENSE = "Public Domain";
14
+ /**
15
+ * An address field split into the street text before its city, the city,
16
+ * its state abbreviation and its ZIP Code.
17
+ */
18
+ export interface TxNotaryAddress {
19
+ street: string;
20
+ city: string;
21
+ state: USStateInfo;
22
+ zip: string;
23
+ }
24
+ /**
25
+ * Splits a registry `Address` field, such as `"1215 mcmillan DR\nCEDAR hill, TX 75104"`,
26
+ * at its trailing city, state and ZIP Code, or returns `null` when the state isn't
27
+ * a US one or no comma-separated city precedes it.
28
+ *
29
+ * The registry appends its own `, ST ZIP` to the city a notary typed, and that city
30
+ * sometimes already ends in the state, a country or the ZIP Code: `Houston, TX, TX 77043`,
31
+ * `San Antonio TX, TX 78245`, `Godley, Texas 76044, TX 76044`, `Houston TX 77006, US, TX 77006`.
32
+ * Those repetitions are removed before the city is read, so the city is `Houston`
33
+ * and the state isn't taken for the city.
34
+ */
35
+ export declare function parseTxNotaryAddress(rawAddress: string): TxNotaryAddress | null;
36
+ /**
37
+ * A notary's street text as its first line and the unit lines typed after it.
38
+ */
39
+ export interface TxNotaryStreetLines {
40
+ line: string;
41
+ units: string[];
42
+ }
43
+ /**
44
+ * Splits the street text {@linkcode parseTxNotaryAddress} returns into its first line
45
+ * and the unit lines typed after it, in their written order.
46
+ *
47
+ * Notaries type a suite or department as its own line (`555 N. Carancahua, Suite 620`),
48
+ * and some type the street line twice (`231 Blanco Dr, 231 Blanco Dr`).
49
+ * A trailing comma-separated segment that {@linkcode unitLine} reads as a unit joins `units`,
50
+ * and one that repeats the first line, with or without its house number, is removed.
51
+ *
52
+ * The split stops at the first trailing segment that's neither, so the street keeps every segment before it.
53
+ */
54
+ export declare function splitTxNotaryStreetLines(street: string): TxNotaryStreetLines;
13
55
  export declare function createStateTxNotariesAdapter(): CorpusAdapter;
14
56
  /**
15
57
  * The configured adapter instance registered with the corpus builder.
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../lib/us/adapters/state/tx-notaries/adapter.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAuD,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AAI/G;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,sBAAsB,CAAA;AAC/D;;;GAGG;AACH,eAAO,MAAM,iCAAiC,kBAAkB,CAAA;AAchE,wBAAgB,4BAA4B,IAAI,aAAa,CAkG5D;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,eAAiC,CAAA"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../lib/us/adapters/state/tx-notaries/adapter.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAuD,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AAC/G,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAG1E;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,sBAAsB,CAAA;AAC/D;;;GAGG;AACH,eAAO,MAAM,iCAAiC,kBAAkB,CAAA;AAOhE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,WAAW,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;CACX;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CA4B/E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,EAAE,CAAA;CACf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAyB5E;AAkBD,wBAAgB,4BAA4B,IAAI,aAAa,CA8F5D;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,eAAiC,CAAA"}
@@ -14,15 +14,17 @@
14
14
  * License: stamped `"Public Domain"` per Texas state government open-data terms.
15
15
  */
16
16
  import { formatAddressRow } from "@mailwoman/codex/address/format";
17
+ import { isPresent } from "@mailwoman/core/objects";
17
18
  import { formatPersonName } from "@mailwoman/record/name";
18
19
  import { CSVSpliterator } from "spliterator";
19
20
  import { stableSourceID } from "#adapters/source-id";
21
+ import { splitStreetLine } from "#adapters/street/line";
20
22
  import { createUnitSplitter } from "#adapters/street/unit";
21
23
  import { SourceRegister } from "#registers";
22
24
  import { streetIndexOpener } from "#street-index/reader";
23
25
  import { AddressRole, SurfaceOrigin } from "#types";
24
26
  import { lookupStateAbbreviation } from "#us/fips-state";
25
- import { splitUSStreetLine } from "#us/street-unit";
27
+ import { splitUSStreetLine, unitLine } from "#us/street-unit";
26
28
  /**
27
29
  * Registry id for this adapter.
28
30
  *
@@ -35,9 +37,83 @@ export const STATE_TX_NOTARIES_ADAPTER_ID = "state-tx-notaries";
35
37
  */
36
38
  export const STATE_TX_NOTARIES_DEFAULT_LICENSE = "Public Domain";
37
39
  /**
38
- * Match trailing "city, ST ZIP" or "city, ST" at the end of an address line.
40
+ * The trailing `, ST ZIP` or `, ST` the registry writes after the city.
39
41
  */
40
- const CITY_STATE_ZIP_SUFFIX = /[,]?\s*([^,]+),\s*([A-Z]{2})\s*(\d{5}(?:-\d{4})?)?\s*$/i;
42
+ const STATE_ZIP_SUFFIX = /,\s*([A-Z]{2})\s*(\d{5}(?:-\d{4})?)?\s*$/i;
43
+ /**
44
+ * Splits a registry `Address` field, such as `"1215 mcmillan DR\nCEDAR hill, TX 75104"`,
45
+ * at its trailing city, state and ZIP Code, or returns `null` when the state isn't
46
+ * a US one or no comma-separated city precedes it.
47
+ *
48
+ * The registry appends its own `, ST ZIP` to the city a notary typed, and that city
49
+ * sometimes already ends in the state, a country or the ZIP Code: `Houston, TX, TX 77043`,
50
+ * `San Antonio TX, TX 78245`, `Godley, Texas 76044, TX 76044`, `Houston TX 77006, US, TX 77006`.
51
+ * Those repetitions are removed before the city is read, so the city is `Houston`
52
+ * and the state isn't taken for the city.
53
+ */
54
+ export function parseTxNotaryAddress(rawAddress) {
55
+ const line = rawAddress.replaceAll("\n", ", ");
56
+ const suffix = STATE_ZIP_SUFFIX.exec(line);
57
+ const state = lookupStateAbbreviation(suffix?.[1] ?? null);
58
+ if (!suffix || !state)
59
+ return null;
60
+ const zip = suffix[2] ?? "";
61
+ const repetitions = [
62
+ `[\\s,]+(?:${state.abbreviation}\\.?|${state.name})`,
63
+ ",\\s*USA?",
64
+ ...(zip ? [`[\\s,]+${zip}`] : []),
65
+ ];
66
+ const repeated = new RegExp(`(?:${repetitions.join("|")})\\s*$`, "iu");
67
+ let head = line.slice(0, suffix.index);
68
+ for (let match = repeated.exec(head); match; match = repeated.exec(head)) {
69
+ head = head.slice(0, match.index);
70
+ }
71
+ const comma = head.lastIndexOf(",");
72
+ if (comma === -1)
73
+ return null;
74
+ return { street: head.slice(0, comma).replace(/,\s*$/u, "").trim(), city: head.slice(comma + 1).trim(), state, zip };
75
+ }
76
+ /**
77
+ * Splits the street text {@linkcode parseTxNotaryAddress} returns into its first line
78
+ * and the unit lines typed after it, in their written order.
79
+ *
80
+ * Notaries type a suite or department as its own line (`555 N. Carancahua, Suite 620`),
81
+ * and some type the street line twice (`231 Blanco Dr, 231 Blanco Dr`).
82
+ * A trailing comma-separated segment that {@linkcode unitLine} reads as a unit joins `units`,
83
+ * and one that repeats the first line, with or without its house number, is removed.
84
+ *
85
+ * The split stops at the first trailing segment that's neither, so the street keeps every segment before it.
86
+ */
87
+ export function splitTxNotaryStreetLines(street) {
88
+ // The unit splitter collapses a line's inner whitespace when it splits one, so a peeled line does too.
89
+ const collapse = (text) => text.trim().replaceAll(/\s+/gu, " ");
90
+ const comparable = (text) => collapse(text).toLowerCase();
91
+ const first = street.split(",")[0] ?? "";
92
+ const repeats = new Set([first, splitStreetLine(first)?.street ?? first].map(comparable));
93
+ const units = [];
94
+ let line = street;
95
+ for (let comma = line.lastIndexOf(","); comma > 0; comma = line.lastIndexOf(",")) {
96
+ const last = line.slice(comma + 1);
97
+ const unit = unitLine(last);
98
+ if (unit) {
99
+ units.unshift(unit);
100
+ }
101
+ else if (last.trim() && !repeats.has(comparable(last))) {
102
+ break;
103
+ }
104
+ line = line.slice(0, comma).trimEnd();
105
+ }
106
+ if (line === street)
107
+ return { line, units };
108
+ return { line: collapse(line), units: units.map(collapse) };
109
+ }
110
+ /**
111
+ * The `unit` component for a street line's own trailing unit followed by the unit lines typed after it.
112
+ */
113
+ function withUnitLines(trailing, typed) {
114
+ const unit = [trailing, ...typed].filter(isPresent).join(" ");
115
+ return unit ? { unit } : {};
116
+ }
41
117
  export function createStateTxNotariesAdapter() {
42
118
  return {
43
119
  id: STATE_TX_NOTARIES_ADAPTER_ID,
@@ -66,25 +142,22 @@ export function createStateTxNotariesAdapter() {
66
142
  const firstName = record["First Name"] ?? "";
67
143
  const lastName = record["Last Name"] ?? "";
68
144
  const notaryID = record["Notary ID"] ?? "";
69
- // Parse embedded city/state/zip from the trailing portion of the address.
70
- // Addresses look like: "1215 mcmillan DR\nCEDAR hill, TX 75104"
71
- const addrSingleLine = rawAddress.replaceAll("\n", ", ");
72
- const cszMatch = CITY_STATE_ZIP_SUFFIX.exec(addrSingleLine);
73
- if (!cszMatch)
145
+ const address = parseTxNotaryAddress(rawAddress);
146
+ if (!address?.city)
74
147
  continue;
75
- const city = (cszMatch[1] ?? "").trim();
76
- const stateAbbr = (cszMatch[2] ?? "").trim();
77
- const zip = (cszMatch[3] ?? "").trim();
78
- if (!city || !stateAbbr)
79
- continue;
80
- const state = lookupStateAbbreviation(stateAbbr);
81
- if (!state)
82
- continue;
83
- // Extract the street portion (everything before the city/state/zip)
84
- const streetPortion = addrSingleLine.slice(0, cszMatch.index).replace(/,\s*$/, "").trim();
148
+ const { city, state, zip, street: streetPortion } = address;
85
149
  if (!streetPortion)
86
150
  continue;
87
- const line = splitUSStreetLine(streetPortion, units);
151
+ const typed = splitTxNotaryStreetLines(streetPortion);
152
+ const split = splitUSStreetLine(typed.line, units);
153
+ if (!split)
154
+ continue;
155
+ // A PO box row emits no unit, so a box followed by a unit line keeps its whole street text.
156
+ const line = !("po_box" in split)
157
+ ? { ...split, ...withUnitLines(split.unit, typed.units) }
158
+ : typed.units.length
159
+ ? splitUSStreetLine(streetPortion, units)
160
+ : split;
88
161
  if (!line)
89
162
  continue;
90
163
  const venue = formatPersonName({ given: firstName, family: lastName }, "short") || undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../../lib/us/adapters/state/tx-notaries/adapter.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,WAAW,EAA8D,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC/G,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAAA;AAC/D;;;GAGG;AACH,MAAM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,sBAAsB,GAAG,4BAA4B,EAAE,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { PathBuilderLike } from "path-ts";
2
- import { type CorpusAdapter } from "#types";
2
+ import { type CanonicalRow, type CorpusAdapter } from "#types";
3
3
  /**
4
4
  * The adapter stamps this id on every emitted row.
5
5
  */
@@ -74,7 +74,16 @@ export declare const NAD_RECORD_COLUMNS: readonly ["OID_", "UUID", "AddNum_Pre",
74
74
  */
75
75
  export declare function normalizeNADUUID(value: string | null | undefined): string | null;
76
76
  /**
77
- * Streams the NAD records of one release Parquet file in file order, with each UUID normalized.
77
+ * A NAD record with each text column that holds a {@link NAD_PLACEHOLDER_TEXT}
78
+ * spelling read as absent, and its UUID normalized.
79
+ *
80
+ * `Placement` is left as published, because there `Unknown` is a value of the
81
+ * column's own domain that names how the point was placed.
82
+ */
83
+ export declare function normalizeNADRecord(record: NADRecord): NADRecord;
84
+ /**
85
+ * Streams the NAD records of one release Parquet file in file order,
86
+ * each passed through {@linkcode normalizeNADRecord}.
78
87
  *
79
88
  * @param where A DuckDB condition rows must satisfy, built with `escapeSQLString` for every literal.
80
89
  * @throws When the file lacks a column of {@link NAD_RECORD_COLUMNS}.
@@ -88,6 +97,13 @@ export declare function readNADRecords(parquetPath: PathBuilderLike, options?: {
88
97
  *
89
98
  * A publisher may write one designator into several columns, as New York writes `Apartment 2`
90
99
  * into both `Building` and `Unit`, so a part that repeats an earlier one is kept once.
100
+ *
101
+ * A publisher may also copy the landmark or the street into a unit column, as Oklahoma writes
102
+ * `RM ENERGY` as both `LandmkName` and `Unit`, and `DAUBE RANCH` as both `St_Name` and `Unit`.
103
+ * Such a part isn't a unit designator, so it's left out.
104
+ *
105
+ * A part holding a digit or a single character is kept even when it equals the street's name,
106
+ * because `A` on `Avenue A` and `17` on `Highway 17` read as unit designators too.
91
107
  */
92
108
  export declare function nadUnitText(record: NADRecord): string | null;
93
109
  /**
@@ -133,6 +149,23 @@ export declare function composeNADLocality(r: NADRecord): string | null;
133
149
  * A NAD place-name column's value trimmed, or `null` when it is empty or a placeholder such as `Not stated`.
134
150
  */
135
151
  export declare function statedNADPlaceName(value: string | null | undefined): string | null;
152
+ /**
153
+ * The address components the adapter renders for one NAD record, or `null`
154
+ * when the record lacks a US state code, a locality or a ZIP Code.
155
+ */
156
+ export declare function nadAddressComponents(record: NADRecord): CanonicalRow["components"] | null;
157
+ /**
158
+ * The rendered components with a locality that writes the record's own county moved to `subregion`.
159
+ *
160
+ * NAD contributors fill a place column with the county for an address outside any
161
+ * municipality: Oregon's `Inc_Muni` reads `Polk County` where `County` reads `Polk`,
162
+ * and Texas's `Post_City` reads `DENTON COUNTY`.
163
+ * The row's text keeps the county where the locality would be, as
164
+ * `1 1st Street, Polk County, OR 97347`, and the span is labeled the county it is.
165
+ *
166
+ * A place that shares its county's name without a designator (`Denton` in Denton County) stays a locality.
167
+ */
168
+ export declare function nadCountyAsSubregion(components: CanonicalRow["components"], record: Pick<NADRecord, "County">): CanonicalRow["components"];
136
169
  /**
137
170
  * Creates the NAD adapter.
138
171
  *
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../lib/us/adapters/usgov/nad/adapter.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAK9C,OAAO,EAAuD,KAAK,aAAa,EAAiB,MAAM,QAAQ,CAAA;AAE/G;;GAEG;AACH,eAAO,MAAM,oBAAoB,cAAc,CAAA;AAC/C;;GAEG;AACH,eAAO,MAAM,yBAAyB,kBAAkB,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,oBAAoB,QAAiC,CAAA;AAElE;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,UAAU,CAAC,E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