@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/address.d.ts
CHANGED
|
@@ -2,35 +2,10 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The canonical address record — the matcher's unit of address identity, and the canonical record
|
|
7
|
-
* the organization and contact records build on.
|
|
8
|
-
*
|
|
9
|
-
* It is plain data: parser components + the formatter's match key + an optional resolved geocode,
|
|
10
|
-
* composed into one object. No ORM, no decorators, no schema-generation implementation — if we need a
|
|
11
|
-
* database we reach for Kysely at the call site, not a model layer here.
|
|
12
|
-
*
|
|
13
|
-
* The geocode fields mirror mailwoman's `GeocodeResult` (tier + calibrated uncertainty + hierarchy)
|
|
14
|
-
* on purpose: that is the location signal the Fellegi-Sunter scorer weights its distance evidence
|
|
15
|
-
* by — two records sharing a `address_point` coordinate is strong agreement; sharing an
|
|
16
|
-
* `interpolated` centroid is weak; a PO-box / multi-unit coordinate is barely location agreement
|
|
17
|
-
* at all (the NAACCR precedent, see the geocode-first record-matching concept doc).
|
|
18
|
-
*/
|
|
19
|
-
import { type ComponentDict, type FormatAddressOptions } from "@mailwoman/codex/address-format";
|
|
20
|
-
/**
|
|
21
|
-
* A geographic coordinate (WGS84 decimal degrees).
|
|
22
|
-
*/
|
|
23
|
-
export interface GeoCoordinate {
|
|
24
|
-
latitude: number;
|
|
25
|
-
longitude: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The resolution tier that produced a coordinate, mirroring mailwoman's geocoder (`address_point` > `interpolated` >
|
|
29
|
-
* `street` > `admin`). Kept as a local plain union so this package stays decoupled from the heavy geocoder runtime; a
|
|
30
|
-
* `GeocodeResult.resolution_tier` maps in directly. (`street` = a street centroid for a street-only query, #1042 —
|
|
31
|
-
* coarser than a house-number estimate, finer than an admin centroid.)
|
|
32
5
|
*/
|
|
33
|
-
|
|
6
|
+
import type { ResolutionTier } from "@mailwoman/annotations/geo";
|
|
7
|
+
import { type ComponentDict, type FormatAddressOptions } from "@mailwoman/codex/address/format";
|
|
8
|
+
import type { GeoCoordinate } from "@mailwoman/spatial";
|
|
34
9
|
/**
|
|
35
10
|
* One resolved admin-hierarchy ancestor (most specific first), for spelling-invariant blocking.
|
|
36
11
|
*/
|
|
@@ -46,45 +21,48 @@ export interface AddressGeocode {
|
|
|
46
21
|
coordinate: GeoCoordinate;
|
|
47
22
|
tier: ResolutionTier;
|
|
48
23
|
/**
|
|
49
|
-
*
|
|
24
|
+
* Gives the uncertainty radius in meters.
|
|
25
|
+
*
|
|
26
|
+
* It is `null` on the admin tier and whenever the tier reports none.
|
|
50
27
|
*/
|
|
51
28
|
uncertaintyMeters: number | null;
|
|
52
29
|
/**
|
|
53
|
-
*
|
|
30
|
+
* Lists the resolved admin hierarchy from the locality up to the country.
|
|
54
31
|
*/
|
|
55
32
|
hierarchy?: HierarchyNode[];
|
|
56
33
|
/**
|
|
57
|
-
*
|
|
34
|
+
* Marks a delivery point, such as a PO box, rather than a building,
|
|
35
|
+
* so the coordinate does not locate the addressee.
|
|
58
36
|
*/
|
|
59
37
|
poBox?: boolean;
|
|
60
38
|
/**
|
|
61
|
-
*
|
|
39
|
+
* Marks a multi-unit building whose records share one coordinate,
|
|
40
|
+
* so the coordinate cannot distinguish units.
|
|
62
41
|
*/
|
|
63
42
|
multiUnit?: boolean;
|
|
64
43
|
}
|
|
65
44
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
45
|
+
* Describes the canonical address record with parsed components plus a match key.
|
|
46
|
+
*
|
|
47
|
+
* It may also include formatted text, raw input or a resolved geocode.
|
|
68
48
|
*/
|
|
69
49
|
export interface PostalAddress {
|
|
70
50
|
/**
|
|
71
|
-
*
|
|
51
|
+
* Holds the parsed address components keyed by component tag.
|
|
72
52
|
*/
|
|
73
53
|
components: ComponentDict;
|
|
74
54
|
/**
|
|
75
|
-
*
|
|
55
|
+
* Holds the normalized, deterministic match key used for blocking, built by
|
|
56
|
+
* `canonicalKey` from `@mailwoman/codex/address/key`.
|
|
76
57
|
*/
|
|
77
58
|
canonicalKey: string;
|
|
78
59
|
/**
|
|
79
|
-
*
|
|
60
|
+
* Gives a human-readable single-line form for display.
|
|
80
61
|
*/
|
|
81
62
|
formatted?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Resolved location, when geocoded.
|
|
84
|
-
*/
|
|
85
63
|
geocode?: AddressGeocode;
|
|
86
64
|
/**
|
|
87
|
-
*
|
|
65
|
+
* Keeps the original free-text input for provenance.
|
|
88
66
|
*/
|
|
89
67
|
raw?: string;
|
|
90
68
|
}
|
|
@@ -93,25 +71,29 @@ export interface PostalAddress {
|
|
|
93
71
|
*/
|
|
94
72
|
export interface ToPostalAddressOptions {
|
|
95
73
|
/**
|
|
96
|
-
*
|
|
74
|
+
* Supplies the country for formatting as an ISO-2 code or a name.
|
|
75
|
+
* It defaults to the `country` component.
|
|
97
76
|
*/
|
|
98
77
|
country?: string;
|
|
99
78
|
/**
|
|
100
|
-
*
|
|
79
|
+
* Supplies the original free-text input to keep as provenance.
|
|
101
80
|
*/
|
|
102
81
|
raw?: string;
|
|
103
82
|
/**
|
|
104
|
-
*
|
|
83
|
+
* Indicates whether to compute the `formatted` string.
|
|
84
|
+
* It defaults to `true`.
|
|
105
85
|
*/
|
|
106
86
|
format?: boolean;
|
|
107
87
|
/**
|
|
108
|
-
*
|
|
88
|
+
* Passes options to the formatter, defaulting to a single line joined with `", "`.
|
|
109
89
|
*/
|
|
110
90
|
formatOptions?: FormatAddressOptions;
|
|
111
91
|
}
|
|
112
92
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
93
|
+
* Builds a {@linkcode PostalAddress} from parsed components, always filling the match key
|
|
94
|
+
* and, unless `format` is `false`, the formatted address.
|
|
95
|
+
*
|
|
96
|
+
* Attach a geocode separately with {@linkcode withGeocode}.
|
|
115
97
|
*/
|
|
116
98
|
export declare function toPostalAddress(components: ComponentDict, opts?: ToPostalAddressOptions): PostalAddress;
|
|
117
99
|
/**
|
package/out/address.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../lib/address.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../lib/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAiB,MAAM,iCAAiC,CAAA;AAE9G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,aAAa,CAAA;IACzB,IAAI,EAAE,cAAc,CAAA;IAEpB;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhC;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,EAAE,CAAA;IAE3B;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,UAAU,EAAE,aAAa,CAAA;IAEzB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,OAAO,CAAC,EAAE,cAAc,CAAA;IAExB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;OAEG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAA;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,aAAa,EAAE,IAAI,GAAE,sBAA2B,GAAG,aAAa,CAqB3G;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,GAAG,aAAa,CAEzF"}
|
package/out/address.js
CHANGED
|
@@ -2,25 +2,14 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The canonical address record — the matcher's unit of address identity, and the canonical record
|
|
7
|
-
* the organization and contact records build on.
|
|
8
|
-
*
|
|
9
|
-
* It is plain data: parser components + the formatter's match key + an optional resolved geocode,
|
|
10
|
-
* composed into one object. No ORM, no decorators, no schema-generation implementation — if we need a
|
|
11
|
-
* database we reach for Kysely at the call site, not a model layer here.
|
|
12
|
-
*
|
|
13
|
-
* The geocode fields mirror mailwoman's `GeocodeResult` (tier + calibrated uncertainty + hierarchy)
|
|
14
|
-
* on purpose: that is the location signal the Fellegi-Sunter scorer weights its distance evidence
|
|
15
|
-
* by — two records sharing a `address_point` coordinate is strong agreement; sharing an
|
|
16
|
-
* `interpolated` centroid is weak; a PO-box / multi-unit coordinate is barely location agreement
|
|
17
|
-
* at all (the NAACCR precedent, see the geocode-first record-matching concept doc).
|
|
18
5
|
*/
|
|
19
|
-
import { formatAddress } from "@mailwoman/codex/address
|
|
20
|
-
import { canonicalKey } from "@mailwoman/codex/address
|
|
6
|
+
import { formatAddress } from "@mailwoman/codex/address/format";
|
|
7
|
+
import { canonicalKey } from "@mailwoman/codex/address/key";
|
|
21
8
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
9
|
+
* Builds a {@linkcode PostalAddress} from parsed components, always filling the match key
|
|
10
|
+
* and, unless `format` is `false`, the formatted address.
|
|
11
|
+
*
|
|
12
|
+
* Attach a geocode separately with {@linkcode withGeocode}.
|
|
24
13
|
*/
|
|
25
14
|
export function toPostalAddress(components, opts = {}) {
|
|
26
15
|
const country = opts.country ?? components.country ?? "";
|
package/out/address.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","sourceRoot":"","sources":["../lib/address.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../lib/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAiD,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAC9G,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAqG3D;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,UAAyB,EAAE,IAAI,GAA2B,EAAE;IAC3F,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,IAAI,EAAE,CAAA;IAExD,MAAM,MAAM,GAAkB;QAC7B,UAAU;QACV,YAAY,EAAE,YAAY,CAAC,UAAU,CAAC;KACtC,CAAA;IAED,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IACtB,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAE/F,IAAI,SAAS,EAAE,CAAC;YACf,MAAM,CAAC,SAAS,GAAG,SAAS,CAAA;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAA;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,MAAqB,EAAE,OAAuB;IACzE,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAA;AAC9B,CAAC"}
|
package/out/name.d.ts
CHANGED
|
@@ -14,18 +14,20 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Scope + honesty (per the name-canonicalization research pass):
|
|
16
16
|
*
|
|
17
|
-
* - Western / romanized names only. Cultural given-family
|
|
17
|
+
* - Western / romanized names only. Cultural given-family order variation (East-Asian family-first)
|
|
18
18
|
* and transliteration are not handled here — a documented follow-up.
|
|
19
|
-
* - Nickname → canonical-root mapping is intentionally
|
|
19
|
+
* - Nickname → canonical-root mapping is intentionally not done at parse time: it is lossy and
|
|
20
20
|
* gendered (Bobbie → Robert _or_ Roberta), so equivalence belongs in the matcher as a fuzzy
|
|
21
|
-
* agreement level
|
|
21
|
+
* agreement level rather than a destructive rewrite. We only _extract_ a parenthetical/quoted
|
|
22
22
|
* nickname.
|
|
23
|
-
* - A CRF parser (probablepeople) is the gold-standard reference but too heavy to port
|
|
23
|
+
* - A CRF parser (probablepeople) is the gold-standard reference but too heavy to port. this
|
|
24
24
|
* positional parser covers the documented hard cases (inversion, particles, generational +
|
|
25
25
|
* professional suffixes) without a model.
|
|
26
26
|
*/
|
|
27
27
|
/**
|
|
28
|
-
* A parsed person name.
|
|
28
|
+
* A parsed person name.
|
|
29
|
+
*
|
|
30
|
+
* All fields optional — the parser fills what it can identify.
|
|
29
31
|
*/
|
|
30
32
|
export interface PersonName {
|
|
31
33
|
/**
|
|
@@ -58,8 +60,10 @@ export interface PersonName {
|
|
|
58
60
|
nickname?: string;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
|
-
* Parse a full name into components.
|
|
62
|
-
*
|
|
63
|
+
* Parse a full name into components.
|
|
64
|
+
*
|
|
65
|
+
* @returns `null` for empty input.
|
|
66
|
+
* Best-effort and non-throwing — ambiguous input degrades gracefully rather than erroring.
|
|
63
67
|
*/
|
|
64
68
|
export declare function parsePersonName(input: string | null | undefined): PersonName | null;
|
|
65
69
|
/**
|
|
@@ -69,12 +73,15 @@ export type PersonNameStyle = "full" | "short";
|
|
|
69
73
|
/**
|
|
70
74
|
* Render a {@linkcode PersonName} back to a string — the inverse of {@linkcode parsePersonName}.
|
|
71
75
|
*
|
|
72
|
-
* `"full"` prints every part the parser identified except the nickname
|
|
73
|
-
*
|
|
74
|
-
*
|
|
76
|
+
* `"full"` prints every part the parser identified except the nickname.
|
|
77
|
+
* A nickname is an alternative to the given name rather than an addition to it.
|
|
78
|
+
*
|
|
79
|
+
* `"short"` prints what a person is addressed by.
|
|
80
|
+
* Display labels and match keys use this form.
|
|
75
81
|
*
|
|
76
|
-
* The particle travels
|
|
77
|
-
* `Vega` independently of `de la`;
|
|
82
|
+
* The particle travels with the surname in both styles.
|
|
83
|
+
* The parser stores it separately so the matcher can compare `Vega` independently of `de la`;
|
|
84
|
+
* printing them apart would produce a form absent from the input name.
|
|
78
85
|
*/
|
|
79
86
|
export declare function formatPersonName(name: PersonName | null | undefined, style?: PersonNameStyle): string;
|
|
80
87
|
//# sourceMappingURL=name.d.ts.map
|
package/out/name.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../lib/name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../lib/name.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAsJD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAsHnF;AAkBD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAA;AAE9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAE,eAAwB,GAAG,MAAM,CAe7G"}
|
package/out/name.js
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
+
import { TextSpliterator } from "spliterator";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
3
|
+
* Titles / salutations that lead a name.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
* compare.
|
|
8
|
-
*
|
|
9
|
-
* A rule-based positional parser, the portable recipe from `python-nameparser`: split on a comma to
|
|
10
|
-
* detect `Last, First` inversion, then classify tokens by position against configurable title /
|
|
11
|
-
* suffix / particle lists. We deliberately store the surname **particle** (`van`, `de la`, `von`)
|
|
12
|
-
* separately from the bare surname (the `theiconic/name-parser` pattern) so the matcher can
|
|
13
|
-
* compare `Vega` independent of `de la` — sources that drop or vary the particle still match.
|
|
14
|
-
*
|
|
15
|
-
* Scope + honesty (per the name-canonicalization research pass):
|
|
16
|
-
*
|
|
17
|
-
* - Western / romanized names only. Cultural given-family ORDER variation (East-Asian family-first)
|
|
18
|
-
* and transliteration are not handled here — a documented follow-up.
|
|
19
|
-
* - Nickname → canonical-root mapping is intentionally NOT done at parse time: it is lossy and
|
|
20
|
-
* gendered (Bobbie → Robert _or_ Roberta), so equivalence belongs in the matcher as a fuzzy
|
|
21
|
-
* agreement level, not a destructive rewrite. We only _extract_ a parenthetical/quoted
|
|
22
|
-
* nickname.
|
|
23
|
-
* - A CRF parser (probablepeople) is the gold-standard reference but too heavy to port; this
|
|
24
|
-
* positional parser covers the documented hard cases (inversion, particles, generational +
|
|
25
|
-
* professional suffixes) without a model.
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* Titles / salutations that lead a name. Matched case-insensitively, trailing `.` ignored.
|
|
5
|
+
* Matched case-insensitively, trailing `.` ignored.
|
|
29
6
|
*/
|
|
30
7
|
const TITLES = new Set([
|
|
31
8
|
"airman",
|
|
@@ -124,8 +101,10 @@ const SUFFIXES = new Set([
|
|
|
124
101
|
"pharmd",
|
|
125
102
|
]);
|
|
126
103
|
/**
|
|
127
|
-
* Surname particles.
|
|
128
|
-
*
|
|
104
|
+
* Surname particles.
|
|
105
|
+
*
|
|
106
|
+
* Consecutive particles fold together (`de` + `la` → `de la`), and the next
|
|
107
|
+
* non-particle token begins the bare surname.
|
|
129
108
|
*/
|
|
130
109
|
const PARTICLES = new Set([
|
|
131
110
|
"al",
|
|
@@ -165,8 +144,10 @@ const isPresent = (s) => typeof s === "string" && s.trim().length > 0;
|
|
|
165
144
|
const norm = (token) => token.replace(/\.$/, "").toLowerCase();
|
|
166
145
|
const countChar = (s, c) => s.split(c).length - 1;
|
|
167
146
|
/**
|
|
168
|
-
* Parse a full name into components.
|
|
169
|
-
*
|
|
147
|
+
* Parse a full name into components.
|
|
148
|
+
*
|
|
149
|
+
* @returns `null` for empty input.
|
|
150
|
+
* Best-effort and non-throwing — ambiguous input degrades gracefully rather than erroring.
|
|
170
151
|
*/
|
|
171
152
|
export function parsePersonName(input) {
|
|
172
153
|
if (!isPresent(input))
|
|
@@ -191,7 +172,7 @@ export function parsePersonName(input) {
|
|
|
191
172
|
// 2. Resolve a single comma: "Last, First" inversion, unless the tail is a known suffix
|
|
192
173
|
// ("John Smith, Jr."), in which case keep order and treat the tail as a suffix.
|
|
193
174
|
if (countChar(working, ",") === 1) {
|
|
194
|
-
const [head, tail] =
|
|
175
|
+
const [head, tail] = TextSpliterator.from(working, { delimiter: "," }).toArray();
|
|
195
176
|
if (tail && tail.split(/\s+/).every((t) => SUFFIXES.has(norm(t)))) {
|
|
196
177
|
result.suffix = tail;
|
|
197
178
|
working = head;
|
|
@@ -200,10 +181,10 @@ export function parsePersonName(input) {
|
|
|
200
181
|
working = `${tail} ${head}`;
|
|
201
182
|
}
|
|
202
183
|
}
|
|
203
|
-
const tokens = working.split(/\s+/).filter((value) => value.length
|
|
184
|
+
const tokens = working.split(/\s+/).filter((value) => value.length);
|
|
204
185
|
if (!tokens.length)
|
|
205
186
|
return Object.keys(result).length ? result : null;
|
|
206
|
-
// 3.
|
|
187
|
+
// 3. Titles at the start become the prefix.
|
|
207
188
|
const prefixParts = [];
|
|
208
189
|
while (tokens.length > 1 && TITLES.has(norm(tokens[0]))) {
|
|
209
190
|
prefixParts.push(tokens.shift());
|
|
@@ -211,7 +192,7 @@ export function parsePersonName(input) {
|
|
|
211
192
|
if (prefixParts.length) {
|
|
212
193
|
result.prefix = prefixParts.join(" ");
|
|
213
194
|
}
|
|
214
|
-
// 4.
|
|
195
|
+
// 4. Suffixes at the end become the suffix, while one name token must remain.
|
|
215
196
|
const suffixParts = [];
|
|
216
197
|
while (tokens.length > 1 && SUFFIXES.has(norm(tokens.at(-1)))) {
|
|
217
198
|
suffixParts.unshift(tokens.pop());
|
|
@@ -221,7 +202,8 @@ export function parsePersonName(input) {
|
|
|
221
202
|
}
|
|
222
203
|
if (!tokens.length)
|
|
223
204
|
return result;
|
|
224
|
-
// 5. Locate the surname particle run
|
|
205
|
+
// 5. Locate the surname particle run.
|
|
206
|
+
// Everything from it onward is the (particled) surname.
|
|
225
207
|
let particleStart = -1;
|
|
226
208
|
for (let i = 0; i < tokens.length; i++) {
|
|
227
209
|
// A particle only starts a surname if a bare-surname token follows it.
|
|
@@ -261,24 +243,31 @@ export function parsePersonName(input) {
|
|
|
261
243
|
return result;
|
|
262
244
|
}
|
|
263
245
|
/**
|
|
264
|
-
* The
|
|
265
|
-
*
|
|
246
|
+
* The order a person name prints in.
|
|
247
|
+
*
|
|
248
|
+
* Western / romanized only, the same scope {@linkcode parsePersonName} declares.
|
|
249
|
+
* A family-first system does not use this order in reverse.
|
|
250
|
+
* An invented order here would be worse than having none.
|
|
266
251
|
*/
|
|
267
252
|
const NAME_ORDER = ["prefix", "given", "middle", "familyParticle", "family", "suffix"];
|
|
268
253
|
/**
|
|
269
|
-
* The parts {@linkcode formatPersonName} prints for the short style
|
|
270
|
-
*
|
|
254
|
+
* The parts {@linkcode formatPersonName} prints for the short style.
|
|
255
|
+
*
|
|
256
|
+
* What a person is addressed by, without the title, the nickname or the letters after.
|
|
271
257
|
*/
|
|
272
258
|
const SHORT_NAME_ORDER = ["given", "familyParticle", "family"];
|
|
273
259
|
/**
|
|
274
260
|
* Render a {@linkcode PersonName} back to a string — the inverse of {@linkcode parsePersonName}.
|
|
275
261
|
*
|
|
276
|
-
* `"full"` prints every part the parser identified except the nickname
|
|
277
|
-
*
|
|
278
|
-
*
|
|
262
|
+
* `"full"` prints every part the parser identified except the nickname.
|
|
263
|
+
* A nickname is an alternative to the given name rather than an addition to it.
|
|
264
|
+
*
|
|
265
|
+
* `"short"` prints what a person is addressed by.
|
|
266
|
+
* Display labels and match keys use this form.
|
|
279
267
|
*
|
|
280
|
-
* The particle travels
|
|
281
|
-
* `Vega` independently of `de la`;
|
|
268
|
+
* The particle travels with the surname in both styles.
|
|
269
|
+
* The parser stores it separately so the matcher can compare `Vega` independently of `de la`;
|
|
270
|
+
* printing them apart would produce a form absent from the input name.
|
|
282
271
|
*/
|
|
283
272
|
export function formatPersonName(name, style = "full") {
|
|
284
273
|
if (!name)
|
package/out/name.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.js","sourceRoot":"","sources":["../lib/name.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"name.js","sourceRoot":"","sources":["../lib/name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAiE7C;;;;GAIG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACtB,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,WAAW;IACX,MAAM;IACN,SAAS;IACT,MAAM;IACN,KAAK;IACL,SAAS;IACT,WAAW;IACX,cAAc;IACd,KAAK;IACL,KAAK;IACL,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,KAAK;IACL,SAAS;IACT,KAAK;IACL,WAAW;IACX,OAAO;IACP,IAAI;IACJ,OAAO;IACP,OAAO;IACP,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,KAAK;IACL,MAAM;IACN,WAAW;IACX,SAAS;IACT,MAAM;IACN,WAAW;IACX,KAAK;IACL,OAAO;IACP,KAAK;IACL,gBAAgB;IAChB,KAAK;IACL,UAAU;IACV,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,QAAQ;CACR,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,QAAQ,GAAG,IAAI,GA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,MAAM,KAAK,GAAG,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAA;IAC/D,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAA;QAEhC,IAAI,KAAK,EAAE,CAAC;YACX,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAClB,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC"}
|
package/out/organization.d.ts
CHANGED
|
@@ -3,39 +3,9 @@
|
|
|
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
10
|
/**
|
|
41
11
|
* A canonicalized organization name.
|
|
@@ -59,34 +29,40 @@ export interface OrganizationName {
|
|
|
59
29
|
dba?: string;
|
|
60
30
|
}
|
|
61
31
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
32
|
+
* Names a domain pack.
|
|
33
|
+
*
|
|
34
|
+
* Each pack leaves domain-specific abbreviations in the organization name
|
|
35
|
+
* instead of stripping them as legal forms.
|
|
36
|
+
* The `general` pack adds no domain-specific abbreviations.
|
|
65
37
|
*/
|
|
66
38
|
export type DesignationDomain = "general" | "healthcare";
|
|
67
39
|
/**
|
|
68
|
-
* Context for {@link canonicalizeOrganizationName}
|
|
40
|
+
* Context for {@link canonicalizeOrganizationName}; omit both fields for the universal base behavior.
|
|
69
41
|
*/
|
|
70
42
|
export interface CanonicalizeOptions {
|
|
71
43
|
/**
|
|
72
|
-
* ISO 3166-1 alpha-2 country code
|
|
73
|
-
*
|
|
74
|
-
*
|
|
44
|
+
* ISO 3166-1 alpha-2 country code for the organization's jurisdiction.
|
|
45
|
+
*
|
|
46
|
+
* Its country pack adds that jurisdiction's legal forms to the strip set.
|
|
47
|
+
* The comparison ignores case.
|
|
48
|
+
* Unknown codes add no pack.
|
|
75
49
|
*/
|
|
76
50
|
jurisdiction?: string;
|
|
77
51
|
/**
|
|
78
|
-
* Ingest domain
|
|
79
|
-
*
|
|
52
|
+
* Ingest domain that keeps domain-specific abbreviations in organization names.
|
|
53
|
+
*
|
|
54
|
+
* The `healthcare` domain leaves `pt` in the name.
|
|
55
|
+
* It also leaves `sca` and `scs`.
|
|
56
|
+
* These rules take precedence over jurisdiction packs.
|
|
80
57
|
*/
|
|
81
58
|
domain?: DesignationDomain;
|
|
82
59
|
}
|
|
83
60
|
/**
|
|
84
|
-
* Canonicalize an organization name: split off any `doing business as` clause,
|
|
85
|
-
*
|
|
61
|
+
* Canonicalize an organization name: split off any `doing business as` clause,
|
|
62
|
+
* then reduce the legal name to a designation-stripped key.
|
|
86
63
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* used and the result is byte-for-byte the legacy behavior.
|
|
64
|
+
* Returns `null` for empty input. {@link CanonicalizeOptions} resolves conflicts
|
|
65
|
+
* between jurisdiction and domain rules.
|
|
90
66
|
*/
|
|
91
67
|
export declare function canonicalizeOrganizationName(input: string | null | undefined, options?: CanonicalizeOptions): OrganizationName | null;
|
|
92
68
|
//# sourceMappingURL=organization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../lib/organization.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../lib/organization.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,YAAY,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAC1B;AAqJD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,OAAO,CAAC,EAAE,mBAAmB,GAC3B,gBAAgB,GAAG,IAAI,CAoBzB"}
|