@mailwoman/registry 10.0.0 → 10.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.
- package/README.md +11 -14
- package/lib/address-key.ts +14 -10
- package/lib/geocode-handler.ts +7 -5
- package/lib/geojson.ts +13 -7
- package/lib/ingest.ts +70 -92
- package/lib/learned-scorer.ts +38 -44
- package/lib/map-html.ts +26 -72
- package/lib/models/crosssource-gbt-en-us.ts +9 -7
- package/lib/models/dedup-gbt-en-us.ts +9 -8
- package/lib/models/org-crosssource-gbt-en-us.ts +10 -8
- package/lib/reconcile.ts +45 -54
- package/lib/resolve.ts +187 -130
- package/lib/types.ts +35 -29
- package/out/address-key.d.ts +14 -10
- package/out/address-key.d.ts.map +1 -1
- package/out/address-key.js +14 -10
- package/out/address-key.js.map +1 -1
- package/out/geocode-handler.d.ts +6 -4
- package/out/geocode-handler.d.ts.map +1 -1
- package/out/geocode-handler.js +7 -5
- package/out/geocode-handler.js.map +1 -1
- package/out/geojson.d.ts +9 -5
- package/out/geojson.d.ts.map +1 -1
- package/out/geojson.js +13 -7
- package/out/geojson.js.map +1 -1
- package/out/ingest.d.ts +49 -76
- package/out/ingest.d.ts.map +1 -1
- package/out/ingest.js +37 -62
- package/out/ingest.js.map +1 -1
- package/out/learned-scorer.d.ts +29 -26
- package/out/learned-scorer.d.ts.map +1 -1
- package/out/learned-scorer.js +31 -39
- package/out/learned-scorer.js.map +1 -1
- package/out/map-html.d.ts +13 -32
- package/out/map-html.d.ts.map +1 -1
- package/out/map-html.js +11 -64
- package/out/map-html.js.map +1 -1
- package/out/models/crosssource-gbt-en-us.d.ts +9 -7
- package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/crosssource-gbt-en-us.js +9 -7
- package/out/models/crosssource-gbt-en-us.js.map +1 -1
- package/out/models/dedup-gbt-en-us.d.ts +9 -8
- package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
- package/out/models/dedup-gbt-en-us.js +9 -8
- package/out/models/dedup-gbt-en-us.js.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.d.ts +10 -8
- package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
- package/out/models/org-crosssource-gbt-en-us.js +10 -8
- package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
- package/out/reconcile.d.ts +36 -50
- package/out/reconcile.d.ts.map +1 -1
- package/out/reconcile.js +18 -42
- package/out/reconcile.js.map +1 -1
- package/out/resolve.d.ts +152 -91
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +67 -68
- package/out/resolve.js.map +1 -1
- package/out/tools/coverage-reconciliation.d.ts +23 -23
- package/out/tools/coverage-reconciliation.d.ts.map +1 -1
- package/out/tools/coverage-reconciliation.js +15 -26
- package/out/tools/coverage-reconciliation.js.map +1 -1
- package/out/tools/cross/dataset-correlation.d.ts +23 -27
- package/out/tools/cross/dataset-correlation.d.ts.map +1 -1
- package/out/tools/cross/dataset-correlation.js +9 -61
- package/out/tools/cross/dataset-correlation.js.map +1 -1
- package/out/tools/cross/source-threshold-sweep.d.ts +20 -26
- package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -1
- package/out/tools/cross/source-threshold-sweep.js +14 -40
- package/out/tools/cross/source-threshold-sweep.js.map +1 -1
- package/out/tools/dedup-ceiling.d.ts +23 -26
- package/out/tools/dedup-ceiling.d.ts.map +1 -1
- package/out/tools/dedup-ceiling.js +22 -41
- package/out/tools/dedup-ceiling.js.map +1 -1
- package/out/tools/eval-geocoder.d.ts +25 -16
- package/out/tools/eval-geocoder.d.ts.map +1 -1
- package/out/tools/eval-geocoder.js +5 -6
- package/out/tools/eval-geocoder.js.map +1 -1
- package/out/tools/geocoder/namesake-probe.d.ts +9 -8
- package/out/tools/geocoder/namesake-probe.d.ts.map +1 -1
- package/out/tools/geocoder/namesake-probe.js +6 -7
- package/out/tools/geocoder/namesake-probe.js.map +1 -1
- package/out/tools/geocoder/vs-provided-coords.d.ts +18 -15
- package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -1
- package/out/tools/geocoder/vs-provided-coords.js +30 -27
- package/out/tools/geocoder/vs-provided-coords.js.map +1 -1
- package/out/tools/gold-set-sample.d.ts +27 -18
- package/out/tools/gold-set-sample.d.ts.map +1 -1
- package/out/tools/gold-set-sample.js +18 -22
- package/out/tools/gold-set-sample.js.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.d.ts +30 -27
- package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/clustering-eval.js +28 -38
- package/out/tools/learned/scorer/clustering-eval.js.map +1 -1
- package/out/tools/learned/scorer/crossstate-eval.d.ts +24 -18
- package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/crossstate-eval.js +19 -25
- package/out/tools/learned/scorer/crossstate-eval.js.map +1 -1
- package/out/tools/learned/scorer/eval.d.ts +26 -39
- package/out/tools/learned/scorer/eval.d.ts.map +1 -1
- package/out/tools/learned/scorer/eval.js +11 -71
- package/out/tools/learned/scorer/eval.js.map +1 -1
- package/out/tools/matcher-scale.d.ts +12 -17
- package/out/tools/matcher-scale.d.ts.map +1 -1
- package/out/tools/matcher-scale.js +11 -29
- package/out/tools/matcher-scale.js.map +1 -1
- package/out/tools/nppes/dedup-benchmark.d.ts +22 -41
- package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -1
- package/out/tools/nppes/dedup-benchmark.js +21 -67
- package/out/tools/nppes/dedup-benchmark.js.map +1 -1
- package/out/tools/nppes/org-name.d.ts +5 -11
- package/out/tools/nppes/org-name.d.ts.map +1 -1
- package/out/tools/nppes/org-name.js +2 -9
- package/out/tools/nppes/org-name.js.map +1 -1
- package/out/tools/nppes/overmerge-packet.d.ts +15 -11
- package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
- package/out/tools/nppes/overmerge-packet.js +6 -7
- package/out/tools/nppes/overmerge-packet.js.map +1 -1
- package/out/tools/nppes/report.d.ts +17 -13
- package/out/tools/nppes/report.d.ts.map +1 -1
- package/out/tools/nppes/report.js +6 -14
- package/out/tools/nppes/report.js.map +1 -1
- package/out/tools/nppes/sample.d.ts +29 -18
- package/out/tools/nppes/sample.d.ts.map +1 -1
- package/out/tools/nppes/sample.js +24 -28
- package/out/tools/nppes/sample.js.map +1 -1
- package/out/tools/nppes/scoring.d.ts +7 -6
- package/out/tools/nppes/scoring.d.ts.map +1 -1
- package/out/tools/nppes/scoring.js +6 -5
- package/out/tools/nppes/scoring.js.map +1 -1
- package/out/tools/nppes/settings.d.ts +10 -7
- package/out/tools/nppes/settings.d.ts.map +1 -1
- package/out/tools/nppes/settings.js +16 -16
- package/out/tools/nppes/settings.js.map +1 -1
- package/out/tools/nppes/truth-grains.d.ts +36 -23
- package/out/tools/nppes/truth-grains.d.ts.map +1 -1
- package/out/tools/nppes/truth-grains.js +36 -20
- package/out/tools/nppes/truth-grains.js.map +1 -1
- package/out/tools/shared.d.ts +68 -72
- package/out/tools/shared.d.ts.map +1 -1
- package/out/tools/shared.js +50 -67
- package/out/tools/shared.js.map +1 -1
- package/out/tools/train/cross-gbt.d.ts +37 -26
- package/out/tools/train/cross-gbt.d.ts.map +1 -1
- package/out/tools/train/cross-gbt.js +14 -25
- package/out/tools/train/cross-gbt.js.map +1 -1
- package/out/tools/train/gbt.d.ts +36 -20
- package/out/tools/train/gbt.d.ts.map +1 -1
- package/out/tools/train/gbt.js +27 -31
- package/out/tools/train/gbt.js.map +1 -1
- package/out/tools/train/org-cross-gbt.d.ts +38 -24
- package/out/tools/train/org-cross-gbt.d.ts.map +1 -1
- package/out/tools/train/org-cross-gbt.js +18 -22
- package/out/tools/train/org-cross-gbt.js.map +1 -1
- package/out/tools/txhhsc-to-oarow.d.ts +14 -9
- package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
- package/out/tools/txhhsc-to-oarow.js +16 -15
- package/out/tools/txhhsc-to-oarow.js.map +1 -1
- package/out/tools/viz/browser.d.ts +6 -5
- package/out/tools/viz/browser.d.ts.map +1 -1
- package/out/tools/viz/browser.js +6 -5
- package/out/tools/viz/browser.js.map +1 -1
- package/out/tools/viz/cross-dataset-map.d.ts +7 -4
- package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
- package/out/tools/viz/cross-dataset-map.js +9 -6
- package/out/tools/viz/cross-dataset-map.js.map +1 -1
- package/out/tools/viz/geocode-first-surface.d.ts +11 -5
- package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
- package/out/tools/viz/geocode-first-surface.js +16 -11
- package/out/tools/viz/geocode-first-surface.js.map +1 -1
- package/out/tools/viz/render/map.d.ts +5 -5
- package/out/tools/viz/render/map.d.ts.map +1 -1
- package/out/tools/viz/render/map.js +6 -5
- package/out/tools/viz/render/map.js.map +1 -1
- package/out/tools/viz/{render/index.d.ts → render.d.ts} +13 -9
- package/out/tools/viz/render.d.ts.map +1 -0
- package/out/tools/viz/{render/index.js → render.js} +9 -8
- package/out/tools/viz/render.js.map +1 -0
- package/out/tools/viz/source-provenance-map.d.ts +19 -7
- package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
- package/out/tools/viz/source-provenance-map.js +11 -8
- package/out/tools/viz/source-provenance-map.js.map +1 -1
- package/out/tools/viz/yardstick-figure.d.ts +2 -21
- package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
- package/out/tools/viz/yardstick-figure.js +3 -39
- package/out/tools/viz/yardstick-figure.js.map +1 -1
- package/out/types.d.ts +35 -29
- package/out/types.d.ts.map +1 -1
- package/out/types.js +2 -2
- package/out/types.js.map +1 -1
- package/package.json +42 -185
- package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
- package/{lib/tools → tools}/cross/dataset-correlation.ts +35 -73
- package/{lib/tools → tools}/cross/source-threshold-sweep.ts +29 -46
- package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
- package/tools/eval-geocoder.ts +77 -0
- package/{lib/tools → tools}/geocoder/namesake-probe.ts +9 -8
- package/{lib/tools → tools}/geocoder/vs-provided-coords.ts +40 -31
- package/{lib/tools → tools}/gold-set-sample.ts +35 -29
- package/{lib/tools → tools}/learned/scorer/clustering-eval.ts +49 -45
- package/{lib/tools → tools}/learned/scorer/crossstate-eval.ts +34 -30
- package/{lib/tools → tools}/learned/scorer/eval.ts +39 -78
- package/{lib/tools → tools}/matcher-scale.ts +21 -33
- package/{lib/tools → tools}/nppes/dedup-benchmark.ts +39 -83
- package/tools/nppes/org-name.ts +15 -0
- package/{lib/tools → tools}/nppes/overmerge-packet.ts +16 -12
- package/{lib/tools → tools}/nppes/report.ts +32 -25
- package/{lib/tools → tools}/nppes/sample.ts +43 -38
- package/{lib/tools → tools}/nppes/scoring.ts +7 -6
- package/{lib/tools → tools}/nppes/settings.ts +16 -16
- package/{lib/tools → tools}/nppes/truth-grains.ts +46 -26
- package/{lib/tools → tools}/shared.ts +79 -98
- package/{lib/tools → tools}/train/cross-gbt.ts +39 -34
- package/{lib/tools → tools}/train/gbt.ts +55 -41
- package/{lib/tools → tools}/train/org-cross-gbt.ts +40 -30
- package/{lib/tools → tools}/txhhsc-to-oarow.ts +24 -18
- package/{lib/tools → tools}/viz/browser.ts +6 -5
- package/{lib/tools → tools}/viz/cross-dataset-map.ts +15 -9
- package/{lib/tools → tools}/viz/geocode-first-surface.ts +29 -17
- package/{lib/tools → tools}/viz/render/map.ts +7 -6
- package/{lib/tools/viz/render/index.ts → tools/viz/render.ts} +16 -11
- package/{lib/tools → tools}/viz/source-provenance-map.ts +30 -15
- package/{lib/tools → tools}/viz/yardstick-figure.ts +6 -43
- package/lib/tools/eval-geocoder.ts +0 -67
- package/lib/tools/index.ts +0 -31
- package/lib/tools/nppes/org-name.ts +0 -23
- package/out/tools/index.d.ts +0 -31
- package/out/tools/index.d.ts.map +0 -1
- package/out/tools/index.js +0 -31
- package/out/tools/index.js.map +0 -1
- package/out/tools/viz/render/index.d.ts.map +0 -1
- package/out/tools/viz/render/index.js.map +0 -1
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
* @file
|
|
6
|
-
*
|
|
5
|
+
* @file Defines union-find truth labels that group co-located NPIs for one organization.
|
|
6
|
+
* One label uses address strings. Another uses a haversine radius. The third uses H3 cells.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import type { GeoCoordinate } from "@mailwoman/spatial";
|
|
9
9
|
import type { SourceRecord } from "#index";
|
|
10
10
|
import { type NPIPrimary } from "#tools/nppes/org-name";
|
|
11
11
|
/**
|
|
@@ -13,38 +13,51 @@ import { type NPIPrimary } from "#tools/nppes/org-name";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const COLOCATION_KM = 0.05;
|
|
15
15
|
/**
|
|
16
|
-
* A truth
|
|
16
|
+
* A truth labeling: the entity class a record belongs to.
|
|
17
17
|
*/
|
|
18
18
|
export type TruthLabel = (rec: SourceRecord) => string;
|
|
19
19
|
/**
|
|
20
|
-
* An NPI's primary practice coordinate
|
|
21
|
-
*
|
|
20
|
+
* An NPI's primary practice coordinate.
|
|
21
|
+
*
|
|
22
|
+
* Returns the first geocoded record for the NPI.
|
|
23
|
+
* The sample builder adds this primary row before alternate-name and mailing variants.
|
|
22
24
|
*/
|
|
23
|
-
export declare function collectPrimaryCoordinates(records: readonly SourceRecord[]): Map<string,
|
|
25
|
+
export declare function collectPrimaryCoordinates(records: readonly SourceRecord[]): Map<string, GeoCoordinate>;
|
|
24
26
|
/**
|
|
25
|
-
* The string-keyed org-name truth: same NPI ⇒ same entity
|
|
26
|
-
*
|
|
27
|
+
* The string-keyed org-name truth: same NPI ⇒ same entity
|
|
28
|
+
* (so an NPI's records stay together and recall is preserved), plus union two NPIs
|
|
29
|
+
* at the same address KEY whose primary org names agree.
|
|
30
|
+
*
|
|
31
|
+
* The address-string block provides a conservative lower bound.
|
|
32
|
+
* `1504 Taub loop` and `1504 Taub LP STE 100` key apart even though they are one building,
|
|
33
|
+
* so a correct merge across them is still charged as an error.
|
|
34
|
+
* The coordinate grain below is the tighter reading.
|
|
27
35
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* below is the tighter reading. Neither relies on the NPPES subpart flag, which the gold set showed misses 37%.
|
|
36
|
+
* Neither method uses the NPPES subpart flag.
|
|
37
|
+
* The gold set misses 37% of cases when grouped by that flag.
|
|
31
38
|
*/
|
|
32
39
|
export declare function buildOrgNameGrain(npiPrimary: Map<string, NPIPrimary>): TruthLabel;
|
|
33
40
|
/**
|
|
34
|
-
* The coordinate-keyed org-name truth: union same-org NPIs whose primary practice
|
|
35
|
-
* {@linkcode COLOCATION_KM}.
|
|
36
|
-
* apart, so this F1 is at or above the string grain's; the Jaccard test still blocks distinct co-located orgs.
|
|
41
|
+
* The coordinate-keyed org-name truth: union same-org NPIs whose primary practice
|
|
42
|
+
* coordinates fall within {@linkcode COLOCATION_KM}.
|
|
37
43
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
44
|
+
* A geocoded-building block catches same-building pairs that the address string keys apart,
|
|
45
|
+
* so this F1 is at or above the string grain's.
|
|
46
|
+
* The Jaccard test still blocks distinct co-located orgs.
|
|
47
|
+
*
|
|
48
|
+
* Compares every sampled NPI pair.
|
|
49
|
+
* This is small enough for the sample and has no cell-boundary artifact.
|
|
40
50
|
*/
|
|
41
|
-
export declare function buildOrgNameCoordGrain(npiPrimary: Map<string, NPIPrimary>, npiCoord: Map<string,
|
|
51
|
+
export declare function buildOrgNameCoordGrain(npiPrimary: Map<string, NPIPrimary>, npiCoord: Map<string, GeoCoordinate>): TruthLabel;
|
|
42
52
|
/**
|
|
43
|
-
* The H3-cell org-name truth
|
|
44
|
-
*
|
|
53
|
+
* The H3-cell org-name truth.
|
|
54
|
+
*
|
|
55
|
+
* The same building grain keyed on a cell instead of a radius, so co-location
|
|
56
|
+
* blocking is O(n) rather than O(n²).
|
|
45
57
|
*
|
|
46
|
-
* A robustness check on the coordinate grain
|
|
47
|
-
* into adjacent cells, so this slightly
|
|
58
|
+
* A robustness check on the coordinate grain rather than a replacement: a hard cell boundary can split
|
|
59
|
+
* a same-building pair into adjacent cells, so this slightly under-counts relative to the radius.
|
|
60
|
+
* Coarser resolutions absorb more of that.
|
|
48
61
|
*/
|
|
49
|
-
export declare function buildOrgNameH3Grain(npiPrimary: Map<string, NPIPrimary>, npiCoord: Map<string,
|
|
62
|
+
export declare function buildOrgNameH3Grain(npiPrimary: Map<string, NPIPrimary>, npiCoord: Map<string, GeoCoordinate>, h3Res: number): TruthLabel;
|
|
50
63
|
//# sourceMappingURL=truth-grains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truth-grains.d.ts","sourceRoot":"","sources":["../../../
|
|
1
|
+
{"version":3,"file":"truth-grains.d.ts","sourceRoot":"","sources":["../../../tools/nppes/truth-grains.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,aAAa,OAAO,CAAA;AAEjC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAA;AA2BtD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAYtG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,CAoBjF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAClC,UAAU,CAuBZ;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EACpC,KAAK,EAAE,MAAM,GACX,UAAU,CAqBZ"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
* @file
|
|
6
|
-
*
|
|
5
|
+
* @file Defines union-find truth labels that group co-located NPIs for one organization.
|
|
6
|
+
* One label uses address strings. Another uses a haversine radius. The third uses H3 cells.
|
|
7
7
|
*/
|
|
8
8
|
import { createUnionFind } from "@mailwoman/core/utils";
|
|
9
9
|
import { haversineKm, jaccard } from "@mailwoman/match";
|
|
@@ -16,8 +16,11 @@ export const COLOCATION_KM = 0.05;
|
|
|
16
16
|
/**
|
|
17
17
|
* Union every pair in each block whose org names agree.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Checks every pair within a block.
|
|
20
|
+
* This preserves the per-pair Jaccard test.
|
|
21
|
+
*
|
|
22
|
+
* Therefore, a chain of near-matches cannot transitively fuse two genuinely distinct
|
|
23
|
+
* co-located orgs unless some pair actually agrees.
|
|
21
24
|
*/
|
|
22
25
|
function unionAgreeingPairs(blocks, npiPrimary, uf) {
|
|
23
26
|
for (const group of blocks) {
|
|
@@ -31,8 +34,10 @@ function unionAgreeingPairs(blocks, npiPrimary, uf) {
|
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
|
-
* An NPI's primary practice coordinate
|
|
35
|
-
*
|
|
37
|
+
* An NPI's primary practice coordinate.
|
|
38
|
+
*
|
|
39
|
+
* Returns the first geocoded record for the NPI.
|
|
40
|
+
* The sample builder adds this primary row before alternate-name and mailing variants.
|
|
36
41
|
*/
|
|
37
42
|
export function collectPrimaryCoordinates(records) {
|
|
38
43
|
const npiCoord = new Map();
|
|
@@ -45,12 +50,17 @@ export function collectPrimaryCoordinates(records) {
|
|
|
45
50
|
return npiCoord;
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
|
-
* The string-keyed org-name truth: same NPI ⇒ same entity
|
|
49
|
-
*
|
|
53
|
+
* The string-keyed org-name truth: same NPI ⇒ same entity
|
|
54
|
+
* (so an NPI's records stay together and recall is preserved), plus union two NPIs
|
|
55
|
+
* at the same address KEY whose primary org names agree.
|
|
56
|
+
*
|
|
57
|
+
* The address-string block provides a conservative lower bound.
|
|
58
|
+
* `1504 Taub loop` and `1504 Taub LP STE 100` key apart even though they are one building,
|
|
59
|
+
* so a correct merge across them is still charged as an error.
|
|
60
|
+
* The coordinate grain below is the tighter reading.
|
|
50
61
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* below is the tighter reading. Neither relies on the NPPES subpart flag, which the gold set showed misses 37%.
|
|
62
|
+
* Neither method uses the NPPES subpart flag.
|
|
63
|
+
* The gold set misses 37% of cases when grouped by that flag.
|
|
54
64
|
*/
|
|
55
65
|
export function buildOrgNameGrain(npiPrimary) {
|
|
56
66
|
const uf = createUnionFind();
|
|
@@ -69,12 +79,15 @@ export function buildOrgNameGrain(npiPrimary) {
|
|
|
69
79
|
return (rec) => (npiPrimary.has(rec.id) ? uf.find(rec.id) : rec.id);
|
|
70
80
|
}
|
|
71
81
|
/**
|
|
72
|
-
* The coordinate-keyed org-name truth: union same-org NPIs whose primary practice
|
|
73
|
-
* {@linkcode COLOCATION_KM}.
|
|
74
|
-
* apart, so this F1 is at or above the string grain's; the Jaccard test still blocks distinct co-located orgs.
|
|
82
|
+
* The coordinate-keyed org-name truth: union same-org NPIs whose primary practice
|
|
83
|
+
* coordinates fall within {@linkcode COLOCATION_KM}.
|
|
75
84
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
85
|
+
* A geocoded-building block catches same-building pairs that the address string keys apart,
|
|
86
|
+
* so this F1 is at or above the string grain's.
|
|
87
|
+
* The Jaccard test still blocks distinct co-located orgs.
|
|
88
|
+
*
|
|
89
|
+
* Compares every sampled NPI pair.
|
|
90
|
+
* This is small enough for the sample and has no cell-boundary artifact.
|
|
78
91
|
*/
|
|
79
92
|
export function buildOrgNameCoordGrain(npiPrimary, npiCoord) {
|
|
80
93
|
const uf = createUnionFind();
|
|
@@ -97,11 +110,14 @@ export function buildOrgNameCoordGrain(npiPrimary, npiCoord) {
|
|
|
97
110
|
return (rec) => (npiPrimary.has(rec.id) ? uf.find(rec.id) : rec.id);
|
|
98
111
|
}
|
|
99
112
|
/**
|
|
100
|
-
* The H3-cell org-name truth
|
|
101
|
-
*
|
|
113
|
+
* The H3-cell org-name truth.
|
|
114
|
+
*
|
|
115
|
+
* The same building grain keyed on a cell instead of a radius, so co-location
|
|
116
|
+
* blocking is O(n) rather than O(n²).
|
|
102
117
|
*
|
|
103
|
-
* A robustness check on the coordinate grain
|
|
104
|
-
* into adjacent cells, so this slightly
|
|
118
|
+
* A robustness check on the coordinate grain rather than a replacement: a hard cell boundary can split
|
|
119
|
+
* a same-building pair into adjacent cells, so this slightly under-counts relative to the radius.
|
|
120
|
+
* Coarser resolutions absorb more of that.
|
|
105
121
|
*/
|
|
106
122
|
export function buildOrgNameH3Grain(npiPrimary, npiCoord, h3Res) {
|
|
107
123
|
const uf = createUnionFind();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truth-grains.js","sourceRoot":"","sources":["../../../
|
|
1
|
+
{"version":3,"file":"truth-grains.js","sourceRoot":"","sources":["../../../tools/nppes/truth-grains.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAkB,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAE,YAAY,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MAAM,GAAG,IAAI,GAAG,EAAoB,CAAA;IAE1C,KAAK,MAAM,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QACnC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAC,oDAAoD;QAC/D,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QAEzB,IAAI,CAAC,CAAC;YAAE,SAAQ;QAChB,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAEzD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QACrB,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;IAED,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;IAEnD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACpE,CAAC"}
|
package/out/tools/shared.d.ts
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Shared helpers
|
|
7
|
-
*
|
|
8
|
-
* The rule: anything reused by two or more probes belongs here; anything a single probe needs
|
|
9
|
-
* stays with that probe.
|
|
6
|
+
* Shared helpers used by two or more probes in the `registry/tools` probe battery.
|
|
10
7
|
*/
|
|
11
|
-
import { type TermFrequencyTable } from "@mailwoman/match";
|
|
8
|
+
import { type GBTOpts, type TermFrequencyTable } from "@mailwoman/match";
|
|
12
9
|
import { type ColumnMapping } from "#index";
|
|
13
10
|
import type { EvalGeocoderFactory } from "#tools/eval-geocoder";
|
|
14
11
|
import type { Score } from "#tools/nppes/scoring";
|
|
15
12
|
/**
|
|
16
|
-
* One source a cross-source probe ingests
|
|
13
|
+
* One source a cross-source probe ingests.
|
|
14
|
+
*
|
|
15
|
+
* Its spec gives the path and column mapping.
|
|
16
|
+
* The spec also provides an in-state filter.
|
|
17
17
|
*/
|
|
18
18
|
export interface SourceSpec {
|
|
19
19
|
source: string;
|
|
@@ -24,20 +24,19 @@ export interface SourceSpec {
|
|
|
24
24
|
*/
|
|
25
25
|
inState: (row: Record<string, string>) => boolean;
|
|
26
26
|
/**
|
|
27
|
-
* Optional: a row
|
|
27
|
+
* Optional: a row carrying ≥1 addressable entity yields each as its own row.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue identity.
|
|
28
30
|
*/
|
|
29
31
|
explode?: (row: Record<string, string>) => Record<string, string>[];
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
* Trim, treating `undefined` as empty — the shape every probe's raw CSV columns arrive in.
|
|
34
|
+
* Trim, treating `null` or `undefined` as empty — the shape every probe's raw CSV columns arrive in.
|
|
33
35
|
*/
|
|
34
|
-
export declare const norm: (s: string | undefined) => string;
|
|
36
|
+
export declare const norm: (s: string | null | undefined) => string;
|
|
35
37
|
/**
|
|
36
|
-
* The token set of an organization name
|
|
37
|
-
*
|
|
38
|
-
* NOT a canonical form — `@mailwoman/record`'s `canonicalizeOrganizationName` is the stronger canonical key
|
|
39
|
-
* (jurisdiction-aware designation stripping, a DBA split). This set serves the probes' cheap Jaccard overlap over raw
|
|
40
|
-
* registry names, never blocking or display.
|
|
38
|
+
* The token set of an organization name for the probes' cheap Jaccard overlap,
|
|
39
|
+
* never blocking or display — not a canonical form.
|
|
41
40
|
*/
|
|
42
41
|
export declare function orgTokens(s: string): Set<string>;
|
|
43
42
|
/**
|
|
@@ -45,17 +44,23 @@ export declare function orgTokens(s: string): Set<string>;
|
|
|
45
44
|
*/
|
|
46
45
|
export declare const addr: (line: string, city: string, st: string, zip: string) => string;
|
|
47
46
|
/**
|
|
48
|
-
* Population standard deviation; `0` on an empty sample, because these feed
|
|
47
|
+
* Population standard deviation; `0` on an empty sample, because these feed
|
|
48
|
+
* report tables that print a number per row.
|
|
49
49
|
*/
|
|
50
50
|
export declare const std: (xs: readonly number[]) => number;
|
|
51
|
+
/**
|
|
52
|
+
* Takes a fraction and omits the percent sign, unlike core `formatPercent`'s
|
|
53
|
+
* numerator/denominator interface.
|
|
54
|
+
* Call sites append their own `%`.
|
|
55
|
+
*/
|
|
51
56
|
export declare const pct: (x: number) => string;
|
|
52
57
|
/**
|
|
53
|
-
* Sign prefix for a signed delta
|
|
58
|
+
* Sign prefix for a signed delta: `"+"` for a non-negative value, since a negative one includes its sign.
|
|
54
59
|
*/
|
|
55
60
|
export declare const sgn: (x: number) => string;
|
|
56
61
|
/**
|
|
57
|
-
* Logistic function with the input clamped to
|
|
58
|
-
* silently becomes a no-op.
|
|
62
|
+
* Logistic function with the input clamped to ±30, past which `Math.exp` underflows to 0
|
|
63
|
+
* and the gradient step silently becomes a no-op.
|
|
59
64
|
*/
|
|
60
65
|
export declare const sigmoid: (z: number) => number;
|
|
61
66
|
/**
|
|
@@ -78,14 +83,8 @@ export declare const TX_BBOX: {
|
|
|
78
83
|
*/
|
|
79
84
|
export declare const inTXBBOX: (lat: number, lon: number) => boolean;
|
|
80
85
|
/**
|
|
81
|
-
* NPPES registry column headers, by the short name the probes read them under.
|
|
82
|
-
*
|
|
83
|
-
* The NPI registry export is a ~330-column TSV with headers this long, so every probe that touches it needs this map,
|
|
84
|
-
* and five of them had grown their own copy. The copies were a NESTED SUPERSET chain, not a disagreement -- each new
|
|
85
|
-
* probe took the previous one's map and appended what it additionally read -- so this is the widest of the five, and no
|
|
86
|
-
* consumer loses a column. Reading extra keys costs nothing: they are inert strings, and nothing enumerates this object
|
|
87
|
-
* (checked: no `Object.keys`/`values`/`entries`/spread over it anywhere in `tools/`), so adding a column can never
|
|
88
|
-
* change a probe's behavior.
|
|
86
|
+
* NPPES registry column headers, by the short name the probes read them under. no code
|
|
87
|
+
* enumerates this object, so adding a column cannot change a probe's behavior.
|
|
89
88
|
*/
|
|
90
89
|
export declare const NPPES_COLUMNS: {
|
|
91
90
|
npi: string;
|
|
@@ -115,12 +114,13 @@ export declare const NPPES_COLUMNS: {
|
|
|
115
114
|
*/
|
|
116
115
|
export declare const MIN_GROUP_SIZE = 5;
|
|
117
116
|
/**
|
|
118
|
-
* Gradient-descent epochs for {@link trainLogisticRegression}
|
|
117
|
+
* Gradient-descent epochs for {@link trainLogisticRegression}, fixed
|
|
118
|
+
* rather than early-stopped so seeds stay comparable.
|
|
119
119
|
*/
|
|
120
120
|
export declare const TRAINING_EPOCHS = 400;
|
|
121
121
|
/**
|
|
122
|
-
* Smallest mean F1 gap counted as a real difference between models rather than seed
|
|
123
|
-
* reported as a tie.
|
|
122
|
+
* Smallest mean F1 gap counted as a real difference between models rather than seed
|
|
123
|
+
* noise. verdicts inside ±this are reported as a tie.
|
|
124
124
|
*/
|
|
125
125
|
export declare const MIN_MEANINGFUL_F1_DELTA = 0.02;
|
|
126
126
|
/**
|
|
@@ -132,20 +132,22 @@ export declare const LR_LEARNING_RATE = 0.1;
|
|
|
132
132
|
*/
|
|
133
133
|
export declare const LR_L2 = 0.001;
|
|
134
134
|
/**
|
|
135
|
-
* L2-regularized logistic regression by batch gradient descent
|
|
136
|
-
*
|
|
137
|
-
*
|
|
135
|
+
* L2-regularized logistic regression by batch gradient descent over {@link TRAINING_EPOCHS}
|
|
136
|
+
* epochs, where `w` stores per-sample class weights, returning the logit rather than
|
|
137
|
+
* the probability so it is threshold-comparable across a fixed feature layout.
|
|
138
138
|
*/
|
|
139
139
|
export declare function trainLogisticRegression(X: readonly (readonly number[])[], y: readonly number[], w: readonly number[], dim: number): (x: readonly number[]) => number;
|
|
140
140
|
/**
|
|
141
|
-
* `n + 1` evenly-spaced order statistics of an already-sorted sample, de-duplicated
|
|
142
|
-
* GBT node considers
|
|
143
|
-
*
|
|
141
|
+
* `n + 1` evenly-spaced order statistics of an already-sorted sample, de-duplicated,
|
|
142
|
+
* that a GBT node considers as candidate splits.
|
|
143
|
+
*
|
|
144
|
+
* An empty sample yields `[0]` so a degenerate feature still yields one threshold
|
|
145
|
+
* rather than an empty split set.
|
|
144
146
|
*/
|
|
145
147
|
export declare function uniqueQuantiles(sorted: readonly number[], n: number): number[];
|
|
146
148
|
/**
|
|
147
|
-
* Link-threshold candidates for a learned scorer: de-duplicated quantiles of the
|
|
148
|
-
* distribution across the 0.2–0.999
|
|
149
|
+
* Link-threshold candidates for a learned scorer: de-duplicated quantiles of the
|
|
150
|
+
* scorer's own eval-pair score distribution across the 0.2–0.999 band.
|
|
149
151
|
*/
|
|
150
152
|
export declare const quantileThresholds: (scores: readonly number[]) => number[];
|
|
151
153
|
/**
|
|
@@ -166,19 +168,18 @@ export declare const toArmScore: (s: Score) => ArmScore;
|
|
|
166
168
|
*/
|
|
167
169
|
export declare function bestOver(thresholds: readonly number[], scoreAt: (threshold: number) => ArmScore): ArmScore;
|
|
168
170
|
/**
|
|
169
|
-
* One organization provider at its practice address, as the geocode-free co-location probes read it
|
|
170
|
-
* `dedup-ceiling` and `gold-set-sample` each collect.
|
|
171
|
+
* One organization provider at its practice address, as the geocode-free co-location probes read it.
|
|
171
172
|
*/
|
|
172
173
|
export interface ColocatedProvider {
|
|
173
174
|
npi: string;
|
|
174
175
|
org: string;
|
|
175
176
|
tokens: Set<string>;
|
|
176
177
|
/**
|
|
177
|
-
* The composed practice address ({@link addr})
|
|
178
|
+
* The composed practice address ({@link addr}).
|
|
178
179
|
*/
|
|
179
180
|
address: string;
|
|
180
181
|
/**
|
|
181
|
-
* Strict last-10-digit phone key; `""` when the column
|
|
182
|
+
* Strict last-10-digit phone key; `""` when the column contains fewer than 10 digits.
|
|
182
183
|
*/
|
|
183
184
|
phone: string;
|
|
184
185
|
/**
|
|
@@ -191,7 +192,7 @@ export interface ColocatedProvider {
|
|
|
191
192
|
taxonomy: string;
|
|
192
193
|
subpart: boolean;
|
|
193
194
|
/**
|
|
194
|
-
* `parentLBN|parentTIN`, lowercased
|
|
195
|
+
* `parentLBN|parentTIN`, lowercased; `"|"` when both are blank.
|
|
195
196
|
*/
|
|
196
197
|
parent: string;
|
|
197
198
|
}
|
|
@@ -207,8 +208,9 @@ export interface ColocatedScan {
|
|
|
207
208
|
scanned: number;
|
|
208
209
|
}
|
|
209
210
|
/**
|
|
210
|
-
* Stream in-state type-2 (organization) providers from the registry
|
|
211
|
-
*
|
|
211
|
+
* Stream in-state type-2 (organization) providers from the registry,
|
|
212
|
+
* one record per row at its practice address, grouped by `addressFrequencyKey`;
|
|
213
|
+
* geocode-free on purpose so it runs at large caps in seconds.
|
|
212
214
|
*/
|
|
213
215
|
export declare function scanColocatedProviders(options: {
|
|
214
216
|
registryPath: string;
|
|
@@ -222,33 +224,25 @@ export interface ColocatedPair {
|
|
|
222
224
|
a: ColocatedProvider;
|
|
223
225
|
b: ColocatedProvider;
|
|
224
226
|
/**
|
|
225
|
-
* The distinct-NPI providers at the shared address, length ≥ 2
|
|
226
|
-
* group
|
|
227
|
+
* The distinct-NPI providers at the shared address, length ≥ 2, one array reference
|
|
228
|
+
* per group so a consumer can detect the group boundary by identity.
|
|
227
229
|
*/
|
|
228
230
|
group: readonly ColocatedProvider[];
|
|
229
231
|
}
|
|
230
232
|
/**
|
|
231
|
-
* Every unordered pair of
|
|
232
|
-
*
|
|
233
|
+
* Every unordered pair of distinct NPIs sharing a practice-address key, de-duplicated
|
|
234
|
+
* per address by NPI (first record wins) so single-NPI addresses yield no pair.
|
|
233
235
|
*/
|
|
234
236
|
export declare function colocatedDistinctPairs(byAddr: ReadonlyMap<string, readonly ColocatedProvider[]>): Generator<ColocatedPair>;
|
|
235
237
|
/**
|
|
236
|
-
* The TX facility source specs the cross-source probes share.
|
|
237
|
-
* commitments spec (the exploded two-entity-per-row source).
|
|
238
|
+
* The TX facility source specs the cross-source probes share.
|
|
238
239
|
*/
|
|
239
240
|
export declare const buildSpecs: (S: string, STATE: string) => SourceSpec[];
|
|
240
241
|
/**
|
|
241
|
-
*
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
depth: number;
|
|
246
|
-
lr: number;
|
|
247
|
-
minLeaf: number;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* One assembled input row for a cross-source trainer. `npi` carries the cross-system join key (an NPI or a CCN) — it
|
|
251
|
-
* rides `record.id` as the held-out label.
|
|
242
|
+
* One assembled input row for a cross-source trainer.
|
|
243
|
+
*
|
|
244
|
+
* Its `npi` field contains the cross-system join key (an NPI or a CCN).
|
|
245
|
+
* The trainer copies that key into `record.id` as the held-out label.
|
|
252
246
|
*/
|
|
253
247
|
export interface CrossSourceRow extends Record<string, string> {
|
|
254
248
|
npi: string;
|
|
@@ -258,7 +252,7 @@ export interface CrossSourceRow extends Record<string, string> {
|
|
|
258
252
|
source: string;
|
|
259
253
|
}
|
|
260
254
|
/**
|
|
261
|
-
* Every figure
|
|
255
|
+
* Every figure passed to {@link TrainCrossSourceModelOptions.meta}.
|
|
262
256
|
*/
|
|
263
257
|
export interface CrossSourceTrainingFigures {
|
|
264
258
|
records: number;
|
|
@@ -268,7 +262,7 @@ export interface CrossSourceTrainingFigures {
|
|
|
268
262
|
f1Max: number;
|
|
269
263
|
recommendedThreshold: number;
|
|
270
264
|
features: number;
|
|
271
|
-
hyperparams:
|
|
265
|
+
hyperparams: GBTOpts;
|
|
272
266
|
}
|
|
273
267
|
/**
|
|
274
268
|
* Options for {@linkcode trainCrossSourceModel}.
|
|
@@ -279,11 +273,12 @@ export interface TrainCrossSourceModelOptions {
|
|
|
279
273
|
*/
|
|
280
274
|
createGeocoder: EvalGeocoderFactory;
|
|
281
275
|
/**
|
|
282
|
-
* The assembled two-source rows
|
|
276
|
+
* The assembled two-source rows.
|
|
277
|
+
* The caller owns source loading.
|
|
283
278
|
*/
|
|
284
279
|
rows: readonly CrossSourceRow[];
|
|
285
280
|
/**
|
|
286
|
-
* The join keys present in
|
|
281
|
+
* The join keys present in both sources.
|
|
287
282
|
*/
|
|
288
283
|
joined: ReadonlySet<string>;
|
|
289
284
|
addressFrequency: TermFrequencyTable;
|
|
@@ -292,7 +287,7 @@ export interface TrainCrossSourceModelOptions {
|
|
|
292
287
|
*/
|
|
293
288
|
sources: readonly [string, string];
|
|
294
289
|
/**
|
|
295
|
-
*
|
|
290
|
+
* Max cross-source recall subject to this held-out pairwise precision.
|
|
296
291
|
*/
|
|
297
292
|
precisionBar: number;
|
|
298
293
|
/**
|
|
@@ -308,17 +303,18 @@ export interface TrainCrossSourceModelOptions {
|
|
|
308
303
|
*/
|
|
309
304
|
exportPrefix: string;
|
|
310
305
|
/**
|
|
311
|
-
* Assemble the emitted `<prefix>_META` object.
|
|
312
|
-
*
|
|
306
|
+
* Assemble the emitted `<prefix>_META` object.
|
|
307
|
+
*
|
|
308
|
+
* The caller owns field names and order so a retrain diffs cleanly against its committed module.
|
|
313
309
|
*/
|
|
314
310
|
meta: (figures: CrossSourceTrainingFigures) => Record<string, unknown>;
|
|
315
311
|
report?: (line: string) => void;
|
|
316
312
|
}
|
|
317
313
|
/**
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
* inference
|
|
321
|
-
* and emit
|
|
314
|
+
* Geocode and ingest each source under its own provenance label, block the union,
|
|
315
|
+
* keep only cross-source candidate pairs, featurize with `createMatchFeaturizer` so train
|
|
316
|
+
* and inference agree, calibrate the threshold on a held-out split of the join keys,
|
|
317
|
+
* then train and emit the shipped model as a committed TS module.
|
|
322
318
|
*/
|
|
323
319
|
export declare function trainCrossSourceModel(options: TrainCrossSourceModelOptions): Promise<{
|
|
324
320
|
out: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../tools/shared.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAA6B,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAGnG,OAAO,EAQN,KAAK,aAAa,EAElB,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,aAAa,CAAA;IACtB;;OAEG;IACH,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO,CAAA;IACjD;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;CACnE;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,MAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAA0B,CAAA;AAwB9E;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAQhD;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,SAAU,MAAM,QAAQ,MAAM,MAAM,MAAM,OAAO,MAAM,KAAG,MACA,CAAA;AAE3E;;;GAGG;AACH,eAAO,MAAM,GAAG,OAAQ,SAAS,MAAM,EAAE,KAAG,MAI3C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,GAAG,MAAO,MAAM,KAAG,MAA8B,CAAA;AAE9D;;GAEG;AACH,e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