@stll/anonymize-wasm 1.4.3 → 1.4.5
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/dist/common-words-en.mjs +0 -1
- package/dist/constants.mjs +3 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/constants2.d.mts +3 -1
- package/dist/legal-form-leading-clauses.mjs +6 -1
- package/dist/names-exclusions.mjs +12 -0
- package/dist/person-stopwords.mjs +16 -0
- package/dist/wasm.d.mts +28 -1
- package/dist/wasm.mjs +6287 -68
- package/dist/wasm.mjs.map +1 -1
- package/package.json +6 -2
package/dist/common-words-en.mjs
CHANGED
package/dist/constants.mjs
CHANGED
|
@@ -25,6 +25,7 @@ const DETECTION_SOURCES = {
|
|
|
25
25
|
DENY_LIST: "deny-list",
|
|
26
26
|
LEGAL_FORM: "legal-form",
|
|
27
27
|
GAZETTEER: "gazetteer",
|
|
28
|
+
COUNTRY: "country",
|
|
28
29
|
NER: "ner",
|
|
29
30
|
COREFERENCE: "coreference"
|
|
30
31
|
};
|
|
@@ -39,6 +40,7 @@ const DETECTOR_PRIORITY = {
|
|
|
39
40
|
[DETECTION_SOURCES.TRIGGER]: 4,
|
|
40
41
|
[DETECTION_SOURCES.LEGAL_FORM]: 3,
|
|
41
42
|
[DETECTION_SOURCES.REGEX]: 3,
|
|
43
|
+
[DETECTION_SOURCES.COUNTRY]: 3,
|
|
42
44
|
[DETECTION_SOURCES.DENY_LIST]: 2,
|
|
43
45
|
[DETECTION_SOURCES.COREFERENCE]: 2,
|
|
44
46
|
[DETECTION_SOURCES.NER]: 1
|
|
@@ -62,6 +64,7 @@ const DEFAULT_ENTITY_LABELS = [
|
|
|
62
64
|
"organization",
|
|
63
65
|
"phone number",
|
|
64
66
|
"address",
|
|
67
|
+
"country",
|
|
65
68
|
"email address",
|
|
66
69
|
"date",
|
|
67
70
|
"date of birth",
|
package/dist/constants.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/constants.ts"],"sourcesContent":["/**\n * Runtime-free constants for the anonymization pipeline.\n *\n * This module is the SSR-safe / browser-safe entrypoint:\n * importing it must not pull in `@stll/text-search`,\n * `@stll/anonymize-wasm`, or any other runtime-bearing\n * module. Consumers that only need the static label list,\n * detection-source identifiers, or operator names import\n * from `@stll/anonymize/constants` (or\n * `@stll/anonymize-wasm/constants`) without paying the\n * wasm / regex-set startup cost.\n *\n * `types.ts` re-exports these for back-compat, so existing\n * `import { DEFAULT_ENTITY_LABELS } from \"@stll/anonymize\"`\n * call sites keep working.\n */\n\n/**\n * Source of a detected entity span.\n * Ordered by detection layer in the pipeline.\n */\nexport const DETECTION_SOURCES = {\n TRIGGER: \"trigger\",\n REGEX: \"regex\",\n DENY_LIST: \"deny-list\",\n LEGAL_FORM: \"legal-form\",\n GAZETTEER: \"gazetteer\",\n NER: \"ner\",\n COREFERENCE: \"coreference\",\n} as const;\n\nexport type DetectionSource =\n (typeof DETECTION_SOURCES)[keyof typeof DETECTION_SOURCES];\n\n/**\n * Priority levels for detection sources.\n * Higher = more structurally reliable. Used during\n * overlap resolution so deterministic detectors beat\n * probabilistic ones regardless of raw score.\n */\nexport const DETECTOR_PRIORITY = {\n [DETECTION_SOURCES.GAZETTEER]: 5,\n [DETECTION_SOURCES.TRIGGER]: 4,\n [DETECTION_SOURCES.LEGAL_FORM]: 3,\n [DETECTION_SOURCES.REGEX]: 3,\n [DETECTION_SOURCES.DENY_LIST]: 2,\n [DETECTION_SOURCES.COREFERENCE]: 2,\n [DETECTION_SOURCES.NER]: 1,\n} as const satisfies Record<DetectionSource, number>;\n\n/**\n * Anonymization operator types. Each operator defines\n * how a confirmed entity is replaced in the output.\n */\nexport const OPERATOR_TYPES = [\"replace\", \"redact\"] as const;\n\nexport type OperatorType = (typeof OPERATOR_TYPES)[number];\n\n/**\n * Canonical entity labels used across the pipeline.\n * NER models may use different native labels; the bench\n * NER wrapper maps model output to these canonical names.\n *\n * These labels are ephemeral: entities are regenerated on\n * every pipeline run and never persisted to the database.\n * Renaming a label here requires no migration.\n */\nexport const DEFAULT_ENTITY_LABELS = [\n \"person\",\n \"organization\",\n \"phone number\",\n \"address\",\n \"email address\",\n \"date\",\n \"date of birth\",\n \"bank account number\",\n \"iban\",\n \"tax identification number\",\n \"identity card number\",\n \"birth number\",\n \"national identification number\",\n \"social security number\",\n \"registration number\",\n \"credit card number\",\n \"passport number\",\n \"monetary amount\",\n \"land parcel\",\n \"misc\",\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,oBAAoB;CAC/B,SAAS;CACT,OAAO;CACP,WAAW;CACX,YAAY;CACZ,WAAW;CACX,KAAK;CACL,aAAa;CACd;;;;;;;AAWD,MAAa,oBAAoB;EAC9B,kBAAkB,YAAY;EAC9B,kBAAkB,UAAU;EAC5B,kBAAkB,aAAa;EAC/B,kBAAkB,QAAQ;EAC1B,kBAAkB,YAAY;EAC9B,kBAAkB,cAAc;EAChC,kBAAkB,MAAM;CAC1B;;;;;AAMD,MAAa,iBAAiB,CAAC,WAAW,SAAS;;;;;;;;;;AAanD,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/constants.ts"],"sourcesContent":["/**\n * Runtime-free constants for the anonymization pipeline.\n *\n * This module is the SSR-safe / browser-safe entrypoint:\n * importing it must not pull in `@stll/text-search`,\n * `@stll/anonymize-wasm`, or any other runtime-bearing\n * module. Consumers that only need the static label list,\n * detection-source identifiers, or operator names import\n * from `@stll/anonymize/constants` (or\n * `@stll/anonymize-wasm/constants`) without paying the\n * wasm / regex-set startup cost.\n *\n * `types.ts` re-exports these for back-compat, so existing\n * `import { DEFAULT_ENTITY_LABELS } from \"@stll/anonymize\"`\n * call sites keep working.\n */\n\n/**\n * Source of a detected entity span.\n * Ordered by detection layer in the pipeline.\n */\nexport const DETECTION_SOURCES = {\n TRIGGER: \"trigger\",\n REGEX: \"regex\",\n DENY_LIST: \"deny-list\",\n LEGAL_FORM: \"legal-form\",\n GAZETTEER: \"gazetteer\",\n COUNTRY: \"country\",\n NER: \"ner\",\n COREFERENCE: \"coreference\",\n} as const;\n\nexport type DetectionSource =\n (typeof DETECTION_SOURCES)[keyof typeof DETECTION_SOURCES];\n\n/**\n * Priority levels for detection sources.\n * Higher = more structurally reliable. Used during\n * overlap resolution so deterministic detectors beat\n * probabilistic ones regardless of raw score.\n */\nexport const DETECTOR_PRIORITY = {\n [DETECTION_SOURCES.GAZETTEER]: 5,\n [DETECTION_SOURCES.TRIGGER]: 4,\n [DETECTION_SOURCES.LEGAL_FORM]: 3,\n [DETECTION_SOURCES.REGEX]: 3,\n [DETECTION_SOURCES.COUNTRY]: 3,\n [DETECTION_SOURCES.DENY_LIST]: 2,\n [DETECTION_SOURCES.COREFERENCE]: 2,\n [DETECTION_SOURCES.NER]: 1,\n} as const satisfies Record<DetectionSource, number>;\n\n/**\n * Anonymization operator types. Each operator defines\n * how a confirmed entity is replaced in the output.\n */\nexport const OPERATOR_TYPES = [\"replace\", \"redact\"] as const;\n\nexport type OperatorType = (typeof OPERATOR_TYPES)[number];\n\n/**\n * Canonical entity labels used across the pipeline.\n * NER models may use different native labels; the bench\n * NER wrapper maps model output to these canonical names.\n *\n * These labels are ephemeral: entities are regenerated on\n * every pipeline run and never persisted to the database.\n * Renaming a label here requires no migration.\n */\nexport const DEFAULT_ENTITY_LABELS = [\n \"person\",\n \"organization\",\n \"phone number\",\n \"address\",\n \"country\",\n \"email address\",\n \"date\",\n \"date of birth\",\n \"bank account number\",\n \"iban\",\n \"tax identification number\",\n \"identity card number\",\n \"birth number\",\n \"national identification number\",\n \"social security number\",\n \"registration number\",\n \"credit card number\",\n \"passport number\",\n \"monetary amount\",\n \"land parcel\",\n \"misc\",\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,oBAAoB;CAC/B,SAAS;CACT,OAAO;CACP,WAAW;CACX,YAAY;CACZ,WAAW;CACX,SAAS;CACT,KAAK;CACL,aAAa;CACd;;;;;;;AAWD,MAAa,oBAAoB;EAC9B,kBAAkB,YAAY;EAC9B,kBAAkB,UAAU;EAC5B,kBAAkB,aAAa;EAC/B,kBAAkB,QAAQ;EAC1B,kBAAkB,UAAU;EAC5B,kBAAkB,YAAY;EAC9B,kBAAkB,cAAc;EAChC,kBAAkB,MAAM;CAC1B;;;;;AAMD,MAAa,iBAAiB,CAAC,WAAW,SAAS;;;;;;;;;;AAanD,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
package/dist/constants2.d.mts
CHANGED
|
@@ -25,6 +25,7 @@ declare const DETECTION_SOURCES: {
|
|
|
25
25
|
readonly DENY_LIST: "deny-list";
|
|
26
26
|
readonly LEGAL_FORM: "legal-form";
|
|
27
27
|
readonly GAZETTEER: "gazetteer";
|
|
28
|
+
readonly COUNTRY: "country";
|
|
28
29
|
readonly NER: "ner";
|
|
29
30
|
readonly COREFERENCE: "coreference";
|
|
30
31
|
};
|
|
@@ -40,6 +41,7 @@ declare const DETECTOR_PRIORITY: {
|
|
|
40
41
|
readonly trigger: 4;
|
|
41
42
|
readonly "legal-form": 3;
|
|
42
43
|
readonly regex: 3;
|
|
44
|
+
readonly country: 3;
|
|
43
45
|
readonly "deny-list": 2;
|
|
44
46
|
readonly coreference: 2;
|
|
45
47
|
readonly ner: 1;
|
|
@@ -59,7 +61,7 @@ type OperatorType = (typeof OPERATOR_TYPES)[number];
|
|
|
59
61
|
* every pipeline run and never persisted to the database.
|
|
60
62
|
* Renaming a label here requires no migration.
|
|
61
63
|
*/
|
|
62
|
-
declare const DEFAULT_ENTITY_LABELS: readonly ["person", "organization", "phone number", "address", "email address", "date", "date of birth", "bank account number", "iban", "tax identification number", "identity card number", "birth number", "national identification number", "social security number", "registration number", "credit card number", "passport number", "monetary amount", "land parcel", "misc"];
|
|
64
|
+
declare const DEFAULT_ENTITY_LABELS: readonly ["person", "organization", "phone number", "address", "country", "email address", "date", "date of birth", "bank account number", "iban", "tax identification number", "identity card number", "birth number", "national identification number", "social security number", "registration number", "credit card number", "passport number", "monetary amount", "land parcel", "misc"];
|
|
63
65
|
//#endregion
|
|
64
66
|
export { OPERATOR_TYPES as a, DetectionSource as i, DETECTION_SOURCES as n, OperatorType as o, DETECTOR_PRIORITY as r, DEFAULT_ENTITY_LABELS as t };
|
|
65
67
|
//# sourceMappingURL=constants2.d.mts.map
|
|
@@ -144,16 +144,28 @@ var words = [
|
|
|
144
144
|
"subject",
|
|
145
145
|
"supplier",
|
|
146
146
|
"tarif",
|
|
147
|
+
"tato",
|
|
148
|
+
"tedy",
|
|
149
|
+
"tehdy",
|
|
147
150
|
"tel",
|
|
148
151
|
"telefon",
|
|
149
152
|
"tenant",
|
|
153
|
+
"tento",
|
|
150
154
|
"termín",
|
|
151
155
|
"that",
|
|
152
156
|
"the",
|
|
153
157
|
"therefore",
|
|
154
158
|
"thereof",
|
|
155
159
|
"this",
|
|
160
|
+
"tito",
|
|
161
|
+
"tomto",
|
|
162
|
+
"tomuto",
|
|
163
|
+
"toto",
|
|
164
|
+
"touto",
|
|
156
165
|
"tribunal",
|
|
166
|
+
"tuto",
|
|
167
|
+
"tyto",
|
|
168
|
+
"této",
|
|
157
169
|
"under",
|
|
158
170
|
"until",
|
|
159
171
|
"upon",
|
|
@@ -17,6 +17,7 @@ var person_stopwords_default = {
|
|
|
17
17
|
"basic",
|
|
18
18
|
"belgian",
|
|
19
19
|
"borrower",
|
|
20
|
+
"branch",
|
|
20
21
|
"british",
|
|
21
22
|
"bulgarian",
|
|
22
23
|
"buyer",
|
|
@@ -35,6 +36,8 @@ var person_stopwords_default = {
|
|
|
35
36
|
"default",
|
|
36
37
|
"delaware",
|
|
37
38
|
"delivery",
|
|
39
|
+
"department",
|
|
40
|
+
"division",
|
|
38
41
|
"dry",
|
|
39
42
|
"dutch",
|
|
40
43
|
"english",
|
|
@@ -50,6 +53,7 @@ var person_stopwords_default = {
|
|
|
50
53
|
"germany",
|
|
51
54
|
"greek",
|
|
52
55
|
"guarantor",
|
|
56
|
+
"headquarters",
|
|
53
57
|
"hungarian",
|
|
54
58
|
"indiana",
|
|
55
59
|
"interest",
|
|
@@ -80,6 +84,7 @@ var person_stopwords_default = {
|
|
|
80
84
|
"notice",
|
|
81
85
|
"november",
|
|
82
86
|
"october",
|
|
87
|
+
"office",
|
|
83
88
|
"ohio",
|
|
84
89
|
"opportunity",
|
|
85
90
|
"owner",
|
|
@@ -102,6 +107,7 @@ var person_stopwords_default = {
|
|
|
102
107
|
"section",
|
|
103
108
|
"seller",
|
|
104
109
|
"september",
|
|
110
|
+
"subsidiary",
|
|
105
111
|
"slovak",
|
|
106
112
|
"slovenian",
|
|
107
113
|
"spanish",
|
|
@@ -134,6 +140,16 @@ var person_stopwords_default = {
|
|
|
134
140
|
"viale",
|
|
135
141
|
"vico",
|
|
136
142
|
"vicolo",
|
|
143
|
+
"tato",
|
|
144
|
+
"tento",
|
|
145
|
+
"tito",
|
|
146
|
+
"tomto",
|
|
147
|
+
"tomuto",
|
|
148
|
+
"toto",
|
|
149
|
+
"touto",
|
|
150
|
+
"tuto",
|
|
151
|
+
"tyto",
|
|
152
|
+
"této",
|
|
137
153
|
"acheteur",
|
|
138
154
|
"acheteuse",
|
|
139
155
|
"acquéreur",
|
package/dist/wasm.d.mts
CHANGED
|
@@ -325,6 +325,13 @@ type PipelineConfig = {
|
|
|
325
325
|
*/
|
|
326
326
|
customRegexes?: readonly CustomRegexPattern[];
|
|
327
327
|
enableGazetteer: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Detect country names (ISO 3166-1 names, curated
|
|
330
|
+
* aliases, alpha-3 codes). Defaults to true. Names
|
|
331
|
+
* span all manifest languages plus widely-used
|
|
332
|
+
* additions (Dutch, Russian, Chinese, Arabic, etc.).
|
|
333
|
+
*/
|
|
334
|
+
enableCountries?: boolean;
|
|
328
335
|
enableNer: boolean;
|
|
329
336
|
enableConfidenceBoost: boolean;
|
|
330
337
|
enableCoreference: boolean;
|
|
@@ -387,7 +394,7 @@ declare const CURRENCY_PATTERN_META: Readonly<RegexMeta>;
|
|
|
387
394
|
declare const processRegexMatches: (allMatches: Match[], sliceStart: number, sliceEnd: number, meta_: readonly RegexMeta[]) => Entity[];
|
|
388
395
|
//#endregion
|
|
389
396
|
//#region src/detectors/deny-list.d.ts
|
|
390
|
-
type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "nameCorpusLanguages" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "customDenyList" | "dictionaries">;
|
|
397
|
+
type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "nameCorpusLanguages" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "customDenyList" | "dictionaries" | "enableCountries">;
|
|
391
398
|
/**
|
|
392
399
|
* Source tag for each pattern in the automaton.
|
|
393
400
|
* "deny-list" = standard deny list entry
|
|
@@ -452,6 +459,24 @@ declare const ensureDenyListData: (ctx?: PipelineContext, dictionaries?: Diction
|
|
|
452
459
|
*/
|
|
453
460
|
declare const processDenyListMatches: (allMatches: Match[], sliceStart: number, sliceEnd: number, fullText: string, data: DenyListData, ctx?: PipelineContext) => Entity[];
|
|
454
461
|
//#endregion
|
|
462
|
+
//#region src/detectors/countries.d.ts
|
|
463
|
+
/**
|
|
464
|
+
* Pre-built country patterns + parallel label/source
|
|
465
|
+
* metadata. Constructed once and reused across pipeline
|
|
466
|
+
* runs.
|
|
467
|
+
*/
|
|
468
|
+
type CountryData = {
|
|
469
|
+
/** Maps local pattern index to entity label. Always "country". */labels: string[];
|
|
470
|
+
/**
|
|
471
|
+
* Maps local pattern index to the alpha-2 ISO code the
|
|
472
|
+
* pattern resolves to. Used for downstream coreference /
|
|
473
|
+
* placeholder grouping.
|
|
474
|
+
*/
|
|
475
|
+
isoCodes: string[]; /** Maps local pattern index to pattern variant kind. */
|
|
476
|
+
variants: CountryVariant[];
|
|
477
|
+
};
|
|
478
|
+
type CountryVariant = "name" | "alias" | "alpha3" | "alpha2";
|
|
479
|
+
//#endregion
|
|
455
480
|
//#region src/build-unified-search.d.ts
|
|
456
481
|
type PatternSlice = {
|
|
457
482
|
start: number;
|
|
@@ -477,12 +502,14 @@ type UnifiedSearchInstance = {
|
|
|
477
502
|
denyList: PatternSlice;
|
|
478
503
|
streetTypes: PatternSlice;
|
|
479
504
|
gazetteer: PatternSlice;
|
|
505
|
+
countries: PatternSlice;
|
|
480
506
|
};
|
|
481
507
|
regexMeta: readonly RegexMeta[];
|
|
482
508
|
customRegexMeta: readonly RegexMeta[];
|
|
483
509
|
triggerRules: readonly TriggerRule[];
|
|
484
510
|
denyListData: DenyListData | null;
|
|
485
511
|
gazetteerData: GazetteerData | null;
|
|
512
|
+
countryData: CountryData | null;
|
|
486
513
|
};
|
|
487
514
|
declare const buildUnifiedSearch: (config: PipelineConfig, gazetteerEntries?: GazetteerEntry[], ctx?: PipelineContext) => Promise<UnifiedSearchInstance>;
|
|
488
515
|
//#endregion
|