@mailwoman/record 10.0.0 → 10.1.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 +14 -14
- package/lib/address.ts +41 -50
- package/lib/name.ts +42 -24
- package/lib/organization.ts +42 -68
- package/out/address.d.ts +29 -47
- package/out/address.d.ts.map +1 -1
- package/out/address.js +6 -17
- package/out/address.js.map +1 -1
- package/out/name.d.ts +19 -12
- package/out/name.d.ts.map +1 -1
- package/out/name.js +33 -44
- package/out/name.js.map +1 -1
- package/out/organization.d.ts +23 -47
- package/out/organization.d.ts.map +1 -1
- package/out/organization.js +26 -59
- package/out/organization.js.map +1 -1
- package/package.json +16 -38
package/out/organization.js
CHANGED
|
@@ -3,48 +3,17 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `Corporation`, `Limited`, `LLC`) are normalized away before matching, so `Acme Corp` and `Acme
|
|
10
|
-
* Corporation, LLC` collapse to the same key. We also split off a `doing business as` clause and
|
|
11
|
-
* normalize connectives (`&` → `and`), punctuation, accents, and a leading `The`.
|
|
12
|
-
*
|
|
13
|
-
* **The collision problem (#668).** A legal-form token in one jurisdiction is a meaningful word in
|
|
14
|
-
* another domain. `PT` is Indonesia's `Perseroan Terbatas` (its LLC) — and US-healthcare
|
|
15
|
-
* shorthand for _Physical Therapy_. `SCA` / `SCS` are French/Belgian/Luxembourg commandite forms
|
|
16
|
-
* — and, in a clinic's name, _Sudden Cardiac Arrest_ / _Spinal Cord Stimulator_. A single
|
|
17
|
-
* universal strip-list can't be right for both: strip `PT` and you corrupt `Lakeside PT`; keep it
|
|
18
|
-
* and you leave the legal form on an Indonesian company. So the strip-set is computed on **two
|
|
19
|
-
* axes**:
|
|
20
|
-
*
|
|
21
|
-
* - **jurisdiction** (ISO 3166-1 alpha-2, e.g. from the resolved address country) — _adds_ the legal
|
|
22
|
-
* forms valid in that country. Collision-prone forms (`pt`, `sca`, `scs`) live here, admitted only
|
|
23
|
-
* behind a known jurisdiction, NOT in the universal base.
|
|
24
|
-
* - **domain** (an ingest-config tag, e.g. `healthcare`) — _protects_ domain-meaningful tokens from
|
|
25
|
-
* ever being stripped, even when a jurisdiction pack would add them. Domain protection wins.
|
|
26
|
-
*
|
|
27
|
-
* `effective = (base ∪ jurisdiction-pack) − domain-protect-pack`. With no options the set is the
|
|
28
|
-
* universal base and behavior is byte-for-byte unchanged — the new axes are strictly opt-in.
|
|
29
|
-
*
|
|
30
|
-
* Evidence honesty (per the name-canonicalization research pass): the PERSON-name side is well
|
|
31
|
-
* sourced; the ORGANIZATION side is a known evidence gap. This is a solid _canonicalization_
|
|
32
|
-
* baseline (the strip-designations principle is Winkler-grounded; the designation list draws on
|
|
33
|
-
* the ISO 20275 Entity Legal Forms register and `cleanco`). The jurisdiction/domain packs below
|
|
34
|
-
* are grounded seeds, not exhaustive — extend them per ISO 20275 as locales are added. The harder
|
|
35
|
-
* org-_matching_ problems — acronym ↔ expansion (`IBM` ↔ `International Business Machines`),
|
|
36
|
-
* DBA/alias resolution beyond the simple clause, subsidiary/parent, and TF-IDF n-gram token
|
|
37
|
-
* matching — are deferred to a follow-up (a dedicated org-matching research pass + the matcher
|
|
38
|
-
* epic).
|
|
6
|
+
* Canonicalizes organization names by removing legal designations. It normalizes DBA clauses plus punctuation and accents.
|
|
7
|
+
* It also folds connectives and leading articles. Jurisdiction adds local legal forms. Domain rules preserve
|
|
8
|
+
* ambiguous terms that could otherwise be stripped.
|
|
39
9
|
*/
|
|
40
|
-
import { foldForKey } from "@mailwoman/codex/address
|
|
10
|
+
import { foldForKey } from "@mailwoman/codex/address/key";
|
|
41
11
|
/**
|
|
42
|
-
* Universal legal-entity designations
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* jurisdiction.
|
|
12
|
+
* Universal legal-entity designations, normalized to lowercase without punctuation
|
|
13
|
+
* and stripped as whole tokens.
|
|
14
|
+
*
|
|
15
|
+
* Name-meaningful words and the collision-prone forms that live in
|
|
16
|
+
* {@link JURISDICTION_DESIGNATIONS} are deliberately absent.
|
|
48
17
|
*/
|
|
49
18
|
const BASE_DESIGNATIONS = new Set([
|
|
50
19
|
"inc",
|
|
@@ -96,15 +65,13 @@ const BASE_DESIGNATIONS = new Set([
|
|
|
96
65
|
"doo",
|
|
97
66
|
"ood",
|
|
98
67
|
"ead",
|
|
99
|
-
// Belgian forms
|
|
68
|
+
// Belgian forms, safe in the base because they collide with no domain.
|
|
100
69
|
"bvba",
|
|
101
70
|
"sprl",
|
|
102
71
|
]);
|
|
103
72
|
/**
|
|
104
|
-
* Jurisdiction-conditional legal forms (ISO 3166-1 alpha-2 → forms)
|
|
105
|
-
*
|
|
106
|
-
* Stripping these is correct ONLY when we know the org's country — never in the universal base. Grounded seeds, not
|
|
107
|
-
* exhaustive; extend per ISO 20275.
|
|
73
|
+
* Jurisdiction-conditional legal forms (ISO 3166-1 alpha-2 → forms) added only when the jurisdiction
|
|
74
|
+
* is known, holding the collision-prone tokens (`pt`, `sca`, `scs`) that the base must not strip.
|
|
108
75
|
*/
|
|
109
76
|
const JURISDICTION_DESIGNATIONS = {
|
|
110
77
|
ID: ["pt", "tbk", "ud"], // Perseroan Terbatas / Terbuka (listed) / Usaha Dagang
|
|
@@ -115,19 +82,18 @@ const JURISDICTION_DESIGNATIONS = {
|
|
|
115
82
|
IT: ["sapa", "snc"], // S.a.p.a. (commandite par actions) / società in nome collettivo
|
|
116
83
|
};
|
|
117
84
|
/**
|
|
118
|
-
* Domain
|
|
119
|
-
*
|
|
120
|
-
* collide with jurisdiction-conditional legal forms — `pt` (Physical Therapy), `sca` (Sudden Cardiac Arrest), `scs`
|
|
121
|
-
* (Spinal Cord Stimulator) — plus a couple of always-clinical ones for future-proofing.
|
|
85
|
+
* Domain guard-sets (domain → tokens never stripped) that override any jurisdiction pack,
|
|
86
|
+
* e.g. `healthcare` keeps `pt`, `sca`, and `scs` from being stripped as legal forms.
|
|
122
87
|
*/
|
|
123
88
|
const DOMAIN_PROTECTED = {
|
|
124
89
|
general: [],
|
|
125
90
|
healthcare: ["pt", "sca", "scs", "ot", "dpt"],
|
|
126
91
|
};
|
|
127
92
|
/**
|
|
128
|
-
* Compute the effective
|
|
129
|
-
*
|
|
130
|
-
* the
|
|
93
|
+
* Compute the effective strip-set `(base ∪ jurisdiction-pack) − domain-guard-pack`.
|
|
94
|
+
*
|
|
95
|
+
* @returns the shared base set unchanged when no context is given (the byte-stable default),
|
|
96
|
+
* so the common path allocates no set.
|
|
131
97
|
*/
|
|
132
98
|
function resolveDesignations(options) {
|
|
133
99
|
const jurisdiction = options?.jurisdiction?.trim().toUpperCase();
|
|
@@ -153,8 +119,10 @@ function resolveDesignations(options) {
|
|
|
153
119
|
*/
|
|
154
120
|
const DBA_PATTERN = /\s+(?:d\/b\/a|dba|doing business as|t\/a|trading as|a\/k\/a|aka|fka|f\/k\/a)\s+/i;
|
|
155
121
|
/**
|
|
156
|
-
* Canonicalize one name fragment: lowercase, strip accents, connectives → `and`,
|
|
157
|
-
* `the`, strip legal designations, collapse whitespace.
|
|
122
|
+
* Canonicalize one name fragment: lowercase, strip accents, connectives → `and`,
|
|
123
|
+
* drop punctuation, remove a leading `the`, strip legal designations, collapse whitespace.
|
|
124
|
+
*
|
|
125
|
+
* @returns the key plus the designations it removed.
|
|
158
126
|
*/
|
|
159
127
|
function canonicalizeFragment(fragment, designationSet) {
|
|
160
128
|
const normalized = foldForKey(fragment, { ampersand: "and", dropPeriods: true }).replace(/^the\s+/, "");
|
|
@@ -173,12 +141,11 @@ function canonicalizeFragment(fragment, designationSet) {
|
|
|
173
141
|
return { canonical: kept.join(" "), designations };
|
|
174
142
|
}
|
|
175
143
|
/**
|
|
176
|
-
* Canonicalize an organization name: split off any `doing business as` clause,
|
|
177
|
-
*
|
|
144
|
+
* Canonicalize an organization name: split off any `doing business as` clause,
|
|
145
|
+
* then reduce the legal name to a designation-stripped key.
|
|
178
146
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* used and the result is byte-for-byte the legacy behavior.
|
|
147
|
+
* Returns `null` for empty input. {@link CanonicalizeOptions} resolves conflicts
|
|
148
|
+
* between jurisdiction and domain rules.
|
|
182
149
|
*/
|
|
183
150
|
export function canonicalizeOrganizationName(input, options) {
|
|
184
151
|
if (typeof input !== "string" || !input.trim())
|
package/out/organization.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.js","sourceRoot":"","sources":["../lib/organization.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"organization.js","sourceRoot":"","sources":["../lib/organization.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAuDzD;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IACjC,KAAK;IACL,cAAc;IACd,MAAM;IACN,aAAa;IACb,IAAI;IACJ,SAAS;IACT,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,IAAI;IACJ,KAAK;IACL,SAAS;IACT,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,IAAI;IACJ,MAAM;IACN,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,KAAK;IACL,aAAa;IACb,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,uEAAuE;IACvE,MAAM;IACN,MAAM;CACN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mB,CAAC,OAAO,CAAC,CAAA;IACnD,MAAM,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IAEzD,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,oBAAoB,CAAC,SAAS,IAAI,EAAE,EAAE,cAAc,CAAC,CAAA;IAEzF,MAAM,MAAM,GAAqB,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA;IAEjE,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC,SAAS,CAAA;QAE9E,IAAI,GAAG,EAAE,CAAC;YACT,MAAM,CAAC,GAAG,GAAG,GAAG,CAAA;QACjB,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAA;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/record",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "Lean, plain-TypeScript record schema + per-field normalizers for the geocode-first matcher. Address-first: the canonical PostalAddress record composes parser components, the formatter's match key, and a resolved geocode; organization + contact records build on the same canonical record.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
@@ -13,15 +13,10 @@
|
|
|
13
13
|
"out/**/*.js.map",
|
|
14
14
|
"out/**/*.d.ts",
|
|
15
15
|
"out/**/*.d.ts.map",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"**/*.ts",
|
|
19
|
-
"**/*.tsx",
|
|
20
|
-
"!*.test.ts",
|
|
21
|
-
"!*.test.tsx",
|
|
16
|
+
"lib/**/*.ts",
|
|
17
|
+
"lib/**/*.tsx",
|
|
22
18
|
"!**/*.test.ts",
|
|
23
|
-
"!**/*.test.tsx"
|
|
24
|
-
"!test/**"
|
|
19
|
+
"!**/*.test.tsx"
|
|
25
20
|
],
|
|
26
21
|
"type": "module",
|
|
27
22
|
"sideEffects": false,
|
|
@@ -39,20 +34,10 @@
|
|
|
39
34
|
"node": "./out/index.js",
|
|
40
35
|
"default": "./out/index.js"
|
|
41
36
|
},
|
|
42
|
-
"
|
|
43
|
-
"types": "./out
|
|
44
|
-
"node": "./out
|
|
45
|
-
"default": "./out
|
|
46
|
-
},
|
|
47
|
-
"./name": {
|
|
48
|
-
"types": "./out/name.d.ts",
|
|
49
|
-
"node": "./out/name.js",
|
|
50
|
-
"default": "./out/name.js"
|
|
51
|
-
},
|
|
52
|
-
"./organization": {
|
|
53
|
-
"types": "./out/organization.d.ts",
|
|
54
|
-
"node": "./out/organization.js",
|
|
55
|
-
"default": "./out/organization.js"
|
|
37
|
+
"./*": {
|
|
38
|
+
"types": "./out/*.d.ts",
|
|
39
|
+
"node": "./out/*.js",
|
|
40
|
+
"default": "./out/*.js"
|
|
56
41
|
}
|
|
57
42
|
},
|
|
58
43
|
"publishConfig": {
|
|
@@ -64,20 +49,10 @@
|
|
|
64
49
|
"node": "./out/index.js",
|
|
65
50
|
"default": "./out/index.js"
|
|
66
51
|
},
|
|
67
|
-
"
|
|
68
|
-
"types": "./out
|
|
69
|
-
"node": "./out
|
|
70
|
-
"default": "./out
|
|
71
|
-
},
|
|
72
|
-
"./name": {
|
|
73
|
-
"types": "./out/name.d.ts",
|
|
74
|
-
"node": "./out/name.js",
|
|
75
|
-
"default": "./out/name.js"
|
|
76
|
-
},
|
|
77
|
-
"./organization": {
|
|
78
|
-
"types": "./out/organization.d.ts",
|
|
79
|
-
"node": "./out/organization.js",
|
|
80
|
-
"default": "./out/organization.js"
|
|
52
|
+
"./*": {
|
|
53
|
+
"types": "./out/*.d.ts",
|
|
54
|
+
"node": "./out/*.js",
|
|
55
|
+
"default": "./out/*.js"
|
|
81
56
|
}
|
|
82
57
|
},
|
|
83
58
|
"imports": {
|
|
@@ -89,7 +64,10 @@
|
|
|
89
64
|
}
|
|
90
65
|
},
|
|
91
66
|
"dependencies": {
|
|
92
|
-
"@mailwoman/
|
|
67
|
+
"@mailwoman/annotations": "10.1.0",
|
|
68
|
+
"@mailwoman/codex": "10.1.0",
|
|
69
|
+
"@mailwoman/spatial": "10.1.0",
|
|
70
|
+
"spliterator": "^8.1.0"
|
|
93
71
|
},
|
|
94
72
|
"devDependencies": {
|
|
95
73
|
"@types/node": "^26.4.1"
|