@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/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
- export type ResolutionTier = "address_point" | "interpolated" | "street" | "admin" | "venue" | "plus_code";
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
- * Calibrated uncertainty radius in meters; `null` for the admin tier (no sub-locality estimate).
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
- * Resolved admin hierarchy, locality → country (most specific first).
30
+ * Lists the resolved admin hierarchy from the locality up to the country.
54
31
  */
55
32
  hierarchy?: HierarchyNode[];
56
33
  /**
57
- * A delivery point, not a building — weakens location agreement even at a precise coordinate.
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
- * A multi-unit building where many records share one coordinate — weakens unit-level agreement.
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
- * The canonical address record. Composes the parser's components, the formatter's match key, an optional human-readable
67
- * form, and an optional resolved geocode. Plain data — no behavior.
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
- * Parsed address components (`ComponentTag`-keyed).
51
+ * Holds the parsed address components keyed by component tag.
72
52
  */
73
53
  components: ComponentDict;
74
54
  /**
75
- * Normalized, deterministic match key for blocking (from `@mailwoman/formatter`).
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
- * Optional human-readable single-line form, for display.
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
- * The original free-text input, when known (provenance).
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
- * Country (ISO-2 or name) for formatting. Defaults to the `country` component, else unset.
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
- * The original free-text input to retain as provenance.
79
+ * Supplies the original free-text input to keep as provenance.
101
80
  */
102
81
  raw?: string;
103
82
  /**
104
- * Also compute a human-readable `formatted` string. Default `true`.
83
+ * Indicates whether to compute the `formatted` string.
84
+ * It defaults to `true`.
105
85
  */
106
86
  format?: boolean;
107
87
  /**
108
- * Formatting options forwarded to the formatter. Defaults to single-line (`", "`).
88
+ * Passes options to the formatter, defaulting to a single line joined with `", "`.
109
89
  */
110
90
  formatOptions?: FormatAddressOptions;
111
91
  }
112
92
  /**
113
- * Build a canonical {@linkcode PostalAddress} from parsed components: fills the match key (always) and a human-readable
114
- * form (unless disabled). Attach a geocode separately with {@linkcode withGeocode} once the address is resolved.
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
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../lib/address.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAiB,MAAM,iCAAiC,CAAA;AAG9G;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,c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,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-format";
20
- import { canonicalKey } from "@mailwoman/codex/address-key";
6
+ import { formatAddress } from "@mailwoman/codex/address/format";
7
+ import { canonicalKey } from "@mailwoman/codex/address/key";
21
8
  /**
22
- * Build a canonical {@linkcode PostalAddress} from parsed components: fills the match key (always) and a human-readable
23
- * form (unless disabled). Attach a geocode separately with {@linkcode withGeocode} once the address is resolved.
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 ?? "";
@@ -1 +1 @@
1
- {"version":3,"file":"address.js","sourceRoot":"","sources":["../lib/address.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAiD,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAC9G,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAoG3D;;;GAGG;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"}
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 ORDER variation (East-Asian family-first)
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 NOT done at parse time: it is lossy and
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, not a destructive rewrite. We only _extract_ a parenthetical/quoted
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; this
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. All fields optional — the parser fills what it can identify.
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. Returns `null` for empty input. Best-effort and non-throwing — ambiguous input
62
- * degrades gracefully rather than erroring.
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, which is an alternative to the given name
73
- * rather than an addition to it. `"short"` prints what a person is addressed by, which is the form a display label and
74
- * a match key want.
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 WITH the surname in both styles. The parser stores it separately so the matcher can compare
77
- * `Vega` independently of `de la`; printing them apart would produce a name nobody wrote.
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":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;GAEG;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;AAkJD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAqHnF;AAcD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAA;AAE9C;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAE,eAAwB,GAAG,MAAM,CAe7G"}
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
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
3
+ * Titles / salutations that lead a name.
5
4
  *
6
- * Person-name parsing — split a full name into components for the matcher to canonicalize and
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. Consecutive particles fold together (`de` + `la` → `de la`), and the next non-particle token
128
- * begins the bare surname.
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. Returns `null` for empty input. Best-effort and non-throwing — ambiguous input
169
- * degrades gracefully rather than erroring.
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] = working.split(",").map((p) => p.trim());
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 > 0);
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. Leading titles → prefix.
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. Trailing suffixes → suffix (a single name token must remain).
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; everything from it onward is the (particled) surname.
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 ORDER a person name prints in. Western / romanized only, the same scope {@linkcode parsePersonName} declares: a
265
- * family-first system is not this order reversed, and inventing one here would be worse than having none.
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 — what a person is addressed by, without the title,
270
- * the nickname or the letters after.
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, which is an alternative to the given name
277
- * rather than an addition to it. `"short"` prints what a person is addressed by, which is the form a display label and
278
- * a match key want.
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 WITH the surname in both styles. The parser stores it separately so the matcher can compare
281
- * `Vega` independently of `de la`; printing them apart would produce a name nobody wrote.
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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoCH;;GAEG;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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C,IAAmC,EAAE,KAAK,GAAoB,MAAM;IACpG,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAA;IAEpB,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"}
@@ -3,39 +3,9 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Organization-name canonicalization — reduce a company name to a stable, comparable key.
7
- *
8
- * Winkler's record-linkage recipe: words of little distinguishing power (the legal designation —
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
- * A domain pack name. Each protects the abbreviations that are meaningful in that domain from being stripped as legal
63
- * forms (see {@link DOMAIN_PROTECTED}). `general` protects nothing — the explicit "no domain" choice. Add a pack here
64
- * (and to {@link DOMAIN_PROTECTED}) per ingest domain.
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}. Omit both fields for the universal base behavior.
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 of the org's jurisdiction (typically the resolved address country). Adds that
73
- * country's legal forms — including collision-prone ones held out of the base — to the strip-set. Case-insensitive;
74
- * unknown codes add nothing.
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. Protects domain-meaningful abbreviations (e.g. `healthcare` protects `pt` / `sca` / `scs`) from
79
- * being stripped, overriding any jurisdiction pack that would add them.
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, then reduce the legal name to a
85
- * designation-stripped key. Returns `null` for empty input.
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
- * Pass {@link CanonicalizeOptions} to resolve the jurisdiction × domain collision (#668): a `jurisdiction` adds that
88
- * country's legal forms, a `domain` protects its meaningful abbreviations. With no options the universal base set is
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":"A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