@mailwoman/registry 9.1.0 → 9.3.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.
- package/README.md +2 -2
- package/{address-key.ts → lib/address-key.ts} +1 -1
- package/{geocode-handler.ts → lib/geocode-handler.ts} +7 -7
- package/{geojson.ts → lib/geojson.ts} +12 -6
- package/{index.ts → lib/index.ts} +10 -10
- package/{ingest.ts → lib/ingest.ts} +77 -69
- package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
- package/{map-html.ts → lib/map-html.ts} +10 -16
- package/{reconcile.ts → lib/reconcile.ts} +9 -24
- package/{resolve.ts → lib/resolve.ts} +31 -13
- package/{tools → lib/tools}/coverage-reconciliation.ts +13 -15
- package/{tools → lib/tools}/cross-dataset-correlation.ts +64 -139
- package/{tools → lib/tools}/cross-source-threshold-sweep.ts +21 -32
- package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
- package/{tools → lib/tools}/eval-geocoder.ts +10 -11
- package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
- package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +12 -11
- package/lib/tools/gold-set-sample.ts +141 -0
- package/lib/tools/index.ts +31 -0
- package/{tools → lib/tools}/learned-scorer-clustering-eval.ts +71 -260
- package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +62 -245
- package/{tools → lib/tools}/learned-scorer-eval.ts +64 -263
- package/{tools → lib/tools}/matcher-scale.ts +5 -5
- package/lib/tools/nppes/org-name.ts +23 -0
- package/lib/tools/nppes/overmerge-packet.ts +94 -0
- package/lib/tools/nppes/report.ts +373 -0
- package/lib/tools/nppes/sample.ts +245 -0
- package/lib/tools/nppes/scoring.ts +114 -0
- package/lib/tools/nppes/settings.ts +102 -0
- package/lib/tools/nppes/truth-grains.ts +161 -0
- package/lib/tools/nppes-dedup-benchmark.ts +408 -0
- package/lib/tools/shared.ts +763 -0
- package/lib/tools/train-cross-gbt.ts +209 -0
- package/{tools → lib/tools}/train-gbt.ts +38 -156
- package/lib/tools/train-org-cross-gbt.ts +179 -0
- package/{tools → lib/tools}/txhhsc-to-oarow.ts +10 -28
- package/lib/tools/viz/browser.ts +50 -0
- package/{tools → lib/tools}/viz/cross-dataset-map.ts +16 -39
- package/{tools → lib/tools}/viz/geocode-first-surface.ts +13 -39
- package/{tools → lib/tools}/viz/render-map.ts +10 -23
- package/lib/tools/viz/render.ts +98 -0
- package/{tools → lib/tools}/viz/source-provenance-map.ts +20 -39
- package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
- package/{types.ts → lib/types.ts} +10 -1
- package/out/address-key.d.ts +1 -1
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +6 -6
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +6 -6
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +7 -2
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +8 -5
- package/out/geojson.js.map +1 -1
- package/out/index.d.ts +10 -10
- package/out/index.d.ts.map +1 -1
- package/out/index.js +10 -10
- package/out/index.js.map +1 -1
- package/out/ingest.d.ts +64 -46
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +33 -46
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +1 -1
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +4 -4
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +6 -11
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts +6 -1
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +7 -21
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +19 -7
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +20 -6
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.d.ts +1 -1
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +12 -12
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross-dataset-correlation.d.ts +4 -4
- package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross-dataset-correlation.js +60 -111
- package/out/tools/cross-dataset-correlation.js.map +1 -1
- package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
- package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
- package/out/tools/cross-source-threshold-sweep.js +19 -27
- package/out/tools/cross-source-threshold-sweep.js.map +1 -1
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +36 -118
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +9 -13
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +2 -2
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder-namesake-probe.d.ts +2 -2
- package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
- package/out/tools/geocoder-namesake-probe.js +4 -8
- package/out/tools/geocoder-namesake-probe.js.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
- package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder-vs-provided-coords.js +11 -9
- package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts +5 -5
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +37 -121
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/index.d.ts +24 -29
- package/out/tools/index.d.ts.map +1 -1
- package/out/tools/index.js +24 -29
- package/out/tools/index.js.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
- package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-clustering-eval.js +35 -170
- package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
- package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-crossstate-eval.js +44 -166
- package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
- package/out/tools/learned-scorer-eval.d.ts +1 -1
- package/out/tools/learned-scorer-eval.d.ts.map +1 -1
- package/out/tools/learned-scorer-eval.js +37 -173
- package/out/tools/learned-scorer-eval.js.map +1 -1
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +5 -5
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts +21 -0
- package/out/tools/nppes/org-name.d.ts.map +1 -0
- package/out/tools/nppes/org-name.js +13 -0
- package/out/tools/nppes/org-name.js.map +1 -0
- package/out/tools/nppes/overmerge-packet.d.ts +39 -0
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -0
- package/out/tools/nppes/overmerge-packet.js +55 -0
- package/out/tools/nppes/overmerge-packet.js.map +1 -0
- package/out/tools/nppes/report.d.ts +93 -0
- package/out/tools/nppes/report.d.ts.map +1 -0
- package/out/tools/nppes/report.js +186 -0
- package/out/tools/nppes/report.js.map +1 -0
- package/out/tools/nppes/sample.d.ts +90 -0
- package/out/tools/nppes/sample.d.ts.map +1 -0
- package/out/tools/nppes/sample.js +131 -0
- package/out/tools/nppes/sample.js.map +1 -0
- package/out/tools/nppes/scoring.d.ts +36 -0
- package/out/tools/nppes/scoring.d.ts.map +1 -0
- package/out/tools/nppes/scoring.js +80 -0
- package/out/tools/nppes/scoring.js.map +1 -0
- package/out/tools/nppes/settings.d.ts +38 -0
- package/out/tools/nppes/settings.d.ts.map +1 -0
- package/out/tools/nppes/settings.js +79 -0
- package/out/tools/nppes/settings.js.map +1 -0
- package/out/tools/nppes/truth-grains.d.ts +50 -0
- package/out/tools/nppes/truth-grains.d.ts.map +1 -0
- package/out/tools/nppes/truth-grains.js +123 -0
- package/out/tools/nppes/truth-grains.js.map +1 -0
- package/out/tools/nppes-dedup-benchmark.d.ts +7 -3
- package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes-dedup-benchmark.js +106 -673
- package/out/tools/nppes-dedup-benchmark.js.map +1 -1
- package/out/tools/shared.d.ts +244 -7
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +353 -21
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train-cross-gbt.d.ts +7 -7
- package/out/tools/train-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-cross-gbt.js +47 -145
- package/out/tools/train-cross-gbt.js.map +1 -1
- package/out/tools/train-gbt.d.ts +7 -7
- package/out/tools/train-gbt.d.ts.map +1 -1
- package/out/tools/train-gbt.js +31 -111
- package/out/tools/train-gbt.js.map +1 -1
- package/out/tools/train-org-cross-gbt.d.ts +7 -5
- package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train-org-cross-gbt.js +45 -141
- package/out/tools/train-org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.d.ts +2 -2
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +9 -23
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +34 -0
- package/out/tools/viz/browser.d.ts.map +1 -0
- package/out/tools/viz/browser.js +33 -0
- package/out/tools/viz/browser.js.map +1 -0
- package/out/tools/viz/cross-dataset-map.d.ts +4 -25
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +12 -33
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +6 -35
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +10 -37
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render-map.d.ts +3 -6
- package/out/tools/viz/render-map.d.ts.map +1 -1
- package/out/tools/viz/render-map.js +9 -19
- package/out/tools/viz/render-map.js.map +1 -1
- package/out/tools/viz/render.d.ts +4 -9
- package/out/tools/viz/render.d.ts.map +1 -1
- package/out/tools/viz/render.js +24 -39
- package/out/tools/viz/render.js.map +1 -1
- package/out/tools/viz/source-provenance-map.d.ts +4 -24
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +12 -32
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +2 -2
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +5 -4
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts +11 -1
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/package.json +180 -11
- package/tools/gold-set-sample.ts +0 -252
- package/tools/index.ts +0 -36
- package/tools/nppes-dedup-benchmark.ts +0 -1180
- package/tools/shared.ts +0 -160
- package/tools/train-cross-gbt.ts +0 -358
- package/tools/train-org-cross-gbt.ts +0 -329
- package/tools/viz/render.ts +0 -113
- /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
- /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
- /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
package/out/tools/shared.js
CHANGED
|
@@ -8,24 +8,87 @@
|
|
|
8
8
|
* The rule: anything reused by two or more probes belongs here; anything a single probe needs
|
|
9
9
|
* stays with that probe.
|
|
10
10
|
*/
|
|
11
|
+
import { makeDirectories, writeLocalFile } from "@mailwoman/core/fs/writers";
|
|
12
|
+
import { isPresent } from "@mailwoman/core/objects";
|
|
13
|
+
import { makeLcg } from "@mailwoman/core/random";
|
|
14
|
+
import { block, gbtScore, trainGBT } from "@mailwoman/match";
|
|
15
|
+
import { dirname } from "path-ts";
|
|
16
|
+
import { addressFrequencyKey, buildDefaultModel, createMatchFeaturizer, defaultBlockingKeys, ingestRows, normalizePhoneStrict, streamRows, } from "#index";
|
|
17
|
+
export { mean } from "@mailwoman/core/utils";
|
|
11
18
|
/**
|
|
12
19
|
* Trim, treating `undefined` as empty — the shape every probe's raw CSV columns arrive in.
|
|
13
20
|
*/
|
|
14
21
|
export const norm = (s) => (s ?? "").trim();
|
|
22
|
+
/**
|
|
23
|
+
* Corporate-form suffixes and function words that carry no identity — dropped from an organization name before its
|
|
24
|
+
* tokens are compared, so the domain words carry the distinguishing signal.
|
|
25
|
+
*/
|
|
26
|
+
const ORGANIZATION_STOP_WORDS = new Set([
|
|
27
|
+
"llc",
|
|
28
|
+
"inc",
|
|
29
|
+
"incorporated",
|
|
30
|
+
"corp",
|
|
31
|
+
"corporation",
|
|
32
|
+
"co",
|
|
33
|
+
"ltd",
|
|
34
|
+
"pllc",
|
|
35
|
+
"pc",
|
|
36
|
+
"pa",
|
|
37
|
+
"lp",
|
|
38
|
+
"llp",
|
|
39
|
+
"the",
|
|
40
|
+
"of",
|
|
41
|
+
"and",
|
|
42
|
+
]);
|
|
43
|
+
/**
|
|
44
|
+
* The token set of an organization name: lower-cased, non-alphanumerics folded to spaces, stop words removed.
|
|
45
|
+
*
|
|
46
|
+
* NOT a canonical form — `@mailwoman/record`'s `canonicalizeOrganizationName` is the stronger canonical key
|
|
47
|
+
* (jurisdiction-aware designation stripping, a DBA split). This set serves the probes' cheap Jaccard overlap over raw
|
|
48
|
+
* registry names, never blocking or display.
|
|
49
|
+
*/
|
|
50
|
+
export function orgTokens(s) {
|
|
51
|
+
return new Set(s
|
|
52
|
+
.toLowerCase()
|
|
53
|
+
.replaceAll(/[^a-z0-9 ]/g, " ")
|
|
54
|
+
.split(/\s+/)
|
|
55
|
+
.filter((t) => t && !ORGANIZATION_STOP_WORDS.has(t)));
|
|
56
|
+
}
|
|
15
57
|
/**
|
|
16
58
|
* Join the four US address columns into one line, dropping blanks.
|
|
17
59
|
*/
|
|
18
|
-
export const addr = (line, city, st, zip) => [norm(line), norm(city), norm(st), norm(zip)].filter(
|
|
60
|
+
export const addr = (line, city, st, zip) => [norm(line), norm(city), norm(st), norm(zip)].filter(isPresent).join(", ");
|
|
61
|
+
/**
|
|
62
|
+
* Population standard deviation; `0` on an empty sample, because these feed report tables that print a number per row.
|
|
63
|
+
*/
|
|
64
|
+
export const std = (xs) => {
|
|
65
|
+
const m = xs.reduce((a, b) => a + b, 0) / Math.max(1, xs.length);
|
|
66
|
+
return Math.sqrt(xs.map((x) => (x - m) ** 2).reduce((a, b) => a + b, 0) / Math.max(1, xs.length));
|
|
67
|
+
};
|
|
68
|
+
// NOTE(phase4): pct keeps the fraction-in/no-%-suffix shape — not core formatPercent's
|
|
69
|
+
// numerator/denominator contract (call sites append their own "%").
|
|
70
|
+
export const pct = (x) => (100 * x).toFixed(1);
|
|
19
71
|
/**
|
|
20
|
-
*
|
|
21
|
-
* row.
|
|
72
|
+
* Sign prefix for a signed delta — `"+"` for a non-negative value (a negative one carries its own sign).
|
|
22
73
|
*/
|
|
23
|
-
export const
|
|
74
|
+
export const sgn = (x) => (x >= 0 ? "+" : "");
|
|
24
75
|
/**
|
|
25
76
|
* Logistic function with the input clamped to +/-30 — past that `Math.exp` underflows to 0 and the gradient step
|
|
26
77
|
* silently becomes a no-op.
|
|
27
78
|
*/
|
|
28
79
|
export const sigmoid = (z) => 1 / (1 + Math.exp(-Math.max(-30, Math.min(30, z))));
|
|
80
|
+
/**
|
|
81
|
+
* The probes' shared `--state` option: upper-cased, defaulting to TX (the benchmark corpus state).
|
|
82
|
+
*/
|
|
83
|
+
export const stateOption = (options) => (options.state || "TX").toUpperCase();
|
|
84
|
+
/**
|
|
85
|
+
* Texas bounding box (generous) — the shared wrong-region test.
|
|
86
|
+
*/
|
|
87
|
+
export const TX_BBOX = { latMin: 25.8, latMax: 36.6, lonMin: -106.7, lonMax: -93.4 };
|
|
88
|
+
/**
|
|
89
|
+
* Whether a coordinate falls inside {@link TX_BBOX}.
|
|
90
|
+
*/
|
|
91
|
+
export const inTXBBOX = (lat, lon) => lat >= TX_BBOX.latMin && lat <= TX_BBOX.latMax && lon >= TX_BBOX.lonMin && lon <= TX_BBOX.lonMax;
|
|
29
92
|
/**
|
|
30
93
|
* NPPES registry column headers, by the short name the probes read them under.
|
|
31
94
|
*
|
|
@@ -45,11 +108,12 @@ export const NPPES_COLUMNS = {
|
|
|
45
108
|
pAddr: "Provider First Line Business Practice Location Address",
|
|
46
109
|
pCity: "Provider Business Practice Location Address City Name",
|
|
47
110
|
pState: "Provider Business Practice Location Address State Name",
|
|
48
|
-
pZip: "Provider Business Practice Location Address
|
|
111
|
+
pZip: "Provider Business Practice Location Address Postcode",
|
|
112
|
+
pPhone: "Provider Business Practice Location Address Telephone Number",
|
|
49
113
|
mAddr: "Provider First Line Business Mailing Address",
|
|
50
114
|
mCity: "Provider Business Mailing Address City Name",
|
|
51
115
|
mState: "Provider Business Mailing Address State Name",
|
|
52
|
-
mZip: "Provider Business Mailing Address
|
|
116
|
+
mZip: "Provider Business Mailing Address Postcode",
|
|
53
117
|
otherOrg: "Provider Other Organization Name",
|
|
54
118
|
authLast: "Authorized Official Last Name",
|
|
55
119
|
authFirst: "Authorized Official First Name",
|
|
@@ -64,7 +128,7 @@ export const NPPES_COLUMNS = {
|
|
|
64
128
|
*/
|
|
65
129
|
export const MIN_GROUP_SIZE = 5;
|
|
66
130
|
/**
|
|
67
|
-
* Gradient-
|
|
131
|
+
* Gradient-descent epochs for {@link trainLogisticRegression}. Fixed rather than early-stopped so seeds stay comparable.
|
|
68
132
|
*/
|
|
69
133
|
export const TRAINING_EPOCHS = 400;
|
|
70
134
|
/**
|
|
@@ -72,6 +136,49 @@ export const TRAINING_EPOCHS = 400;
|
|
|
72
136
|
* reported as a tie.
|
|
73
137
|
*/
|
|
74
138
|
export const MIN_MEANINGFUL_F1_DELTA = 0.02;
|
|
139
|
+
/**
|
|
140
|
+
* Batch-gradient-descent learning rate for {@link trainLogisticRegression}.
|
|
141
|
+
*/
|
|
142
|
+
export const LR_LEARNING_RATE = 0.1;
|
|
143
|
+
/**
|
|
144
|
+
* L2 regularization strength for {@link trainLogisticRegression}.
|
|
145
|
+
*/
|
|
146
|
+
export const LR_L2 = 1e-3;
|
|
147
|
+
/**
|
|
148
|
+
* L2-regularized logistic regression by batch gradient descent ({@link TRAINING_EPOCHS} epochs) — the probes' linear
|
|
149
|
+
* arm. `w` carries the per-sample class weights (the caller up-weights the rare class). Returns the linear scorer: the
|
|
150
|
+
* logit, not the probability, threshold-comparable across a fixed feature layout.
|
|
151
|
+
*/
|
|
152
|
+
export function trainLogisticRegression(X, y, w, dim) {
|
|
153
|
+
const weights = new Array(dim).fill(0);
|
|
154
|
+
let bias = 0;
|
|
155
|
+
for (let epoch = 0; epoch < TRAINING_EPOCHS; epoch++) {
|
|
156
|
+
const gw = new Array(dim).fill(0);
|
|
157
|
+
let gb = 0;
|
|
158
|
+
for (let i = 0; i < X.length; i++) {
|
|
159
|
+
let z = bias;
|
|
160
|
+
for (let j = 0; j < dim; j++) {
|
|
161
|
+
z += weights[j] * X[i][j];
|
|
162
|
+
}
|
|
163
|
+
const err = (sigmoid(z) - y[i]) * w[i];
|
|
164
|
+
for (let j = 0; j < dim; j++) {
|
|
165
|
+
gw[j] += err * X[i][j];
|
|
166
|
+
}
|
|
167
|
+
gb += err;
|
|
168
|
+
}
|
|
169
|
+
for (let j = 0; j < dim; j++) {
|
|
170
|
+
weights[j] -= LR_LEARNING_RATE * (gw[j] / X.length + LR_L2 * weights[j]);
|
|
171
|
+
}
|
|
172
|
+
bias -= LR_LEARNING_RATE * (gb / X.length);
|
|
173
|
+
}
|
|
174
|
+
return (x) => {
|
|
175
|
+
let z = bias;
|
|
176
|
+
for (let j = 0; j < x.length; j++) {
|
|
177
|
+
z += weights[j] * x[j];
|
|
178
|
+
}
|
|
179
|
+
return z;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
75
182
|
/**
|
|
76
183
|
* `n + 1` evenly-spaced order statistics of an already-sorted sample, de-duplicated — the candidate split thresholds a
|
|
77
184
|
* GBT node considers. `[0]` for an empty sample so a degenerate feature still yields one (useless but well-formed)
|
|
@@ -87,8 +194,112 @@ export function uniqueQuantiles(sorted, n) {
|
|
|
87
194
|
return [...ts];
|
|
88
195
|
}
|
|
89
196
|
/**
|
|
90
|
-
*
|
|
91
|
-
|
|
197
|
+
* Quantile points swept per learned-scorer arm.
|
|
198
|
+
*/
|
|
199
|
+
const THRESHOLD_QUANTILE_POINTS = 32;
|
|
200
|
+
/**
|
|
201
|
+
* Link-threshold candidates for a learned scorer: de-duplicated quantiles of the scorer's own eval-pair score
|
|
202
|
+
* distribution across the 0.2–0.999 quantile band — fine enough that a coarse grid can't understate an arm.
|
|
203
|
+
*/
|
|
204
|
+
export const quantileThresholds = (scores) => {
|
|
205
|
+
const sorted = [...scores].toSorted((p, q) => p - q);
|
|
206
|
+
const ts = new Set();
|
|
207
|
+
for (let k = 0; k <= THRESHOLD_QUANTILE_POINTS; k++) {
|
|
208
|
+
ts.add(sorted[Math.floor((0.2 + (0.999 - 0.2) * (k / THRESHOLD_QUANTILE_POINTS)) * (sorted.length - 1))]);
|
|
209
|
+
}
|
|
210
|
+
return [...ts];
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Project a full {@link Score} onto the arm shape the eval tables print.
|
|
214
|
+
*/
|
|
215
|
+
export const toArmScore = (s) => ({
|
|
216
|
+
precision: s.precision,
|
|
217
|
+
recall: s.recall,
|
|
218
|
+
f1: s.f1,
|
|
219
|
+
overMerged: s.overMergedClusters,
|
|
220
|
+
});
|
|
221
|
+
/**
|
|
222
|
+
* The best-F1 operating point over a threshold sweep.
|
|
223
|
+
*/
|
|
224
|
+
export function bestOver(thresholds, scoreAt) {
|
|
225
|
+
let best = { precision: 0, recall: 0, f1: -1, overMerged: 0 };
|
|
226
|
+
for (const t of thresholds) {
|
|
227
|
+
const s = scoreAt(t);
|
|
228
|
+
if (s.f1 > best.f1) {
|
|
229
|
+
best = s;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return best;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Stream in-state type-2 (organization) providers from the registry — one record per row at its practice address,
|
|
236
|
+
* grouped by `addressFrequencyKey`. Geocode-free on purpose, so it runs at large caps in seconds.
|
|
237
|
+
*/
|
|
238
|
+
export async function scanColocatedProviders(options) {
|
|
239
|
+
const { registryPath, state, cap } = options;
|
|
240
|
+
const C = NPPES_COLUMNS;
|
|
241
|
+
const byAddr = new Map();
|
|
242
|
+
let kept = 0;
|
|
243
|
+
let scanned = 0;
|
|
244
|
+
for await (const r of streamRows(registryPath)) {
|
|
245
|
+
scanned++;
|
|
246
|
+
if (norm(r[C.entityType]) !== "2")
|
|
247
|
+
continue;
|
|
248
|
+
if (norm(r[C.pState]).toUpperCase() !== state)
|
|
249
|
+
continue;
|
|
250
|
+
const org = norm(r[C.orgLegal]);
|
|
251
|
+
const line1 = norm(r[C.pAddr]);
|
|
252
|
+
if (!org || !line1)
|
|
253
|
+
continue;
|
|
254
|
+
const address = addr(line1, r[C.pCity], state, r[C.pZip]);
|
|
255
|
+
const addrKey = addressFrequencyKey(address);
|
|
256
|
+
if (!addrKey)
|
|
257
|
+
continue;
|
|
258
|
+
const provider = {
|
|
259
|
+
npi: norm(r[C.npi]),
|
|
260
|
+
org,
|
|
261
|
+
tokens: orgTokens(org),
|
|
262
|
+
address,
|
|
263
|
+
phone: normalizePhoneStrict(r[C.pPhone]),
|
|
264
|
+
auth: `${norm(r[C.authLast])} ${norm(r[C.authFirst])}`.toLowerCase().trim(),
|
|
265
|
+
taxonomy: norm(r[C.taxonomy[0]]),
|
|
266
|
+
subpart: norm(r[C.isSubpart]).toUpperCase() === "Y",
|
|
267
|
+
parent: `${norm(r[C.parentLBN])}|${norm(r[C.parentTIN])}`.toLowerCase(),
|
|
268
|
+
};
|
|
269
|
+
if (!byAddr.has(addrKey)) {
|
|
270
|
+
byAddr.set(addrKey, []);
|
|
271
|
+
}
|
|
272
|
+
byAddr.get(addrKey).push(provider);
|
|
273
|
+
kept++;
|
|
274
|
+
if (kept >= cap)
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
return { byAddr, kept, scanned };
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Every unordered pair of DISTINCT NPIs sharing a practice-address key — the over-merge population. Providers are
|
|
281
|
+
* de-duplicated per address by NPI (first record wins); single-NPI addresses yield nothing.
|
|
282
|
+
*/
|
|
283
|
+
export function* colocatedDistinctPairs(byAddr) {
|
|
284
|
+
for (const providers of byAddr.values()) {
|
|
285
|
+
const distinct = new Map();
|
|
286
|
+
for (const p of providers)
|
|
287
|
+
if (!distinct.has(p.npi)) {
|
|
288
|
+
distinct.set(p.npi, p);
|
|
289
|
+
}
|
|
290
|
+
const group = [...distinct.values()];
|
|
291
|
+
if (group.length < 2)
|
|
292
|
+
continue;
|
|
293
|
+
for (let i = 0; i < group.length; i++) {
|
|
294
|
+
for (let j = i + 1; j < group.length; j++) {
|
|
295
|
+
yield { a: group[i], b: group[j], group };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The TX facility source specs the cross-source probes share. `cross-dataset-correlation` composes these with its own
|
|
302
|
+
* commitments spec (the exploded two-entity-per-row source).
|
|
92
303
|
*/
|
|
93
304
|
export const buildSpecs = (S, STATE) => [
|
|
94
305
|
{
|
|
@@ -120,20 +331,141 @@ export const buildSpecs = (S, STATE) => [
|
|
|
120
331
|
source: "nppes",
|
|
121
332
|
path: `${S}/nppes_npi-registry_20260607.tsv`,
|
|
122
333
|
mapping: {
|
|
123
|
-
id:
|
|
124
|
-
organization:
|
|
125
|
-
address: [
|
|
126
|
-
|
|
127
|
-
"Provider Business Practice Location Address City Name",
|
|
128
|
-
"Provider Business Practice Location Address State Name",
|
|
129
|
-
"Provider Business Practice Location Address Postal Code",
|
|
130
|
-
],
|
|
131
|
-
phone: "Provider Business Practice Location Address Telephone Number",
|
|
334
|
+
id: NPPES_COLUMNS.npi,
|
|
335
|
+
organization: NPPES_COLUMNS.orgLegal,
|
|
336
|
+
address: [NPPES_COLUMNS.pAddr, NPPES_COLUMNS.pCity, NPPES_COLUMNS.pState, NPPES_COLUMNS.pZip],
|
|
337
|
+
phone: NPPES_COLUMNS.pPhone,
|
|
132
338
|
source: "nppes",
|
|
133
339
|
},
|
|
134
|
-
inState: (r) => norm(r[
|
|
135
|
-
norm(r[
|
|
136
|
-
!!norm(r[
|
|
340
|
+
inState: (r) => norm(r[NPPES_COLUMNS.pState]).toUpperCase() === STATE &&
|
|
341
|
+
norm(r[NPPES_COLUMNS.entityType]) === "2" &&
|
|
342
|
+
!!norm(r[NPPES_COLUMNS.orgLegal]),
|
|
137
343
|
},
|
|
138
344
|
];
|
|
345
|
+
/**
|
|
346
|
+
* The compact pure-Node GBT configuration the cross-source trainers fit with.
|
|
347
|
+
*/
|
|
348
|
+
const CROSS_SOURCE_HYPERPARAMS = { rounds: 120, depth: 3, lr: 0.3, minLeaf: 20 };
|
|
349
|
+
/**
|
|
350
|
+
* Share of join keys assigned to fit during calibration; the rest are held out.
|
|
351
|
+
*/
|
|
352
|
+
const FIT_SPLIT_FRACTION = 0.8;
|
|
353
|
+
/**
|
|
354
|
+
* Phases C–F shared by the cross-source trainers: geocode + ingest each source under its own provenance label, block
|
|
355
|
+
* the union and keep only CROSS-source candidate pairs, featurize with the SHARED `createMatchFeaturizer` (train ≡
|
|
356
|
+
* inference), calibrate the #655 threshold on a held-out split of the join keys, train the shipped model on ALL pairs,
|
|
357
|
+
* and emit it as a committed TS module.
|
|
358
|
+
*/
|
|
359
|
+
export async function trainCrossSourceModel(options) {
|
|
360
|
+
const { rows, joined, addressFrequency, sources, precisionBar, out, report } = options;
|
|
361
|
+
// --- Phase C: geocode + ingest (record.id = the join-key label; `source` rides the record). The
|
|
362
|
+
// heavy geocoder is injected (see ./eval-geocoder.ts). ---
|
|
363
|
+
report?.("[C] geocoding…");
|
|
364
|
+
const geocoder = await options.createGeocoder();
|
|
365
|
+
// `ColumnMapping.source` is a LITERAL provenance label — ingest each source separately so every
|
|
366
|
+
// record carries its registry of origin (the cross-source filter + the sweep harness key on it).
|
|
367
|
+
const mappingFor = (source) => ({
|
|
368
|
+
id: "npi",
|
|
369
|
+
name: "name",
|
|
370
|
+
organization: "org",
|
|
371
|
+
address: "address",
|
|
372
|
+
source,
|
|
373
|
+
});
|
|
374
|
+
const records = [];
|
|
375
|
+
for (const source of sources) {
|
|
376
|
+
records.push(...(await ingestRows(rows.filter((r) => r.source === source), mappingFor(source), { geocodeAddress: geocoder.geocodeAddress })));
|
|
377
|
+
}
|
|
378
|
+
geocoder[Symbol.dispose]();
|
|
379
|
+
report?.(` ${records.length} records, ${records.filter((r) => r.address?.geocode).length} geocoded`);
|
|
380
|
+
// --- Phase D: block over the UNION; keep only CROSS-source pairs; featurize; label by join key. ---
|
|
381
|
+
report?.("[D] blocking + featurizing (cross-source pairs only)…");
|
|
382
|
+
const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons;
|
|
383
|
+
const featurize = createMatchFeaturizer({ comparisons, addressFrequency });
|
|
384
|
+
const { pairs: allPairs } = block(records, defaultBlockingKeys());
|
|
385
|
+
const pairs = allPairs.filter(([a, b]) => a.source !== b.source);
|
|
386
|
+
const X = pairs.map(([a, b]) => featurize(a, b));
|
|
387
|
+
const Y = pairs.map(([a, b]) => (a.id === b.id ? 1 : 0));
|
|
388
|
+
const posRate = Y.reduce((s, y) => s + y, 0) / Math.max(1, Y.length);
|
|
389
|
+
const W = Y.map((y) => (y === 1 ? 1 - posRate : posRate));
|
|
390
|
+
report?.(` ${allPairs.length} blocked pairs → ${pairs.length} cross-source (${(100 * posRate).toFixed(1)}% positive)`);
|
|
391
|
+
// --- Phase E: held-out calibration — the #655 threshold rule. ---
|
|
392
|
+
report?.("[E] held-out calibration…");
|
|
393
|
+
const rnd = makeLcg(655);
|
|
394
|
+
const split = new Map();
|
|
395
|
+
for (const key of joined) {
|
|
396
|
+
split.set(key, rnd() < FIT_SPLIT_FRACTION ? "fit" : "holdout");
|
|
397
|
+
}
|
|
398
|
+
const fitIdx = pairs
|
|
399
|
+
.map((_, i) => i)
|
|
400
|
+
.filter((i) => split.get(pairs[i][0].id) === "fit" && split.get(pairs[i][1].id) === "fit");
|
|
401
|
+
const holdIdx = pairs
|
|
402
|
+
.map((_, i) => i)
|
|
403
|
+
.filter((i) => split.get(pairs[i][0].id) === "holdout" && split.get(pairs[i][1].id) === "holdout");
|
|
404
|
+
const calib = trainGBT(fitIdx.map((i) => X[i]), fitIdx.map((i) => Y[i]), fitIdx.map((i) => W[i]), CROSS_SOURCE_HYPERPARAMS);
|
|
405
|
+
const holdScores = holdIdx.map((i) => ({ s: gbtScore(calib, X[i]), y: Y[i] }));
|
|
406
|
+
const sorted = holdScores.map((h) => h.s).toSorted((a, b) => a - b);
|
|
407
|
+
const totalPos = holdScores.reduce((s, h) => s + h.y, 0);
|
|
408
|
+
let recommendedThreshold = Number.POSITIVE_INFINITY;
|
|
409
|
+
let barRecall = 0;
|
|
410
|
+
let f1MaxThreshold = 0;
|
|
411
|
+
let bestF1 = -1;
|
|
412
|
+
for (const t of uniqueQuantiles(sorted, 60)) {
|
|
413
|
+
let tp = 0;
|
|
414
|
+
let fp = 0;
|
|
415
|
+
for (const h of holdScores) {
|
|
416
|
+
if (h.s < t)
|
|
417
|
+
continue;
|
|
418
|
+
if (h.y) {
|
|
419
|
+
tp++;
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
fp++;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const precision = tp + fp > 0 ? tp / (tp + fp) : 1;
|
|
426
|
+
const recall = totalPos > 0 ? tp / totalPos : 0;
|
|
427
|
+
const f1 = precision + recall > 0 ? (2 * precision * recall) / (precision + recall) : 0;
|
|
428
|
+
// The #655 rule: the LOWEST threshold whose precision clears the bar (maximizes recall under it).
|
|
429
|
+
if (precision >= precisionBar && recall > barRecall) {
|
|
430
|
+
barRecall = recall;
|
|
431
|
+
recommendedThreshold = t;
|
|
432
|
+
}
|
|
433
|
+
if (f1 > bestF1) {
|
|
434
|
+
bestF1 = f1;
|
|
435
|
+
f1MaxThreshold = t;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (!Number.isFinite(recommendedThreshold)) {
|
|
439
|
+
recommendedThreshold = f1MaxThreshold;
|
|
440
|
+
}
|
|
441
|
+
report?.(` held-out (${holdIdx.length} pairs, ${totalPos} pos): precision-bar ${precisionBar} → threshold ${recommendedThreshold.toFixed(3)} (recall ${(100 * barRecall).toFixed(1)}%); F1-max ${(100 * bestF1).toFixed(1)}% @ ${f1MaxThreshold.toFixed(3)}`);
|
|
442
|
+
// --- Phase F: train the SHIPPED model on ALL cross-source pairs; emit the committed module. ---
|
|
443
|
+
report?.("[F] training the shipped model on all pairs…");
|
|
444
|
+
const model = trainGBT(X, Y, W, CROSS_SOURCE_HYPERPARAMS);
|
|
445
|
+
const meta = options.meta({
|
|
446
|
+
records: records.length,
|
|
447
|
+
pairs: pairs.length,
|
|
448
|
+
posRate: Number(posRate.toFixed(4)),
|
|
449
|
+
barRecall: Number(barRecall.toFixed(4)),
|
|
450
|
+
f1Max: Number(bestF1.toFixed(4)),
|
|
451
|
+
recommendedThreshold: Number(recommendedThreshold.toFixed(4)),
|
|
452
|
+
features: X[0]?.length ?? 0,
|
|
453
|
+
hyperparams: CROSS_SOURCE_HYPERPARAMS,
|
|
454
|
+
});
|
|
455
|
+
const moduleSource = `/**\n` +
|
|
456
|
+
` * @copyright Sister Software\n` +
|
|
457
|
+
` * @license AGPL-3.0\n` +
|
|
458
|
+
` * @author Teffen Ellis, et al.\n` +
|
|
459
|
+
` *\n` +
|
|
460
|
+
options.moduleDoc +
|
|
461
|
+
` */\n\n` +
|
|
462
|
+
`import type { GBT } from "@mailwoman/match"\n\n` +
|
|
463
|
+
`export const ${options.exportPrefix}_META = ${JSON.stringify(meta)} as const\n\n` +
|
|
464
|
+
`// prettier-ignore\n` +
|
|
465
|
+
`export const ${options.exportPrefix}_MODEL: GBT = ${JSON.stringify(model)}\n`;
|
|
466
|
+
await makeDirectories(dirname(out));
|
|
467
|
+
await writeLocalFile(moduleSource, out);
|
|
468
|
+
report?.(` ${model.trees.length} trees, ${X[0]?.length ?? 0} features -> ${out}`);
|
|
469
|
+
return { out, pairs: pairs.length, recommendedThreshold };
|
|
470
|
+
}
|
|
139
471
|
//# sourceMappingURL=shared.js.map
|
package/out/tools/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../tools/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAqB,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAU,EAAE,GAAW,EAAU,EAAE,CACnF,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEzE;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EAAqB,EAAU,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,C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AS,CAAC,IAAI,CAAC,eAAe;QAClF,sBAAsB;QACtB,gBAAgB,OAAO,CAAC,YAAY,iBAAiB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAA;IAE/E,MAAM,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACnC,MAAM,cAAc,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;IACvC,MAAM,EAAE,CAAC,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAA;IAEpF,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAA;AAC1D,CAAC"}
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
* each with independently human-entered name + address. Same-NPI cross-source pairs are
|
|
13
13
|
* ground-truth positives labeled by a key the matcher's features never see.
|
|
14
14
|
*
|
|
15
|
-
* Pipeline
|
|
16
|
-
*
|
|
17
|
-
* CROSS-source candidate pairs →
|
|
18
|
-
* inference) → label by NPI → held-out-NPI calibration (the #655
|
|
19
|
-
* subject to a pairwise-precision bar, reported alongside F1-max) →
|
|
20
|
-
* all pairs → emit `registry/models/crosssource-gbt-en-us.ts`.
|
|
15
|
+
* Pipeline: assemble NPPES + Open Payments TX records for the same NPI population (Phases A/B
|
|
16
|
+
* here), then the SHARED `trainCrossSourceModel` runs Phases C–F — geocode through the standard
|
|
17
|
+
* ingest → block the UNION, keep only CROSS-source candidate pairs → the SHARED
|
|
18
|
+
* `createMatchFeaturizer` (train ≡ inference) → label by NPI → held-out-NPI calibration (the #655
|
|
19
|
+
* threshold rule: max recall subject to a pairwise-precision bar, reported alongside F1-max) →
|
|
20
|
+
* train the shipped model on all pairs → emit `registry/models/crosssource-gbt-en-us.ts`.
|
|
21
21
|
*
|
|
22
22
|
* Sources (both public domain, `.notes/data-sources.md`):
|
|
23
23
|
*
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* [--precision-bar 0.95] [--wof <admin.db>] [--data-root <dir>]
|
|
30
30
|
* [--out registry/models/crosssource-gbt-en-us.ts]`
|
|
31
31
|
*/
|
|
32
|
-
import type { EvalGeocoderFactory } from "
|
|
32
|
+
import type { EvalGeocoderFactory } from "#tools/eval-geocoder";
|
|
33
33
|
/**
|
|
34
34
|
* Options for {@linkcode trainCrossSourceGBT}.
|
|
35
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"train-cross-gbt.d.ts","sourceRoot":"","sources":["../../tools/train-cross-gbt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;
|
|
1
|
+
{"version":3,"file":"train-cross-gbt.d.ts","sourceRoot":"","sources":["../../lib/tools/train-cross-gbt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAMH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAG/D;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,cAAc,EAAE,mBAAmB,CAAA;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,0BAA0B,EACnC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,CAAC,CA6HvE"}
|