@mailwoman/registry 10.7.0 → 11.0.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 (399) hide show
  1. package/README.md +93 -98
  2. package/data/manifests/artifacts.json +32 -0
  3. package/data/manifests/coverage.json +56 -0
  4. package/data/manifests/sources.lock.json +48 -0
  5. package/data/normalized/iata-airports.json +126749 -0
  6. package/data/normalized/iso3166-1.json +2035 -0
  7. package/definitions/namespaces.json +63 -0
  8. package/definitions/sections.json +73 -0
  9. package/docs/data-policy.md +81 -0
  10. package/docs/performance.md +146 -0
  11. package/docs/rgy1.md +144 -0
  12. package/lib/artifacts/country-airport-collision.ts +26 -0
  13. package/lib/artifacts/iata-airport/membership.ts +26 -0
  14. package/lib/artifacts/iata-airport/records.ts +26 -0
  15. package/lib/artifacts/iso3166-1/alpha2-membership.ts +26 -0
  16. package/lib/artifacts/iso3166-1/alpha3-membership.ts +26 -0
  17. package/lib/artifacts/iso3166-1/records.ts +26 -0
  18. package/lib/errors.ts +44 -0
  19. package/lib/iata/airports/records.ts +174 -0
  20. package/lib/iata/airports/validate.ts +49 -0
  21. package/lib/index.ts +25 -15
  22. package/lib/inspect.ts +56 -0
  23. package/lib/iso3166/alpha2.ts +48 -0
  24. package/lib/iso3166/alpha3.ts +51 -0
  25. package/lib/iso3166/records.ts +149 -0
  26. package/lib/iso3166/relations.ts +30 -0
  27. package/lib/key.ts +146 -0
  28. package/lib/normalize.ts +31 -0
  29. package/lib/overlap/country-airport.ts +108 -0
  30. package/lib/rgy1/base64.ts +24 -0
  31. package/lib/rgy1/reader.ts +316 -0
  32. package/lib/rgy1/sections.generated.ts +79 -0
  33. package/lib/rgy1/views.ts +267 -0
  34. package/lib/types.ts +88 -74
  35. package/lib/wasm.ts +285 -0
  36. package/out/artifacts/country-airport-collision.d.ts +15 -0
  37. package/out/artifacts/country-airport-collision.d.ts.map +1 -0
  38. package/out/artifacts/country-airport-collision.js +21 -0
  39. package/out/artifacts/country-airport-collision.js.map +1 -0
  40. package/out/artifacts/iata-airport/membership.d.ts +15 -0
  41. package/out/artifacts/iata-airport/membership.d.ts.map +1 -0
  42. package/out/artifacts/iata-airport/membership.js +21 -0
  43. package/out/artifacts/iata-airport/membership.js.map +1 -0
  44. package/out/artifacts/iata-airport/records.d.ts +15 -0
  45. package/out/artifacts/iata-airport/records.d.ts.map +1 -0
  46. package/out/artifacts/iata-airport/records.js +21 -0
  47. package/out/artifacts/iata-airport/records.js.map +1 -0
  48. package/out/artifacts/iso3166-1/alpha2-membership.d.ts +15 -0
  49. package/out/artifacts/iso3166-1/alpha2-membership.d.ts.map +1 -0
  50. package/out/artifacts/iso3166-1/alpha2-membership.js +21 -0
  51. package/out/artifacts/iso3166-1/alpha2-membership.js.map +1 -0
  52. package/out/artifacts/iso3166-1/alpha3-membership.d.ts +15 -0
  53. package/out/artifacts/iso3166-1/alpha3-membership.d.ts.map +1 -0
  54. package/out/artifacts/iso3166-1/alpha3-membership.js +21 -0
  55. package/out/artifacts/iso3166-1/alpha3-membership.js.map +1 -0
  56. package/out/artifacts/iso3166-1/records.d.ts +15 -0
  57. package/out/artifacts/iso3166-1/records.d.ts.map +1 -0
  58. package/out/artifacts/iso3166-1/records.js +21 -0
  59. package/out/artifacts/iso3166-1/records.js.map +1 -0
  60. package/out/errors.d.ts +38 -0
  61. package/out/errors.d.ts.map +1 -0
  62. package/out/errors.js +35 -0
  63. package/out/errors.js.map +1 -0
  64. package/out/iata/airports/records.d.ts +44 -0
  65. package/out/iata/airports/records.d.ts.map +1 -0
  66. package/out/iata/airports/records.js +137 -0
  67. package/out/iata/airports/records.js.map +1 -0
  68. package/out/iata/airports/validate.d.ts +27 -0
  69. package/out/iata/airports/validate.d.ts.map +1 -0
  70. package/out/iata/airports/validate.js +42 -0
  71. package/out/iata/airports/validate.js.map +1 -0
  72. package/out/index.d.ts +19 -15
  73. package/out/index.d.ts.map +1 -1
  74. package/out/index.js +14 -15
  75. package/out/index.js.map +1 -1
  76. package/out/inspect.d.ts +38 -0
  77. package/out/inspect.d.ts.map +1 -0
  78. package/out/inspect.js +33 -0
  79. package/out/inspect.js.map +1 -0
  80. package/out/iso3166/alpha2.d.ts +24 -0
  81. package/out/iso3166/alpha2.d.ts.map +1 -0
  82. package/out/iso3166/alpha2.js +41 -0
  83. package/out/iso3166/alpha2.js.map +1 -0
  84. package/out/iso3166/alpha3.d.ts +29 -0
  85. package/out/iso3166/alpha3.d.ts.map +1 -0
  86. package/out/iso3166/alpha3.js +44 -0
  87. package/out/iso3166/alpha3.js.map +1 -0
  88. package/out/iso3166/records.d.ts +38 -0
  89. package/out/iso3166/records.d.ts.map +1 -0
  90. package/out/iso3166/records.js +105 -0
  91. package/out/iso3166/records.js.map +1 -0
  92. package/out/iso3166/relations.d.ts +20 -0
  93. package/out/iso3166/relations.d.ts.map +1 -0
  94. package/out/iso3166/relations.js +27 -0
  95. package/out/iso3166/relations.js.map +1 -0
  96. package/out/key.d.ts +68 -0
  97. package/out/key.d.ts.map +1 -0
  98. package/out/key.js +122 -0
  99. package/out/key.js.map +1 -0
  100. package/out/normalize.d.ts +25 -0
  101. package/out/normalize.d.ts.map +1 -0
  102. package/out/normalize.js +21 -0
  103. package/out/normalize.js.map +1 -0
  104. package/out/overlap/country-airport.d.ts +57 -0
  105. package/out/overlap/country-airport.d.ts.map +1 -0
  106. package/out/overlap/country-airport.js +71 -0
  107. package/out/overlap/country-airport.js.map +1 -0
  108. package/out/rgy1/base64.d.ts +15 -0
  109. package/out/rgy1/base64.d.ts.map +1 -0
  110. package/out/rgy1/base64.js +22 -0
  111. package/out/rgy1/base64.js.map +1 -0
  112. package/out/rgy1/reader.d.ts +103 -0
  113. package/out/rgy1/reader.d.ts.map +1 -0
  114. package/out/rgy1/reader.js +230 -0
  115. package/out/rgy1/reader.js.map +1 -0
  116. package/out/rgy1/sections.generated.d.ts +54 -0
  117. package/out/rgy1/sections.generated.d.ts.map +1 -0
  118. package/out/rgy1/sections.generated.js +69 -0
  119. package/out/rgy1/sections.generated.js.map +1 -0
  120. package/out/rgy1/views.d.ts +96 -0
  121. package/out/rgy1/views.d.ts.map +1 -0
  122. package/out/rgy1/views.js +218 -0
  123. package/out/rgy1/views.js.map +1 -0
  124. package/out/sdk/fetch.d.ts +53 -0
  125. package/out/sdk/fetch.d.ts.map +1 -0
  126. package/out/sdk/fetch.js +107 -0
  127. package/out/sdk/fetch.js.map +1 -0
  128. package/out/sdk/fetch.run.d.ts +14 -0
  129. package/out/sdk/fetch.run.d.ts.map +1 -0
  130. package/out/sdk/fetch.run.js +20 -0
  131. package/out/sdk/fetch.run.js.map +1 -0
  132. package/out/sdk/sources.d.ts +111 -0
  133. package/out/sdk/sources.d.ts.map +1 -0
  134. package/out/sdk/sources.js +98 -0
  135. package/out/sdk/sources.js.map +1 -0
  136. package/out/tools/artifact-path.d.ts +10 -0
  137. package/out/tools/artifact-path.d.ts.map +1 -0
  138. package/out/tools/artifact-path.js +12 -0
  139. package/out/tools/artifact-path.js.map +1 -0
  140. package/out/tools/bench.run.d.ts +19 -0
  141. package/out/tools/bench.run.d.ts.map +1 -0
  142. package/out/tools/bench.run.js +204 -0
  143. package/out/tools/bench.run.js.map +1 -0
  144. package/out/tools/build-wasm.run.d.ts +18 -0
  145. package/out/tools/build-wasm.run.d.ts.map +1 -0
  146. package/out/tools/build-wasm.run.js +71 -0
  147. package/out/tools/build-wasm.run.js.map +1 -0
  148. package/out/tools/generate-sections.run.d.ts +13 -0
  149. package/out/tools/generate-sections.run.d.ts.map +1 -0
  150. package/out/tools/generate-sections.run.js +136 -0
  151. package/out/tools/generate-sections.run.js.map +1 -0
  152. package/out/tools/generate.run.d.ts +18 -0
  153. package/out/tools/generate.run.d.ts.map +1 -0
  154. package/out/tools/generate.run.js +118 -0
  155. package/out/tools/generate.run.js.map +1 -0
  156. package/out/tools/normalize.d.ts +155 -0
  157. package/out/tools/normalize.d.ts.map +1 -0
  158. package/out/tools/normalize.js +303 -0
  159. package/out/tools/normalize.js.map +1 -0
  160. package/out/tools/normalize.run.d.ts +14 -0
  161. package/out/tools/normalize.run.d.ts.map +1 -0
  162. package/out/tools/normalize.run.js +29 -0
  163. package/out/tools/normalize.run.js.map +1 -0
  164. package/out/types.d.ts +90 -76
  165. package/out/types.d.ts.map +1 -1
  166. package/out/types.js +20 -4
  167. package/out/types.js.map +1 -1
  168. package/out/wasm.d.ts +98 -0
  169. package/out/wasm.d.ts.map +1 -0
  170. package/out/wasm.js +137 -0
  171. package/out/wasm.js.map +1 -0
  172. package/package.json +49 -28
  173. package/sdk/fetch.run.ts +24 -0
  174. package/sdk/fetch.ts +146 -0
  175. package/sdk/sources.ts +162 -0
  176. package/tools/artifact-path.ts +12 -0
  177. package/tools/bench.run.ts +265 -0
  178. package/tools/build-wasm.run.ts +82 -0
  179. package/tools/generate-sections.run.ts +152 -0
  180. package/tools/generate.run.ts +146 -0
  181. package/tools/normalize.run.ts +36 -0
  182. package/tools/normalize.ts +474 -0
  183. package/wasm/registry-simd.wasm +0 -0
  184. package/wasm/registry.wasm +0 -0
  185. package/lib/address-key.ts +0 -46
  186. package/lib/geocode-handler.ts +0 -37
  187. package/lib/geojson.ts +0 -73
  188. package/lib/ingest.ts +0 -349
  189. package/lib/learned-scorer.ts +0 -134
  190. package/lib/map-html.ts +0 -287
  191. package/lib/models/crosssource-gbt-en-us.ts +0 -43
  192. package/lib/models/dedup-gbt-en-us.ts +0 -47
  193. package/lib/models/org-crosssource-gbt-en-us.ts +0 -43
  194. package/lib/reconcile.ts +0 -239
  195. package/lib/resolve.ts +0 -570
  196. package/out/address-key.d.ts +0 -34
  197. package/out/address-key.d.ts.map +0 -1
  198. package/out/address-key.js +0 -41
  199. package/out/address-key.js.map +0 -1
  200. package/out/geocode-handler.d.ts +0 -20
  201. package/out/geocode-handler.d.ts.map +0 -1
  202. package/out/geocode-handler.js +0 -29
  203. package/out/geocode-handler.js.map +0 -1
  204. package/out/geojson.d.ts +0 -28
  205. package/out/geojson.d.ts.map +0 -1
  206. package/out/geojson.js +0 -63
  207. package/out/geojson.js.map +0 -1
  208. package/out/ingest.d.ts +0 -173
  209. package/out/ingest.d.ts.map +0 -1
  210. package/out/ingest.js +0 -185
  211. package/out/ingest.js.map +0 -1
  212. package/out/learned-scorer.d.ts +0 -61
  213. package/out/learned-scorer.d.ts.map +0 -1
  214. package/out/learned-scorer.js +0 -91
  215. package/out/learned-scorer.js.map +0 -1
  216. package/out/map-html.d.ts +0 -39
  217. package/out/map-html.d.ts.map +0 -1
  218. package/out/map-html.js +0 -220
  219. package/out/map-html.js.map +0 -1
  220. package/out/models/crosssource-gbt-en-us.d.ts +0 -45
  221. package/out/models/crosssource-gbt-en-us.d.ts.map +0 -1
  222. package/out/models/crosssource-gbt-en-us.js +0 -40
  223. package/out/models/crosssource-gbt-en-us.js.map +0 -1
  224. package/out/models/dedup-gbt-en-us.d.ts +0 -44
  225. package/out/models/dedup-gbt-en-us.d.ts.map +0 -1
  226. package/out/models/dedup-gbt-en-us.js +0 -44
  227. package/out/models/dedup-gbt-en-us.js.map +0 -1
  228. package/out/models/org-crosssource-gbt-en-us.d.ts +0 -45
  229. package/out/models/org-crosssource-gbt-en-us.d.ts.map +0 -1
  230. package/out/models/org-crosssource-gbt-en-us.js +0 -40
  231. package/out/models/org-crosssource-gbt-en-us.js.map +0 -1
  232. package/out/reconcile.d.ts +0 -96
  233. package/out/reconcile.d.ts.map +0 -1
  234. package/out/reconcile.js +0 -127
  235. package/out/reconcile.js.map +0 -1
  236. package/out/resolve.d.ts +0 -264
  237. package/out/resolve.d.ts.map +0 -1
  238. package/out/resolve.js +0 -282
  239. package/out/resolve.js.map +0 -1
  240. package/out/tools/coverage-reconciliation.d.ts +0 -67
  241. package/out/tools/coverage-reconciliation.d.ts.map +0 -1
  242. package/out/tools/coverage-reconciliation.js +0 -113
  243. package/out/tools/coverage-reconciliation.js.map +0 -1
  244. package/out/tools/cross/dataset-correlation.d.ts +0 -61
  245. package/out/tools/cross/dataset-correlation.d.ts.map +0 -1
  246. package/out/tools/cross/dataset-correlation.js +0 -244
  247. package/out/tools/cross/dataset-correlation.js.map +0 -1
  248. package/out/tools/cross/source-threshold-sweep.d.ts +0 -60
  249. package/out/tools/cross/source-threshold-sweep.d.ts.map +0 -1
  250. package/out/tools/cross/source-threshold-sweep.js +0 -264
  251. package/out/tools/cross/source-threshold-sweep.js.map +0 -1
  252. package/out/tools/dedup-ceiling.d.ts +0 -62
  253. package/out/tools/dedup-ceiling.d.ts.map +0 -1
  254. package/out/tools/dedup-ceiling.js +0 -171
  255. package/out/tools/dedup-ceiling.js.map +0 -1
  256. package/out/tools/eval-geocoder.d.ts +0 -68
  257. package/out/tools/eval-geocoder.d.ts.map +0 -1
  258. package/out/tools/eval-geocoder.js +0 -13
  259. package/out/tools/eval-geocoder.js.map +0 -1
  260. package/out/tools/geocoder/namesake-probe.d.ts +0 -33
  261. package/out/tools/geocoder/namesake-probe.d.ts.map +0 -1
  262. package/out/tools/geocoder/namesake-probe.js +0 -60
  263. package/out/tools/geocoder/namesake-probe.js.map +0 -1
  264. package/out/tools/geocoder/vs-provided-coords.d.ts +0 -53
  265. package/out/tools/geocoder/vs-provided-coords.d.ts.map +0 -1
  266. package/out/tools/geocoder/vs-provided-coords.js +0 -161
  267. package/out/tools/geocoder/vs-provided-coords.js.map +0 -1
  268. package/out/tools/gold-set-sample.d.ts +0 -67
  269. package/out/tools/gold-set-sample.d.ts.map +0 -1
  270. package/out/tools/gold-set-sample.js +0 -81
  271. package/out/tools/gold-set-sample.js.map +0 -1
  272. package/out/tools/learned/scorer/clustering-eval.d.ts +0 -77
  273. package/out/tools/learned/scorer/clustering-eval.d.ts.map +0 -1
  274. package/out/tools/learned/scorer/clustering-eval.js +0 -207
  275. package/out/tools/learned/scorer/clustering-eval.js.map +0 -1
  276. package/out/tools/learned/scorer/crossstate-eval.d.ts +0 -65
  277. package/out/tools/learned/scorer/crossstate-eval.d.ts.map +0 -1
  278. package/out/tools/learned/scorer/crossstate-eval.js +0 -168
  279. package/out/tools/learned/scorer/crossstate-eval.js.map +0 -1
  280. package/out/tools/learned/scorer/eval.d.ts +0 -64
  281. package/out/tools/learned/scorer/eval.d.ts.map +0 -1
  282. package/out/tools/learned/scorer/eval.js +0 -275
  283. package/out/tools/learned/scorer/eval.js.map +0 -1
  284. package/out/tools/matcher-scale.d.ts +0 -40
  285. package/out/tools/matcher-scale.d.ts.map +0 -1
  286. package/out/tools/matcher-scale.js +0 -111
  287. package/out/tools/matcher-scale.js.map +0 -1
  288. package/out/tools/nppes/dedup-benchmark.d.ts +0 -82
  289. package/out/tools/nppes/dedup-benchmark.d.ts.map +0 -1
  290. package/out/tools/nppes/dedup-benchmark.js +0 -226
  291. package/out/tools/nppes/dedup-benchmark.js.map +0 -1
  292. package/out/tools/nppes/org-name.d.ts +0 -15
  293. package/out/tools/nppes/org-name.d.ts.map +0 -1
  294. package/out/tools/nppes/org-name.js +0 -6
  295. package/out/tools/nppes/org-name.js.map +0 -1
  296. package/out/tools/nppes/overmerge-packet.d.ts +0 -43
  297. package/out/tools/nppes/overmerge-packet.d.ts.map +0 -1
  298. package/out/tools/nppes/overmerge-packet.js +0 -54
  299. package/out/tools/nppes/overmerge-packet.js.map +0 -1
  300. package/out/tools/nppes/report.d.ts +0 -97
  301. package/out/tools/nppes/report.d.ts.map +0 -1
  302. package/out/tools/nppes/report.js +0 -178
  303. package/out/tools/nppes/report.js.map +0 -1
  304. package/out/tools/nppes/sample.d.ts +0 -101
  305. package/out/tools/nppes/sample.d.ts.map +0 -1
  306. package/out/tools/nppes/sample.js +0 -127
  307. package/out/tools/nppes/sample.js.map +0 -1
  308. package/out/tools/nppes/scoring.d.ts +0 -37
  309. package/out/tools/nppes/scoring.d.ts.map +0 -1
  310. package/out/tools/nppes/scoring.js +0 -81
  311. package/out/tools/nppes/scoring.js.map +0 -1
  312. package/out/tools/nppes/settings.d.ts +0 -41
  313. package/out/tools/nppes/settings.d.ts.map +0 -1
  314. package/out/tools/nppes/settings.js +0 -79
  315. package/out/tools/nppes/settings.js.map +0 -1
  316. package/out/tools/nppes/truth-grains.d.ts +0 -63
  317. package/out/tools/nppes/truth-grains.d.ts.map +0 -1
  318. package/out/tools/nppes/truth-grains.js +0 -139
  319. package/out/tools/nppes/truth-grains.js.map +0 -1
  320. package/out/tools/shared.d.ts +0 -325
  321. package/out/tools/shared.d.ts.map +0 -1
  322. package/out/tools/shared.js +0 -453
  323. package/out/tools/shared.js.map +0 -1
  324. package/out/tools/train/cross-gbt.d.ts +0 -89
  325. package/out/tools/train/cross-gbt.d.ts.map +0 -1
  326. package/out/tools/train/cross-gbt.js +0 -132
  327. package/out/tools/train/cross-gbt.js.map +0 -1
  328. package/out/tools/train/gbt.d.ts +0 -85
  329. package/out/tools/train/gbt.d.ts.map +0 -1
  330. package/out/tools/train/gbt.js +0 -155
  331. package/out/tools/train/gbt.js.map +0 -1
  332. package/out/tools/train/org-cross-gbt.d.ts +0 -85
  333. package/out/tools/train/org-cross-gbt.d.ts.map +0 -1
  334. package/out/tools/train/org-cross-gbt.js +0 -122
  335. package/out/tools/train/org-cross-gbt.js.map +0 -1
  336. package/out/tools/txhhsc-to-oarow.d.ts +0 -42
  337. package/out/tools/txhhsc-to-oarow.d.ts.map +0 -1
  338. package/out/tools/txhhsc-to-oarow.js +0 -78
  339. package/out/tools/txhhsc-to-oarow.js.map +0 -1
  340. package/out/tools/viz/browser.d.ts +0 -31
  341. package/out/tools/viz/browser.d.ts.map +0 -1
  342. package/out/tools/viz/browser.js +0 -26
  343. package/out/tools/viz/browser.js.map +0 -1
  344. package/out/tools/viz/cross-dataset-map.d.ts +0 -39
  345. package/out/tools/viz/cross-dataset-map.d.ts.map +0 -1
  346. package/out/tools/viz/cross-dataset-map.js +0 -84
  347. package/out/tools/viz/cross-dataset-map.js.map +0 -1
  348. package/out/tools/viz/geocode-first-surface.d.ts +0 -36
  349. package/out/tools/viz/geocode-first-surface.d.ts.map +0 -1
  350. package/out/tools/viz/geocode-first-surface.js +0 -234
  351. package/out/tools/viz/geocode-first-surface.js.map +0 -1
  352. package/out/tools/viz/render/map.d.ts +0 -42
  353. package/out/tools/viz/render/map.d.ts.map +0 -1
  354. package/out/tools/viz/render/map.js +0 -40
  355. package/out/tools/viz/render/map.js.map +0 -1
  356. package/out/tools/viz/render.d.ts +0 -46
  357. package/out/tools/viz/render.d.ts.map +0 -1
  358. package/out/tools/viz/render.js +0 -49
  359. package/out/tools/viz/render.js.map +0 -1
  360. package/out/tools/viz/source-provenance-map.d.ts +0 -57
  361. package/out/tools/viz/source-provenance-map.d.ts.map +0 -1
  362. package/out/tools/viz/source-provenance-map.js +0 -82
  363. package/out/tools/viz/source-provenance-map.js.map +0 -1
  364. package/out/tools/viz/yardstick-figure.d.ts +0 -22
  365. package/out/tools/viz/yardstick-figure.d.ts.map +0 -1
  366. package/out/tools/viz/yardstick-figure.js +0 -106
  367. package/out/tools/viz/yardstick-figure.js.map +0 -1
  368. package/tools/coverage-reconciliation.ts +0 -192
  369. package/tools/cross/dataset-correlation.ts +0 -380
  370. package/tools/cross/source-threshold-sweep.ts +0 -416
  371. package/tools/dedup-ceiling.ts +0 -225
  372. package/tools/eval-geocoder.ts +0 -77
  373. package/tools/geocoder/namesake-probe.ts +0 -91
  374. package/tools/geocoder/vs-provided-coords.ts +0 -232
  375. package/tools/gold-set-sample.ts +0 -147
  376. package/tools/learned/scorer/clustering-eval.ts +0 -349
  377. package/tools/learned/scorer/crossstate-eval.ts +0 -280
  378. package/tools/learned/scorer/eval.ts +0 -429
  379. package/tools/matcher-scale.ts +0 -185
  380. package/tools/nppes/dedup-benchmark.ts +0 -364
  381. package/tools/nppes/org-name.ts +0 -15
  382. package/tools/nppes/overmerge-packet.ts +0 -98
  383. package/tools/nppes/report.ts +0 -380
  384. package/tools/nppes/sample.ts +0 -250
  385. package/tools/nppes/scoring.ts +0 -115
  386. package/tools/nppes/settings.ts +0 -102
  387. package/tools/nppes/truth-grains.ts +0 -181
  388. package/tools/shared.ts +0 -743
  389. package/tools/train/cross-gbt.ts +0 -214
  390. package/tools/train/gbt.ts +0 -261
  391. package/tools/train/org-cross-gbt.ts +0 -189
  392. package/tools/txhhsc-to-oarow.ts +0 -118
  393. package/tools/viz/browser.ts +0 -41
  394. package/tools/viz/cross-dataset-map.ts +0 -133
  395. package/tools/viz/geocode-first-surface.ts +0 -305
  396. package/tools/viz/render/map.ts +0 -61
  397. package/tools/viz/render.ts +0 -103
  398. package/tools/viz/source-provenance-map.ts +0 -154
  399. package/tools/viz/yardstick-figure.ts +0 -197
@@ -1,29 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * The per-record geocode step, factored out of the worker so it unit-tests against a fake geocoder (no
7
- * neural model / SQLite). `geocode-worker.ts` builds the real geocoder from config and wraps this.
8
- */
9
- import { pick } from "#ingest";
10
- /**
11
- * Build the handler `geocodeStream` runs per normalized record: recompute the joined address
12
- * string from `record.raw` + `mapping.address` (the worker can't receive the original closure),
13
- * geocode it via `geocode`, and attach the result.
14
- *
15
- * Records with no mapped address pass through untouched (no geocode call).
16
- * The default separator matches {@link ingestRow}'s `addressSeparator`.
17
- */
18
- export function makeGeocodeHandler(geocode, mapping, addressSeparator = ", ") {
19
- return async (record) => {
20
- if (!record.raw)
21
- return record;
22
- const addressValue = pick(record.raw, mapping.address, addressSeparator);
23
- if (!addressValue)
24
- return record;
25
- const address = (await geocode(addressValue)) ?? null;
26
- return { ...record, address };
27
- };
28
- }
29
- //# sourceMappingURL=geocode-handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"geocode-handler.js","sourceRoot":"","sources":["../lib/geocode-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA2C,IAAI,EAAE,MAAM,SAAS,CAAA;AAGvE;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CACjC,OAAuB,EACvB,OAAsB,EACtB,gBAAgB,GAAG,IAAI;IAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG;YAAE,OAAO,MAAM,CAAA;QAE9B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;QAExE,IAAI,CAAC,YAAY;YAAE,OAAO,MAAM,CAAA;QAEhC,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,IAAI,CAAA;QAErD,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAA;IAC9B,CAAC,CAAA;AACF,CAAC"}
package/out/geojson.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Export resolved entities as GeoJSON — the bridge to QGIS and any web map. Each entity becomes a
7
- * Point at its resolved coordinate, carrying the properties an analyst needs: the count of records
8
- * merged into it, how tightly (cohesion), the canonical name/org/address and the geocode tier
9
- * (so rooftop-precise entities can be styled apart from admin-centroid guesses). Entities without
10
- * a coordinate are omitted (a Point feature needs one).
11
- */
12
- import type { GeoFeature, GeoFeatureCollection, PointLiteral } from "@mailwoman/spatial";
13
- import type { EntityGeoData, ResolvedEntity } from "#types";
14
- /**
15
- * One entity → one GeoJSON Point feature.
16
- *
17
- * `extra` merges over (and may override) the standard properties.
18
- * The reconciliation flow adds its `bucket` and swaps the display name for the
19
- * representative's org-or-person form.
20
- */
21
- export declare function toFeature(entity: ResolvedEntity, extra?: Partial<EntityGeoData>): GeoFeature<PointLiteral, EntityGeoData>;
22
- /**
23
- * Convert resolved entities into a GeoJSON `FeatureCollection` of points, ready for QGIS.
24
- *
25
- * Entities with no resolved coordinate are skipped.
26
- */
27
- export declare function toGeoJSON(entities: readonly ResolvedEntity[]): GeoFeatureCollection<PointLiteral, EntityGeoData>;
28
- //# sourceMappingURL=geojson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"geojson.d.ts","sourceRoot":"","sources":["../lib/geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAExF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,QAAQ,CAAA;AASzE;;;;;;GAMG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,cAAc,EACtB,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,UAAU,CAAC,YAAY,EAAE,aAAa,CAAC,CA0BzC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAKhH"}
package/out/geojson.js DELETED
@@ -1,63 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Export resolved entities as GeoJSON — the bridge to QGIS and any web map. Each entity becomes a
7
- * Point at its resolved coordinate, carrying the properties an analyst needs: the count of records
8
- * merged into it, how tightly (cohesion), the canonical name/org/address and the geocode tier
9
- * (so rooftop-precise entities can be styled apart from admin-centroid guesses). Entities without
10
- * a coordinate are omitted (a Point feature needs one).
11
- */
12
- import { formatPersonName } from "@mailwoman/record/name";
13
- /**
14
- * Assemble a display name from a record's parsed person name, if any.
15
- */
16
- function displayName(record) {
17
- return formatPersonName(record.name ?? null) || null;
18
- }
19
- /**
20
- * One entity → one GeoJSON Point feature.
21
- *
22
- * `extra` merges over (and may override) the standard properties.
23
- * The reconciliation flow adds its `bucket` and swaps the display name for the
24
- * representative's org-or-person form.
25
- */
26
- export function toFeature(entity, extra) {
27
- const rep = entity.representative;
28
- return {
29
- type: "Feature",
30
- id: undefined, // Consider using entity.id here.
31
- geometry: {
32
- type: "Point",
33
- coordinates: [entity.coordinate.longitude, entity.coordinate.latitude],
34
- },
35
- properties: {
36
- entityID: entity.id,
37
- recordCount: entity.records.length,
38
- cohesion: entity.cohesion,
39
- sourceIDs: entity.records.map((r) => r.id),
40
- // Distinct provenance labels the entity's records span.
41
- // An entity with ≥2 is a cross-dataset link.
42
- sources: [...new Set(entity.records.map((r) => r.source).filter((s) => !!s))].toSorted(),
43
- name: displayName(rep),
44
- organization: rep.organization?.canonical ?? null,
45
- address: rep.address?.formatted ?? null,
46
- geocodeTier: rep.address?.geocode?.tier ?? null,
47
- bucket: null,
48
- ...extra,
49
- },
50
- };
51
- }
52
- /**
53
- * Convert resolved entities into a GeoJSON `FeatureCollection` of points, ready for QGIS.
54
- *
55
- * Entities with no resolved coordinate are skipped.
56
- */
57
- export function toGeoJSON(entities) {
58
- return {
59
- type: "FeatureCollection",
60
- features: entities.filter((entity) => entity.coordinate).map((entity) => toFeature(entity)),
61
- };
62
- }
63
- //# sourceMappingURL=geojson.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"geojson.js","sourceRoot":"","sources":["../lib/geojson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAKzD;;GAEG;AACH,SAAS,WAAW,CAAC,MAAoB;IACxC,OAAO,gBAAgB,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,CAAA;AACrD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACxB,MAAsB,EACtB,KAA8B;IAE9B,MAAM,GAAG,GAAG,MAAM,CAAC,cAAc,CAAA;IAEjC,OAAO;QACN,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,SAAS,EAAE,iCAAiC;QAChD,QAAQ,EAAE;YACT,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,CAAC,MAAM,CAAC,UAAW,CAAC,SAAS,EAAE,MAAM,CAAC,UAAW,CAAC,QAAQ,CAAC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- *
6
- * Column mapping and normalization are pure. The caller injects geocoding, so this package never imports the neural parser, resolver, or extracts.
7
- */
8
- import type { AddressGeocode, PostalAddress } from "@mailwoman/record";
9
- import { toPostalAddress } from "@mailwoman/record";
10
- import type { PathBuilderLike } from "path-ts";
11
- import { type AsyncSequence } from "spliterator";
12
- import type { SourceRecord } from "#types";
13
- /**
14
- * Resolve a raw address string into a {@link PostalAddress}, the entry point to mailwoman's geocoder.
15
- */
16
- export type GeocodeAddress = (raw: string) => Promise<PostalAddress | null> | PostalAddress | null;
17
- /**
18
- * The column delimiters a tabular source may declare, by name, each the spliterator's own byte.
19
- *
20
- * The `satisfies` clause makes a delimiter name spliterator no longer ships a compile error
21
- * rather than a silently parallel vocabulary.
22
- */
23
- declare const COLUMN_DELIMITERS: {
24
- readonly comma: 44;
25
- readonly tab: 9;
26
- };
27
- /**
28
- * Column delimiter of a delimited source.
29
- */
30
- export type Delimiter = keyof typeof COLUMN_DELIMITERS;
31
- /**
32
- * Infer the delimiter from a path's extension (`.tsv` → tab, else comma).
33
- */
34
- export declare function delimiterFor(path: string): Delimiter;
35
- /**
36
- * Stream a delimited file's rows lazily as header-keyed objects.
37
- *
38
- * @returns The spliterator's own {@linkcode AsyncSequence}, whose `map`/`filter`
39
- * fuse into the same pull loop.
40
- * An `async function*` wrapper would add an async frame per row and remove those operators.
41
- */
42
- export declare function streamRows(source: PathBuilderLike, opts?: {
43
- delimiter?: Delimiter;
44
- }): AsyncSequence<Record<string, string>>;
45
- /**
46
- * Maps dataset columns to record fields, where a field may draw from several columns joined with spaces.
47
- */
48
- export interface ColumnMapping {
49
- /**
50
- * Column holding a stable row id, falling back to the row index.
51
- */
52
- id?: string;
53
- /**
54
- * A literal provenance label for every row (not a column).
55
- */
56
- source?: string;
57
- name?: string | string[];
58
- organization?: string | string[];
59
- address?: string | string[];
60
- phone?: string;
61
- email?: string;
62
- /**
63
- * Extra secondary-identifier fields mapped to the column(s) to draw each from, landing
64
- * on `SourceRecord.attributes` under the same key for the matcher's `discriminators`.
65
- */
66
- attributes?: Record<string, string | string[]>;
67
- }
68
- /**
69
- * Best-effort {@link ColumnMapping} inferred from a header row, the "point it at any CSV" convenience.
70
- */
71
- export declare function inferMapping(header: readonly string[]): ColumnMapping;
72
- /**
73
- * Options for {@link ingestRows}.
74
- */
75
- export interface IngestOptions {
76
- /**
77
- * The geocoding interface.
78
- *
79
- * Without it records include name/org but have no resolved address.
80
- */
81
- geocodeAddress?: GeocodeAddress;
82
- /**
83
- * Separator for joining a multi-column address mapping, comma-join giving the parser
84
- * delimited input rather than a concatenated run (name/org always join with a space).
85
- *
86
- * @defaultValue `", "`
87
- */
88
- addressSeparator?: string;
89
- }
90
- /**
91
- * Join the selected columns of a row into a single trimmed string, or null if empty.
92
- */
93
- export declare function pick(row: Record<string, string>, columns?: string | string[], separator?: string): string | null;
94
- /**
95
- * Normalize one tabular row into a {@link SourceRecord} under a {@link ColumnMapping},
96
- * pure aside from the optional geocode interface so the deterministic normalization
97
- * can run single-threaded while geocoding is offloaded.
98
- */
99
- export declare function ingestRow(row: Record<string, string>, mapping: ColumnMapping, index: number, opts?: IngestOptions): Promise<SourceRecord>;
100
- /**
101
- * Normalize tabular rows into {@link SourceRecord}s under a {@link ColumnMapping}.
102
- *
103
- * @see {@link streamRows} for the streaming path. It is preferred for multi-GB files.
104
- */
105
- export declare function ingestRows(rows: Iterable<Record<string, string>> | AsyncIterable<Record<string, string>>, mapping: ColumnMapping, opts?: IngestOptions): Promise<SourceRecord[]>;
106
- /**
107
- * Stream a delimited file as normalized {@link SourceRecord}s in file order with no geocoding.
108
- * Geocode separately through `geocodeStream`.
109
- */
110
- export declare function normalizeCSV(source: PathBuilderLike, opts: {
111
- mapping: ColumnMapping;
112
- delimiter?: Delimiter;
113
- }): AsyncSequence<SourceRecord>;
114
- /**
115
- * The subset of mailwoman's `GeocodeResult` the adapter consumes, kept structural
116
- * so this package never imports the heavy geocoder.
117
- */
118
- export interface RawGeocode {
119
- lat: number | null;
120
- lon: number | null;
121
- resolution_tier: AddressGeocode["tier"];
122
- uncertainty_m: number | null;
123
- hierarchy?: AddressGeocode["hierarchy"];
124
- }
125
- /**
126
- * The component map {@link toPostalAddress} consumes
127
- * (kept structural so this package never imports the geocoder).
128
- */
129
- type GeocodeComponents = Parameters<typeof toPostalAddress>[0];
130
- /**
131
- * What every shape of {@link geocodeAddressVia}'s dependencies includes.
132
- */
133
- export interface GeocodeDepsBase {
134
- /**
135
- * Country (ISO-2 or name) the address is formatted under.
136
- *
137
- * When omitted, {@link toPostalAddress} reads the parsed `country` component instead.
138
- */
139
- country?: string;
140
- }
141
- /**
142
- * Two independent calls: parse the address, then geocode it.
143
- *
144
- * Mailwoman's `geocodeAddress` re-parses internally, so the address is read twice
145
- * unless the two callbacks share a parser.
146
- */
147
- export interface TwoStepGeocodeDeps extends GeocodeDepsBase {
148
- parse: (raw: string) => Promise<GeocodeComponents> | GeocodeComponents;
149
- geocode: (raw: string) => Promise<RawGeocode | null> | RawGeocode | null;
150
- }
151
- /**
152
- * Parse the address once and answer both the components and the geocode, for
153
- * when the parse is the expensive step you'd rather not pay for twice.
154
- */
155
- export interface OneStepGeocodeDeps extends GeocodeDepsBase {
156
- parseAndGeocode: (raw: string) => Promise<{
157
- components: GeocodeComponents;
158
- geo: RawGeocode | null;
159
- }>;
160
- }
161
- /**
162
- * The dependencies {@link geocodeAddressVia} builds a {@link GeocodeAddress} from;
163
- * `"parseAndGeocode" in deps` tells the two shapes apart.
164
- */
165
- export type GeocodeAddressViaDeps = TwoStepGeocodeDeps | OneStepGeocodeDeps;
166
- /**
167
- * Build a {@link GeocodeAddress} from injected parse and geocode primitives.
168
- *
169
- * When geocoding can't place the address, the parsed-but-unlocated address is still returned.
170
- */
171
- export declare function geocodeAddressVia(deps: GeocodeAddressViaDeps): GeocodeAddress;
172
- export {};
173
- //# sourceMappingURL=ingest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../lib/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AAI,CAAA;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;IACvC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAA;CACvC;AAED;;;GAGG;AACH,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;AAE9D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IAC1D,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAA;IACtE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,UAAU,GAAG,IAAI,CAAA;CACxE;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IAC1D,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,UAAU,EAAE,iBAAiB,CAAC;QAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;CACpG;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAAG,kBAAkB,CAAA;AAE3E;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,cAAc,CA6B7E"}
package/out/ingest.js DELETED
@@ -1,185 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Column mapping and normalization are pure. The caller injects geocoding, so this package never imports the neural parser, resolver, or extracts.
7
- */
8
- import { isPresent } from "@mailwoman/core/objects";
9
- import { canonicalizeOrganizationName, parsePersonName, toPostalAddress, withGeocode } from "@mailwoman/record";
10
- import { CSVSpliterator, Delimiters } from "spliterator";
11
- /**
12
- * The column delimiters a tabular source may declare, by name, each the spliterator's own byte.
13
- *
14
- * The `satisfies` clause makes a delimiter name spliterator no longer ships a compile error
15
- * rather than a silently parallel vocabulary.
16
- */
17
- const COLUMN_DELIMITERS = {
18
- comma: Delimiters.Comma,
19
- tab: Delimiters.Tab,
20
- };
21
- /**
22
- * Infer the delimiter from a path's extension (`.tsv` → tab, else comma).
23
- */
24
- export function delimiterFor(path) {
25
- return /\.tsv$/i.test(path) ? "tab" : "comma";
26
- }
27
- /**
28
- * Stream a delimited file's rows lazily as header-keyed objects.
29
- *
30
- * @returns The spliterator's own {@linkcode AsyncSequence}, whose `map`/`filter`
31
- * fuse into the same pull loop.
32
- * An `async function*` wrapper would add an async frame per row and remove those operators.
33
- */
34
- export function streamRows(source, opts = {}) {
35
- const path = source.toString();
36
- return CSVSpliterator.fromAsync(path, {
37
- columnDelimiter: COLUMN_DELIMITERS[opts.delimiter ?? delimiterFor(path)],
38
- // A {@linkcode ColumnMapping} holds columns in the publisher's spelling rather than a
39
- // normalized key such as `facility_name`, so the keys must arrive as the file writes them.
40
- // The reader's default normalizes.
41
- normalizeKeys: false,
42
- });
43
- }
44
- /**
45
- * Best-effort {@link ColumnMapping} inferred from a header row, the "point it at any CSV" convenience.
46
- */
47
- export function inferMapping(header) {
48
- // Pad to whole-token boundaries so "state" doesn't match inside "statement".
49
- const tok = (h) => ` ${h
50
- .toLowerCase()
51
- .replaceAll(/[^a-z0-9]+/g, " ")
52
- .trim()} `;
53
- const mapping = {};
54
- const name = [];
55
- const address = [];
56
- for (const column of header) {
57
- const h = tok(column);
58
- const has = (...words) => words.some((w) => h.includes(` ${w} `));
59
- if (!mapping.email && has("email", "e mail")) {
60
- mapping.email = column;
61
- }
62
- else if (!mapping.phone && has("phone", "telephone", "tel", "mobile", "cell")) {
63
- mapping.phone = column;
64
- }
65
- else if (!mapping.id && has("id", "npi", "ein", "frn", "spin", "uuid", "guid", "key")) {
66
- mapping.id = column;
67
- }
68
- else if (has("org", "organization", "organisation", "company", "business", "facility", "agency", "employer")) {
69
- mapping.organization ??= column;
70
- }
71
- else if (has("street", "address", "addr", "city", "town", "state", "province", "zip", "zipcode", "postal", "postcode", "county")) {
72
- address.push(column);
73
- }
74
- else if (has("name", "first", "last", "given", "family", "middle", "surname", "fullname", "contact")) {
75
- name.push(column);
76
- }
77
- }
78
- if (name.length) {
79
- mapping.name = name.length === 1 ? name[0] : name;
80
- }
81
- if (address.length) {
82
- mapping.address = address;
83
- }
84
- return mapping;
85
- }
86
- /**
87
- * Join the selected columns of a row into a single trimmed string, or null if empty.
88
- */
89
- export function pick(row, columns, separator = " ") {
90
- if (!columns)
91
- return null;
92
- const list = Array.isArray(columns) ? columns : [columns];
93
- const value = list
94
- .map((c) => row[c])
95
- .filter(isPresent)
96
- .join(separator)
97
- .trim();
98
- return value || null;
99
- }
100
- /**
101
- * Normalize one tabular row into a {@link SourceRecord} under a {@link ColumnMapping},
102
- * pure aside from the optional geocode interface so the deterministic normalization
103
- * can run single-threaded while geocoding is offloaded.
104
- */
105
- export async function ingestRow(row, mapping, index, opts = {}) {
106
- const id = (mapping.id ? row[mapping.id] : "") || String(index);
107
- const nameValue = pick(row, mapping.name);
108
- const orgValue = pick(row, mapping.organization);
109
- const addressValue = pick(row, mapping.address, opts.addressSeparator ?? ", ");
110
- let attributes = null;
111
- if (mapping.attributes) {
112
- for (const [key, columns] of Object.entries(mapping.attributes)) {
113
- const value = pick(row, columns);
114
- if (value) {
115
- ;
116
- (attributes ??= {})[key] = value;
117
- }
118
- }
119
- }
120
- return {
121
- id,
122
- source: mapping.source ?? null,
123
- name: nameValue ? parsePersonName(nameValue) : null,
124
- organization: orgValue ? canonicalizeOrganizationName(orgValue) : null,
125
- phone: (mapping.phone && row[mapping.phone]) || null,
126
- email: (mapping.email && row[mapping.email]?.toLowerCase()) || null,
127
- address: addressValue && opts.geocodeAddress ? ((await opts.geocodeAddress(addressValue)) ?? null) : null,
128
- attributes,
129
- raw: row,
130
- };
131
- }
132
- /**
133
- * Normalize tabular rows into {@link SourceRecord}s under a {@link ColumnMapping}.
134
- *
135
- * @see {@link streamRows} for the streaming path. It is preferred for multi-GB files.
136
- */
137
- export async function ingestRows(rows, mapping, opts = {}) {
138
- const records = [];
139
- let index = 0;
140
- for await (const row of rows) {
141
- records.push(await ingestRow(row, mapping, index, opts));
142
- index++;
143
- }
144
- return records;
145
- }
146
- /**
147
- * Stream a delimited file as normalized {@link SourceRecord}s in file order with no geocoding.
148
- * Geocode separately through `geocodeStream`.
149
- */
150
- export function normalizeCSV(source, opts) {
151
- return streamRows(source, { delimiter: opts.delimiter }).map((row, index) => ingestRow(row, opts.mapping, index));
152
- }
153
- /**
154
- * Build a {@link GeocodeAddress} from injected parse and geocode primitives.
155
- *
156
- * When geocoding can't place the address, the parsed-but-unlocated address is still returned.
157
- */
158
- export function geocodeAddressVia(deps) {
159
- return async (raw) => {
160
- let components;
161
- let resolved;
162
- if ("parseAndGeocode" in deps) {
163
- const r = await deps.parseAndGeocode(raw);
164
- components = r.components;
165
- resolved = r.geo;
166
- }
167
- else {
168
- components = await deps.parse(raw);
169
- resolved = await deps.geocode(raw);
170
- }
171
- const base = toPostalAddress(components, { country: deps.country, raw });
172
- if (!resolved || resolved.lat === null || resolved.lon === null)
173
- return base;
174
- const geocode = {
175
- coordinate: { latitude: resolved.lat, longitude: resolved.lon },
176
- tier: resolved.resolution_tier,
177
- uncertaintyMeters: resolved.uncertainty_m,
178
- hierarchy: resolved.hierarchy ?? null,
179
- poBox: null,
180
- multiUnit: null,
181
- };
182
- return withGeocode(base, geocode);
183
- };
184
- }
185
- //# sourceMappingURL=ingest.js.map
package/out/ingest.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"ingest.js","sourceRoot":"","sources":["../lib/ingest.ts"],"names":[],"mappings":"AAAA;;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,CAAC,UAAU,CAAA;YACzB,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAA;QACjB,CAAC;aAAM,CAAC;YACP,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAClC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACnC,CAAC;QAED,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;QAExE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,KAAK,IAAI,IAAI,QAAQ,CAAC,GAAG,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QAE5E,MAAM,OAAO,GAAmB;YAC/B,UAAU,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,GAAG,EAAE;YAC/D,IAAI,EAAE,QAAQ,CAAC,eAAe;YAC9B,iBAAiB,EAAE,QAAQ,CAAC,aAAa;YACzC,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,IAAI;YACrC,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;SACf,CAAA;QAED,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClC,CAAC,CAAA;AACF,CAAC"}
@@ -1,61 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * The learned scorer, the production wiring for the gradient-boosted-tree model behind
7
- * {@link ResolveConfig.scorer}.
8
- *
9
- * {@link createMatchFeaturizer} is the one feature extractor for a candidate pair, used
10
- * identically at train time (`registry/tools/train-gbt.ts`), eval time and inference time.
11
- * {@link createGBTScorer} wraps a trained {@link GBT} and the featurizer into the `(a, b) => number`
12
- * the resolve pipeline's `scorer` hook expects (a logit, threshold-comparable with the
13
- * Fellegi-Sunter weight it replaces).
14
- *
15
- * Both take the comparison set as input rather than importing {@link buildDefaultModel}, so this
16
- * module has no dependency cycle with `resolve.ts`. Feed the comparisons from
17
- * `buildDefaultModel({ collapseSpatial: true, addressFrequency })`, since that config fixes the
18
- * feature layout.
19
- */
20
- import { type Comparison, type GBT, type TermFrequencyTable } from "@mailwoman/match";
21
- import type { SourceRecord } from "#types";
22
- /**
23
- * Inputs shared by the featurizer + the scorer factory.
24
- */
25
- export interface LearnedFeatureConfig {
26
- /**
27
- * The comparison set the features are built over.
28
- *
29
- * It must be `buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons`
30
- * so the feature layout matches the trained model.
31
- *
32
- * `usePhone` and `discriminators` are not part of the learned feature model,
33
- * since the GBT replaces the Fellegi-Sunter weight wholesale and owns its feature vector.
34
- */
35
- comparisons: Comparison<SourceRecord>[];
36
- /**
37
- * Address-frequency table for the crowdedness feature (a crowded shared address is weak identity).
38
- */
39
- addressFrequency: TermFrequencyTable;
40
- }
41
- /**
42
- * Build the per-pair feature extractor.
43
- *
44
- * The vector is: one-hot of each comparison's agreement level, then the two over-merge
45
- * interaction terms (spatial-exact × name-disagree, spatial-exact × org-disagree,
46
- * the "same place, different names" signature that drives co-located over-merges),
47
- * then address crowdedness scaled into [0, 1].
48
- * Deterministic and EM-independent, so it is identical across train / eval / inference.
49
- */
50
- export declare function createMatchFeaturizer(config: LearnedFeatureConfig): (a: SourceRecord, b: SourceRecord) => number[];
51
- /**
52
- * Wrap a trained {@link GBT} into the `(a, b) => number` link scorer for {@link ResolveConfig.scorer}.
53
- *
54
- * The returned weight is the model's logit.
55
- * Same threshold-comparable units as the Fellegi-Sunter weight it replaces,
56
- * so the pipeline's clustering + threshold semantics are unchanged.
57
- */
58
- export declare function createGBTScorer(config: LearnedFeatureConfig & {
59
- model: GBT;
60
- }): (a: SourceRecord, b: SourceRecord) => number;
61
- //# sourceMappingURL=learned-scorer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"learned-scorer.d.ts","sourceRoot":"","sources":["../lib/learned-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEN,KAAK,UAAU,EACf,KAAK,GAAG,EAGR,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAS1C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;;;;OAQG;IACH,WAAW,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAA;IACvC;;OAEG;IACH,gBAAgB,EAAE,kBAAkB,CAAA;CACpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,KAAK,MAAM,EAAE,CAkDlH;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,oBAAoB,GAAG;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,GAC3C,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,KAAK,MAAM,CAK9C"}