@stll/anonymize-wasm 1.4.8 → 1.4.10
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/names-nw-excluded-allcaps.mjs +112 -0
- package/dist/names-nw-excluded-allcaps.mjs.map +1 -0
- package/dist/wasm.d.mts +85 -28
- package/dist/wasm.mjs +1018 -323
- package/dist/wasm.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//#region src/data/names-nw-excluded-allcaps.json
|
|
2
|
+
var _comment = "English all-caps words/acronyms excluded from Japanese Hepburn matches";
|
|
3
|
+
var words = [
|
|
4
|
+
"ADD",
|
|
5
|
+
"ALL",
|
|
6
|
+
"AND",
|
|
7
|
+
"ANY",
|
|
8
|
+
"API",
|
|
9
|
+
"APP",
|
|
10
|
+
"APR",
|
|
11
|
+
"ARE",
|
|
12
|
+
"AS",
|
|
13
|
+
"AT",
|
|
14
|
+
"AUG",
|
|
15
|
+
"BIZ",
|
|
16
|
+
"BUT",
|
|
17
|
+
"BY",
|
|
18
|
+
"CAN",
|
|
19
|
+
"COM",
|
|
20
|
+
"CSS",
|
|
21
|
+
"CSV",
|
|
22
|
+
"DEC",
|
|
23
|
+
"DEL",
|
|
24
|
+
"DOC",
|
|
25
|
+
"EDU",
|
|
26
|
+
"END",
|
|
27
|
+
"EUR",
|
|
28
|
+
"FEB",
|
|
29
|
+
"FOR",
|
|
30
|
+
"FRI",
|
|
31
|
+
"GBP",
|
|
32
|
+
"GET",
|
|
33
|
+
"GMT",
|
|
34
|
+
"GOV",
|
|
35
|
+
"HAD",
|
|
36
|
+
"HE",
|
|
37
|
+
"HH",
|
|
38
|
+
"HAS",
|
|
39
|
+
"HTML",
|
|
40
|
+
"ID",
|
|
41
|
+
"IF",
|
|
42
|
+
"IN",
|
|
43
|
+
"INC",
|
|
44
|
+
"INFO",
|
|
45
|
+
"INT",
|
|
46
|
+
"ISO",
|
|
47
|
+
"ITS",
|
|
48
|
+
"JAN",
|
|
49
|
+
"JUL",
|
|
50
|
+
"JUN",
|
|
51
|
+
"KEY",
|
|
52
|
+
"LLC",
|
|
53
|
+
"LTD",
|
|
54
|
+
"MAR",
|
|
55
|
+
"MAY",
|
|
56
|
+
"MIL",
|
|
57
|
+
"MON",
|
|
58
|
+
"NAME",
|
|
59
|
+
"NET",
|
|
60
|
+
"NEW",
|
|
61
|
+
"NO",
|
|
62
|
+
"NOT",
|
|
63
|
+
"NOV",
|
|
64
|
+
"OCT",
|
|
65
|
+
"OF",
|
|
66
|
+
"ON",
|
|
67
|
+
"ONE",
|
|
68
|
+
"OR",
|
|
69
|
+
"ORG",
|
|
70
|
+
"OUT",
|
|
71
|
+
"PDF",
|
|
72
|
+
"POST",
|
|
73
|
+
"PUT",
|
|
74
|
+
"RFC",
|
|
75
|
+
"RUN",
|
|
76
|
+
"SAT",
|
|
77
|
+
"SEE",
|
|
78
|
+
"SEP",
|
|
79
|
+
"SET",
|
|
80
|
+
"SQL",
|
|
81
|
+
"SUN",
|
|
82
|
+
"TAR",
|
|
83
|
+
"THE",
|
|
84
|
+
"THU",
|
|
85
|
+
"TO",
|
|
86
|
+
"TUE",
|
|
87
|
+
"TWO",
|
|
88
|
+
"TXT",
|
|
89
|
+
"UID",
|
|
90
|
+
"URI",
|
|
91
|
+
"URL",
|
|
92
|
+
"USA",
|
|
93
|
+
"USD",
|
|
94
|
+
"UTC",
|
|
95
|
+
"VAL",
|
|
96
|
+
"VAT",
|
|
97
|
+
"WAS",
|
|
98
|
+
"WED",
|
|
99
|
+
"WERE",
|
|
100
|
+
"XLS",
|
|
101
|
+
"XML",
|
|
102
|
+
"YES",
|
|
103
|
+
"ZIP"
|
|
104
|
+
];
|
|
105
|
+
var names_nw_excluded_allcaps_default = {
|
|
106
|
+
_comment,
|
|
107
|
+
words
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
export { _comment, names_nw_excluded_allcaps_default as default, words };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=names-nw-excluded-allcaps.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names-nw-excluded-allcaps.mjs","names":[],"sources":["../../src/data/names-nw-excluded-allcaps.json"],"sourcesContent":[""],"mappings":""}
|
package/dist/wasm.d.mts
CHANGED
|
@@ -5,18 +5,45 @@ import { Tokenizer } from "@huggingface/tokenizers";
|
|
|
5
5
|
|
|
6
6
|
//#region src/types.d.ts
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Every detection layer produces these.
|
|
8
|
+
* Fields shared by every entity span in the source text.
|
|
10
9
|
*/
|
|
11
|
-
type
|
|
10
|
+
type EntityBase = {
|
|
12
11
|
start: number;
|
|
13
12
|
end: number;
|
|
14
13
|
label: string;
|
|
15
14
|
text: string;
|
|
16
15
|
score: number;
|
|
17
|
-
source: DetectionSource;
|
|
18
16
|
sourceDetail?: "custom-deny-list" | "custom-regex" | "gazetteer-extension";
|
|
19
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* A PII entity span found by a primary detection layer
|
|
20
|
+
* (regex, NER, legal forms, deny list, ...).
|
|
21
|
+
*/
|
|
22
|
+
type DetectedEntity = EntityBase & {
|
|
23
|
+
source: Exclude<DetectionSource, typeof DETECTION_SOURCES.COREFERENCE>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* An alias mention of a previously detected entity: a
|
|
27
|
+
* defined term ("the Seller") or a propagated bare
|
|
28
|
+
* mention ("Acme" after "Acme Corp.").
|
|
29
|
+
*
|
|
30
|
+
* `corefSourceText` is required by construction, so an
|
|
31
|
+
* alias cannot exist without the link back to its source
|
|
32
|
+
* entity. Placeholder numbering reads it to give the
|
|
33
|
+
* alias the same placeholder as the source. The link
|
|
34
|
+
* travels with the entity instead of living in a
|
|
35
|
+
* side-channel map that a producer could forget to
|
|
36
|
+
* write — or that a later pass could clear.
|
|
37
|
+
*/
|
|
38
|
+
type CorefAliasEntity = EntityBase & {
|
|
39
|
+
source: typeof DETECTION_SOURCES.COREFERENCE; /** Full text of the source entity this alias refers to. */
|
|
40
|
+
corefSourceText: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A detected PII entity span in the source text.
|
|
44
|
+
* Every detection layer produces these.
|
|
45
|
+
*/
|
|
46
|
+
type Entity = DetectedEntity | CorefAliasEntity;
|
|
20
47
|
/**
|
|
21
48
|
* Entity after human review. Extends the base Entity
|
|
22
49
|
* with a review decision.
|
|
@@ -253,6 +280,13 @@ type Dictionaries = {
|
|
|
253
280
|
* Merged with legacy config names at init time.
|
|
254
281
|
*/
|
|
255
282
|
surnames?: Readonly<Record<string, readonly string[]>>;
|
|
283
|
+
/**
|
|
284
|
+
* Non-Western name tokens per locale code
|
|
285
|
+
* (e.g., "in", "ar", "ja-latn", "ko", "zh-latn",
|
|
286
|
+
* "th", "vi", "fil", "id"). Merged with bundled
|
|
287
|
+
* names-nw-*.json data at init time.
|
|
288
|
+
*/
|
|
289
|
+
nonWesternNames?: Readonly<Record<string, readonly string[]>>;
|
|
256
290
|
/**
|
|
257
291
|
* Pre-loaded deny-list dictionaries keyed by
|
|
258
292
|
* dictionary ID (e.g., "courts/CZ", "banks/DE").
|
|
@@ -521,6 +555,10 @@ declare const buildUnifiedSearch: (config: PipelineConfig, gazetteerEntries?: Ga
|
|
|
521
555
|
* shallow copies (spread). Uses position + label so the
|
|
522
556
|
* key is identical for the original object and any
|
|
523
557
|
* `{ ...entity }` copy produced by mergeAndDedup.
|
|
558
|
+
*
|
|
559
|
+
* @deprecated No longer used internally: coref alias
|
|
560
|
+
* links travel on the entities themselves
|
|
561
|
+
* (`corefSourceText`). Kept for API compatibility.
|
|
524
562
|
*/
|
|
525
563
|
declare const corefKey: (e: Entity) => string;
|
|
526
564
|
/**
|
|
@@ -539,11 +577,20 @@ type NameCorpusData = {
|
|
|
539
577
|
firstNames: ReadonlySet<string>;
|
|
540
578
|
surnames: ReadonlySet<string>;
|
|
541
579
|
titleTokens: ReadonlySet<string>;
|
|
542
|
-
|
|
580
|
+
/** Abbreviation-style titles whose trailing dot is
|
|
581
|
+
* part of the title, not a sentence boundary.
|
|
582
|
+
* Contains the lowercase, dot-stripped form
|
|
583
|
+
* (e.g., "dr", "smt", "atty"). */
|
|
584
|
+
titleAbbreviations: ReadonlySet<string>;
|
|
585
|
+
excludedWords: ReadonlySet<string>; /** Non-Western name tokens merged across all locales. */
|
|
586
|
+
nonWesternNames: ReadonlySet<string>; /** All-caps acronyms excluded from name detection. */
|
|
587
|
+
excludedAllCaps: ReadonlySet<string>; /** Raw arrays exposed for deny-list AC integration. */
|
|
543
588
|
firstNamesList: readonly string[];
|
|
544
589
|
surnamesList: readonly string[];
|
|
545
590
|
titlesList: readonly string[];
|
|
546
591
|
excludedList: readonly string[];
|
|
592
|
+
nonWesternNamesList: readonly string[];
|
|
593
|
+
excludedAllCapsList: readonly string[];
|
|
547
594
|
};
|
|
548
595
|
/**
|
|
549
596
|
* All cached state for a single pipeline run (or
|
|
@@ -582,17 +629,6 @@ type PipelineContext = {
|
|
|
582
629
|
zoneHeadingPatterns: RegExp[] | null;
|
|
583
630
|
zoneSigningPatterns: RegExp[] | null;
|
|
584
631
|
zoneInitPromise: Promise<void> | null;
|
|
585
|
-
/**
|
|
586
|
-
* Maps coreference entities to their source entity
|
|
587
|
-
* text. Populated by findCoreferenceSpans, consumed
|
|
588
|
-
* by buildPlaceholderMap for consistent placeholder
|
|
589
|
-
* numbering across aliases and source entities.
|
|
590
|
-
*
|
|
591
|
-
* Keyed by `start:end:label` composite string so
|
|
592
|
-
* lookups survive shallow copies (e.g. from
|
|
593
|
-
* mergeAndDedup's spread operator).
|
|
594
|
-
*/
|
|
595
|
-
corefSourceMap: Map<string, string>;
|
|
596
632
|
};
|
|
597
633
|
/** Create a fresh, empty pipeline context. */
|
|
598
634
|
declare const createPipelineContext: () => PipelineContext;
|
|
@@ -663,12 +699,11 @@ declare const runPipeline: (options: PipelineOptions) => Promise<Entity[]>;
|
|
|
663
699
|
* Placeholder format: [LABEL_N] where LABEL is uppercase
|
|
664
700
|
* and N is a 1-based counter per label.
|
|
665
701
|
*
|
|
666
|
-
* @param
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
* Defaults to `defaultContext` for single-tenant usage.
|
|
702
|
+
* @param _ctx Unused. Kept for signature compatibility;
|
|
703
|
+
* coref alias links now travel on the entities
|
|
704
|
+
* themselves (`corefSourceText`).
|
|
670
705
|
*/
|
|
671
|
-
declare const buildPlaceholderMap: (entities: Entity[],
|
|
706
|
+
declare const buildPlaceholderMap: (entities: Entity[], _ctx?: PipelineContext) => Map<string, string>;
|
|
672
707
|
/**
|
|
673
708
|
* Apply redactions to the source text, replacing each
|
|
674
709
|
* confirmed entity span using the configured operator.
|
|
@@ -811,11 +846,14 @@ declare const extractDefinedTerms: (fullText: string, entities: Entity[], ctx?:
|
|
|
811
846
|
* character before the start and after the end are NOT
|
|
812
847
|
* word characters (letter/digit).
|
|
813
848
|
*
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
*
|
|
849
|
+
* Each returned alias carries `corefSourceText` linking
|
|
850
|
+
* it to its source entity text, for consistent
|
|
851
|
+
* placeholder numbering.
|
|
852
|
+
*
|
|
853
|
+
* @param _ctx Unused. Kept for signature compatibility;
|
|
854
|
+
* alias links now travel on the entities themselves.
|
|
817
855
|
*/
|
|
818
|
-
declare const findCoreferenceSpans: (fullText: string, terms: DefinedTerm[],
|
|
856
|
+
declare const findCoreferenceSpans: (fullText: string, terms: DefinedTerm[], _ctx?: PipelineContext) => Entity[];
|
|
819
857
|
//#endregion
|
|
820
858
|
//#region src/detectors/org-propagation.d.ts
|
|
821
859
|
/**
|
|
@@ -824,10 +862,17 @@ declare const findCoreferenceSpans: (fullText: string, terms: DefinedTerm[], ctx
|
|
|
824
862
|
* to get the base name, and re-scan the full text for
|
|
825
863
|
* bare mentions of that base name. Returns new entities
|
|
826
864
|
* for occurrences not already covered.
|
|
865
|
+
*
|
|
866
|
+
* Propagated mentions are coref aliases: each carries
|
|
867
|
+
* `corefSourceText` linking it to the full seed entity
|
|
868
|
+
* text, so placeholder numbering assigns the bare
|
|
869
|
+
* mention the same placeholder as its source ("Acme"
|
|
870
|
+
* and "Acme Corp." both become [ORGANIZATION_1]).
|
|
827
871
|
*/
|
|
828
872
|
declare const propagateOrgNames: (entities: Entity[], fullText: string) => Entity[];
|
|
829
873
|
//#endregion
|
|
830
874
|
//#region src/detectors/names.d.ts
|
|
875
|
+
declare const getNameCorpusNonWesternNames: (ctx?: PipelineContext) => readonly string[];
|
|
831
876
|
/**
|
|
832
877
|
* Load name corpus data from injected dictionaries
|
|
833
878
|
* and legacy config files. Merges all sources.
|
|
@@ -841,14 +886,18 @@ declare const propagateOrgNames: (entities: Entity[], fullText: string) => Entit
|
|
|
841
886
|
* omitted, only legacy config files are used.
|
|
842
887
|
*/
|
|
843
888
|
declare const initNameCorpus: (ctx?: PipelineContext, dictionaries?: Dictionaries, languages?: readonly string[]) => Promise<void>;
|
|
889
|
+
type NameCorpusDetectionOptions = {
|
|
890
|
+
mode?: "full" | "supplemental";
|
|
891
|
+
};
|
|
844
892
|
/**
|
|
845
893
|
* Detect person names by looking up tokens against the
|
|
846
894
|
* name corpus, then chaining adjacent name-like tokens.
|
|
895
|
+
* Handles both Western and non-Western name patterns.
|
|
847
896
|
*
|
|
848
897
|
* Requires initNameCorpus() to have been called first.
|
|
849
898
|
* If not initialized, returns an empty array.
|
|
850
899
|
*
|
|
851
|
-
* Scoring:
|
|
900
|
+
* Scoring (Western):
|
|
852
901
|
* TITLE + NAME/SURNAME → 0.95
|
|
853
902
|
* NAME + NAME/SURNAME → 0.9
|
|
854
903
|
* SURNAME + NAME/SURNAME → 0.9
|
|
@@ -856,8 +905,16 @@ declare const initNameCorpus: (ctx?: PipelineContext, dictionaries?: Dictionarie
|
|
|
856
905
|
* ABBREVIATION + NAME → 0.7
|
|
857
906
|
* Standalone NAME → 0.5 (low confidence)
|
|
858
907
|
* Standalone SURNAME → skip (too ambiguous)
|
|
908
|
+
*
|
|
909
|
+
* Scoring (non-Western, when chain contains nonWestern tokens):
|
|
910
|
+
* TITLE + (nonWestern|CAPITALIZED) → 0.95
|
|
911
|
+
* JA_SUFFIX + (CAPITALIZED|nonWestern) → 0.9
|
|
912
|
+
* ARABIC_CONNECTOR + nonWestern → 0.9
|
|
913
|
+
* 2+ nonWestern tokens → 0.9
|
|
914
|
+
* nonWestern + (CAPITALIZED|ABBREVIATION) → 0.9
|
|
915
|
+
* Standalone nonWestern mid-sentence → 0.5
|
|
859
916
|
*/
|
|
860
|
-
declare const detectNameCorpus: (fullText: string, ctx?: PipelineContext) => Entity[];
|
|
917
|
+
declare const detectNameCorpus: (fullText: string, ctx?: PipelineContext, options?: NameCorpusDetectionOptions) => Entity[];
|
|
861
918
|
//#endregion
|
|
862
919
|
//#region src/unified-search.d.ts
|
|
863
920
|
type UnifiedResult = {
|
|
@@ -1122,5 +1179,5 @@ declare const levenshtein: (rawA: string, rawB: string) => number;
|
|
|
1122
1179
|
*/
|
|
1123
1180
|
declare const normalizeForSearch: (text: string) => string;
|
|
1124
1181
|
//#endregion
|
|
1125
|
-
export { type AnonymisationOperator, CURRENCY_PATTERN_META, type CountryCode, type CustomDenyListEntry, type CustomRegexPattern, DATE_PATTERN_META, DEFAULT_ENTITY_LABELS, DEFAULT_OPERATOR_CONFIG, DETECTION_SOURCES, DETECTOR_PRIORITY, type DefinitionPattern, type DenyListCategory, type DenyListData, type DetectionSource, type Dictionaries, type DictionaryMeta, type DocumentZone, type Entity, type EntityResult, type GazetteerData, type GazetteerEntry, type HotwordRule, type NameCorpusData, type NerInferenceFn, OPERATOR_REGISTRY, OPERATOR_TYPES, type OperatorConfig, type OperatorType, type PipelineConfig, type PipelineContext, type PipelineOptions, type PipelineSearchOptions, REGEX_META, REGEX_PATTERNS, REGIONS, type RawInferenceResult, type RedactionResult, type RegexMeta, type RegionId, type ReviewDecision, type ReviewedEntity, type TriggerExtension, type TriggerGroupConfig, type TriggerRule, type TriggerStrategy, type TriggerValidation, type UnifiedResult, type UnifiedSearchInstance, ZONE_SCORE_ADJUSTMENTS, type ZoneSpan, applyHotwordRules, applyZoneAdjustments, boostNearMissEntities, buildDenyList, buildGazetteerPatterns, buildLegalFormPatterns, buildPlaceholderMap, buildStreetTypePatterns, buildTriggerPatterns, buildUnifiedSearch, chunkText, classifyZones, computeChunkOffsets, corefKey, createPipelineContext, deanonymise, decodeSpans, decodeTokenSpans, detectNameCorpus, ensureDenyListData, exportRedactionKey, extractDefinedTerms, filterFalsePositives, findCoreferenceSpans, getCurrencyPatterns, getDatePatterns, initAddressComponents, initHotwordRules, initNameCorpus, initZoneClassifier, levenshtein, mergeAndDedup, mergeChunkEntities, normalizeForSearch, prepareBatch, preparePipelineSearch, processAddressSeeds, processDenyListMatches, processGazetteerMatches, processLegalFormMatches, processRegexMatches, processTriggerMatches, propagateOrgNames, redactText, resolveCountries, resolveOperator, runPipeline, runUnifiedSearch, sanitizeEntities, tokenizeText, warmLegalRoleHeads };
|
|
1182
|
+
export { type AnonymisationOperator, CURRENCY_PATTERN_META, type CountryCode, type CustomDenyListEntry, type CustomRegexPattern, DATE_PATTERN_META, DEFAULT_ENTITY_LABELS, DEFAULT_OPERATOR_CONFIG, DETECTION_SOURCES, DETECTOR_PRIORITY, type DefinitionPattern, type DenyListCategory, type DenyListData, type DetectionSource, type Dictionaries, type DictionaryMeta, type DocumentZone, type Entity, type EntityResult, type GazetteerData, type GazetteerEntry, type HotwordRule, type NameCorpusData, type NerInferenceFn, OPERATOR_REGISTRY, OPERATOR_TYPES, type OperatorConfig, type OperatorType, type PipelineConfig, type PipelineContext, type PipelineOptions, type PipelineSearchOptions, REGEX_META, REGEX_PATTERNS, REGIONS, type RawInferenceResult, type RedactionResult, type RegexMeta, type RegionId, type ReviewDecision, type ReviewedEntity, type TriggerExtension, type TriggerGroupConfig, type TriggerRule, type TriggerStrategy, type TriggerValidation, type UnifiedResult, type UnifiedSearchInstance, ZONE_SCORE_ADJUSTMENTS, type ZoneSpan, applyHotwordRules, applyZoneAdjustments, boostNearMissEntities, buildDenyList, buildGazetteerPatterns, buildLegalFormPatterns, buildPlaceholderMap, buildStreetTypePatterns, buildTriggerPatterns, buildUnifiedSearch, chunkText, classifyZones, computeChunkOffsets, corefKey, createPipelineContext, deanonymise, decodeSpans, decodeTokenSpans, detectNameCorpus, ensureDenyListData, exportRedactionKey, extractDefinedTerms, filterFalsePositives, findCoreferenceSpans, getCurrencyPatterns, getDatePatterns, getNameCorpusNonWesternNames, initAddressComponents, initHotwordRules, initNameCorpus, initZoneClassifier, levenshtein, mergeAndDedup, mergeChunkEntities, normalizeForSearch, prepareBatch, preparePipelineSearch, processAddressSeeds, processDenyListMatches, processGazetteerMatches, processLegalFormMatches, processRegexMatches, processTriggerMatches, propagateOrgNames, redactText, resolveCountries, resolveOperator, runPipeline, runUnifiedSearch, sanitizeEntities, tokenizeText, warmLegalRoleHeads };
|
|
1126
1183
|
//# sourceMappingURL=wasm.d.mts.map
|