@stll/anonymize-wasm 1.2.0 → 1.4.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/dist/address-boundaries.mjs +113 -5
- package/dist/address-stop-keywords.mjs +137 -0
- package/dist/address-stop-keywords.mjs.map +1 -0
- package/dist/address-stopwords.mjs +81 -0
- package/dist/address-stopwords.mjs.map +1 -0
- package/dist/address-street-types.mjs +67 -4
- package/dist/clause-noun-heads.mjs +75 -0
- package/dist/clause-noun-heads.mjs.map +1 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.mjs +85 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/constants2.d.mts +65 -0
- package/dist/coreference.es.mjs +22 -0
- package/dist/coreference.es.mjs.map +1 -0
- package/dist/coreference.fr.mjs +32 -0
- package/dist/coreference.fr.mjs.map +1 -0
- package/dist/coreference.it.mjs +27 -0
- package/dist/coreference.it.mjs.map +1 -0
- package/dist/coreference.pl.mjs +27 -0
- package/dist/coreference.pl.mjs.map +1 -0
- package/dist/coreference.pt-br.mjs +14 -0
- package/dist/coreference.pt-br.mjs.map +1 -0
- package/dist/coreference.sk.mjs +22 -5
- package/dist/generic-roles.mjs +179 -1
- package/dist/hotword-rules.mjs +7 -3
- package/dist/legal-forms.mjs +3 -0
- package/dist/legal-role-heads.cs.mjs +42 -0
- package/dist/legal-role-heads.cs.mjs.map +1 -0
- package/dist/legal-role-heads.de.mjs +33 -0
- package/dist/legal-role-heads.de.mjs.map +1 -0
- package/dist/legal-role-heads.en.mjs +37 -0
- package/dist/legal-role-heads.en.mjs.map +1 -0
- package/dist/legal-role-heads.es.mjs +54 -0
- package/dist/legal-role-heads.es.mjs.map +1 -0
- package/dist/legal-role-heads.fr.mjs +72 -0
- package/dist/legal-role-heads.fr.mjs.map +1 -0
- package/dist/legal-role-heads.it.mjs +68 -0
- package/dist/legal-role-heads.it.mjs.map +1 -0
- package/dist/legal-role-heads.pl.mjs +84 -0
- package/dist/legal-role-heads.pl.mjs.map +1 -0
- package/dist/legal-role-heads.pt-br.mjs +63 -0
- package/dist/legal-role-heads.pt-br.mjs.map +1 -0
- package/dist/legal-role-heads.sk.mjs +80 -0
- package/dist/legal-role-heads.sk.mjs.map +1 -0
- package/dist/manifest.mjs +21 -8
- package/dist/names-exclusions.mjs +21 -1
- package/dist/person-stopwords.mjs +121 -1
- package/dist/section-headings.mjs +15 -3
- package/dist/sentence-verb-indicators.mjs +223 -0
- package/dist/sentence-verb-indicators.mjs.map +1 -0
- package/dist/triggers.cs.mjs +107 -3
- package/dist/triggers.en.mjs +32 -0
- package/dist/triggers.es.mjs +43 -4
- package/dist/triggers.fr.mjs +206 -7
- package/dist/triggers.it.mjs +26 -4
- package/dist/triggers.pl.mjs +191 -4
- package/dist/triggers.pt-br.mjs +193 -0
- package/dist/triggers.pt-br.mjs.map +1 -0
- package/dist/triggers.sk.mjs +493 -0
- package/dist/vite.mjs.map +1 -1
- package/dist/wasm.d.mts +56 -39
- package/dist/wasm.mjs +2382 -1408
- package/dist/wasm.mjs.map +1 -1
- package/package.json +7 -2
package/dist/wasm.d.mts
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
|
+
import { a as OPERATOR_TYPES, i as DetectionSource, n as DETECTION_SOURCES, o as OperatorType, r as DETECTOR_PRIORITY, t as DEFAULT_ENTITY_LABELS } from "./constants2.mjs";
|
|
1
2
|
import { Validator } from "@stll/stdnum";
|
|
2
3
|
import { Match, PatternEntry, TextSearch } from "@stll/text-search";
|
|
3
4
|
import { Tokenizer } from "@huggingface/tokenizers";
|
|
4
5
|
|
|
5
6
|
//#region src/types.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Source of a detected entity span.
|
|
8
|
-
* Ordered by detection layer in the pipeline.
|
|
9
|
-
*/
|
|
10
|
-
declare const DETECTION_SOURCES: {
|
|
11
|
-
readonly TRIGGER: "trigger";
|
|
12
|
-
readonly REGEX: "regex";
|
|
13
|
-
readonly DENY_LIST: "deny-list";
|
|
14
|
-
readonly LEGAL_FORM: "legal-form";
|
|
15
|
-
readonly GAZETTEER: "gazetteer";
|
|
16
|
-
readonly NER: "ner";
|
|
17
|
-
readonly COREFERENCE: "coreference";
|
|
18
|
-
};
|
|
19
|
-
type DetectionSource = (typeof DETECTION_SOURCES)[keyof typeof DETECTION_SOURCES];
|
|
20
|
-
/**
|
|
21
|
-
* Priority levels for detection sources.
|
|
22
|
-
* Higher = more structurally reliable. Used during
|
|
23
|
-
* overlap resolution so deterministic detectors beat
|
|
24
|
-
* probabilistic ones regardless of raw score.
|
|
25
|
-
*/
|
|
26
|
-
declare const DETECTOR_PRIORITY: Record<DetectionSource, number>;
|
|
27
7
|
/**
|
|
28
8
|
* A detected PII entity span in the source text.
|
|
29
9
|
* Every detection layer produces these.
|
|
@@ -62,6 +42,16 @@ type GazetteerEntry = {
|
|
|
62
42
|
/** Extraction strategy — closed discriminated union. */
|
|
63
43
|
type TriggerStrategy = {
|
|
64
44
|
type: "to-next-comma";
|
|
45
|
+
/**
|
|
46
|
+
* Optional list of lowercase keywords that terminate
|
|
47
|
+
* the value scan, in addition to commas/newlines. Useful
|
|
48
|
+
* for triggers like court names that may continue past
|
|
49
|
+
* a missing comma into adjacent clause text ("Městským
|
|
50
|
+
* soudem v Praze dne 1. 1. 2020"); listing `"dne"` here
|
|
51
|
+
* stops the scan at the date boundary. Matched on a
|
|
52
|
+
* word-boundary, case-insensitive.
|
|
53
|
+
*/
|
|
54
|
+
stopWords?: string[];
|
|
65
55
|
} | {
|
|
66
56
|
type: "to-end-of-line";
|
|
67
57
|
} | {
|
|
@@ -72,6 +62,19 @@ type TriggerStrategy = {
|
|
|
72
62
|
} | {
|
|
73
63
|
type: "address";
|
|
74
64
|
maxChars?: number;
|
|
65
|
+
} | {
|
|
66
|
+
/**
|
|
67
|
+
* Extract the first regex match in the value text.
|
|
68
|
+
* Useful for shape-bounded values that follow a
|
|
69
|
+
* label on the same line as other fields, where
|
|
70
|
+
* `to-end-of-line` would over-capture. The pattern
|
|
71
|
+
* is anchored to the start of the (already
|
|
72
|
+
* leading-whitespace-stripped) value, so use
|
|
73
|
+
* `(?:.*?)` prefix only when intentional.
|
|
74
|
+
*/
|
|
75
|
+
type: "match-pattern";
|
|
76
|
+
pattern: string;
|
|
77
|
+
flags?: string;
|
|
75
78
|
};
|
|
76
79
|
/** Validation rules — closed discriminated union. */
|
|
77
80
|
type TriggerValidation = {
|
|
@@ -90,7 +93,21 @@ type TriggerValidation = {
|
|
|
90
93
|
type: "matches-pattern";
|
|
91
94
|
pattern: string;
|
|
92
95
|
flags?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Run a named stdnum validator (checksum + length)
|
|
99
|
+
* against the captured value. Keeps the trigger
|
|
100
|
+
* path symmetrical with the formatted-regex
|
|
101
|
+
* detectors so e.g. `CPF nº 00000000000` does not
|
|
102
|
+
* survive as a tax-ID entity.
|
|
103
|
+
*/
|
|
104
|
+
| {
|
|
105
|
+
type: "valid-id";
|
|
106
|
+
validator: ValidIdValidator;
|
|
93
107
|
};
|
|
108
|
+
/** Built-in stdnum validators that can be referenced
|
|
109
|
+
* by `valid-id` validations. */
|
|
110
|
+
type ValidIdValidator = "br.cpf" | "br.cnpj";
|
|
94
111
|
/** Auto-generated trigger variants — closed set. */
|
|
95
112
|
type TriggerExtension = "add-colon" | "add-trailing-space" | "add-colon-space" | "normalize-spaces";
|
|
96
113
|
/** V2 trigger config entry (JSON shape). */
|
|
@@ -124,6 +141,9 @@ type CompiledValidation = {
|
|
|
124
141
|
} | {
|
|
125
142
|
type: "matches-pattern";
|
|
126
143
|
re: RegExp;
|
|
144
|
+
} | {
|
|
145
|
+
type: "valid-id";
|
|
146
|
+
check: (value: string) => boolean;
|
|
127
147
|
};
|
|
128
148
|
/**
|
|
129
149
|
* Runtime rule — one per trigger string after
|
|
@@ -136,12 +156,6 @@ type TriggerRule = {
|
|
|
136
156
|
validations: CompiledValidation[];
|
|
137
157
|
includeTrigger: boolean;
|
|
138
158
|
};
|
|
139
|
-
/**
|
|
140
|
-
* Anonymisation operator types. Each operator defines
|
|
141
|
-
* how a confirmed entity is replaced in the output.
|
|
142
|
-
*/
|
|
143
|
-
declare const OPERATOR_TYPES: readonly ["replace", "redact"];
|
|
144
|
-
type OperatorType = (typeof OPERATOR_TYPES)[number];
|
|
145
159
|
/** Per-label operator selection. Key is the entity label. */
|
|
146
160
|
type OperatorConfig = {
|
|
147
161
|
/** Operator per label. Missing labels default to "replace". */operators: Record<string, OperatorType>; /** Custom replacement string for the redact operator. */
|
|
@@ -301,16 +315,6 @@ type PipelineConfig = {
|
|
|
301
315
|
*/
|
|
302
316
|
dictionaries?: Dictionaries;
|
|
303
317
|
};
|
|
304
|
-
/**
|
|
305
|
-
* Canonical entity labels used across the pipeline.
|
|
306
|
-
* NER models may use different native labels; the bench
|
|
307
|
-
* NER wrapper maps model output to these canonical names.
|
|
308
|
-
*
|
|
309
|
-
* These labels are ephemeral: entities are regenerated on
|
|
310
|
-
* every pipeline run and never persisted to the database.
|
|
311
|
-
* Renaming a label here requires no migration.
|
|
312
|
-
*/
|
|
313
|
-
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", "registration number", "credit card number", "passport number", "monetary amount", "land parcel"];
|
|
314
318
|
//#endregion
|
|
315
319
|
//#region src/detectors/regex.d.ts
|
|
316
320
|
type RegexMeta = {
|
|
@@ -502,7 +506,9 @@ type PipelineContext = {
|
|
|
502
506
|
allowList: ReadonlySet<string> | null;
|
|
503
507
|
allowListPromise: Promise<ReadonlySet<string>> | null;
|
|
504
508
|
personStopwords: ReadonlySet<string> | null;
|
|
505
|
-
personStopwordsPromise: Promise<ReadonlySet<string>> | null;
|
|
509
|
+
personStopwordsPromise: Promise<ReadonlySet<string>> | null;
|
|
510
|
+
addressStopwords: ReadonlySet<string> | null;
|
|
511
|
+
addressStopwordsPromise: Promise<ReadonlySet<string>> | null; /** First-name exclusions for stopword filtering. */
|
|
506
512
|
firstNameExclusions: ReadonlySet<string> | null;
|
|
507
513
|
firstNameExclusionCorpusLen: number;
|
|
508
514
|
genericRoles: ReadonlySet<string> | null;
|
|
@@ -627,6 +633,7 @@ declare const DEFAULT_OPERATOR_CONFIG: OperatorConfig;
|
|
|
627
633
|
declare const resolveOperator: (config: OperatorConfig, label: string) => OperatorType;
|
|
628
634
|
//#endregion
|
|
629
635
|
//#region src/detectors/legal-forms.d.ts
|
|
636
|
+
declare const warmLegalRoleHeads: () => Promise<void>;
|
|
630
637
|
/**
|
|
631
638
|
* Build legal form regex pattern strings.
|
|
632
639
|
* Returns an array of regex strings for the unified
|
|
@@ -638,6 +645,14 @@ declare const buildLegalFormPatterns: () => Promise<string[]>;
|
|
|
638
645
|
* Process legal form matches from the unified search.
|
|
639
646
|
* Receives all matches; filters to the legal forms
|
|
640
647
|
* slice via sliceStart/sliceEnd.
|
|
648
|
+
*
|
|
649
|
+
* The role-head trimming step reads per-language data from
|
|
650
|
+
* a cache that `runPipeline` warms via `warmLegalRoleHeads()`
|
|
651
|
+
* before calling this. Callers that invoke
|
|
652
|
+
* `processLegalFormMatches` directly (without going through
|
|
653
|
+
* `runPipeline`) must `await warmLegalRoleHeads()` first;
|
|
654
|
+
* otherwise the trim falls back to a no-op and sentence-
|
|
655
|
+
* fragment fixes do not apply.
|
|
641
656
|
*/
|
|
642
657
|
declare const processLegalFormMatches: (allMatches: Match[], sliceStart: number, sliceEnd: number, fullText?: string) => Entity[];
|
|
643
658
|
//#endregion
|
|
@@ -819,6 +834,8 @@ type CountryCode = NonNullRegion[keyof NonNullRegion][number];
|
|
|
819
834
|
declare const resolveCountries: (regions?: string[], countries?: string[]) => Set<string> | null;
|
|
820
835
|
//#endregion
|
|
821
836
|
//#region src/filters/false-positives.d.ts
|
|
837
|
+
/** Ensure street-type vocabulary is loaded. */
|
|
838
|
+
declare const initAddressComponents: () => Promise<void>;
|
|
822
839
|
/**
|
|
823
840
|
* Filter out entities that are likely false positives:
|
|
824
841
|
* template placeholders, clause/section numbers,
|
|
@@ -1035,5 +1052,5 @@ declare const levenshtein: (rawA: string, rawB: string) => number;
|
|
|
1035
1052
|
*/
|
|
1036
1053
|
declare const normalizeForSearch: (text: string) => string;
|
|
1037
1054
|
//#endregion
|
|
1038
|
-
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, 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, initHotwordRules, initNameCorpus, initZoneClassifier, levenshtein, mergeAndDedup, mergeChunkEntities, normalizeForSearch, prepareBatch, processAddressSeeds, processDenyListMatches, processGazetteerMatches, processLegalFormMatches, processRegexMatches, processTriggerMatches, propagateOrgNames, redactText, resolveCountries, resolveOperator, runPipeline, runUnifiedSearch, sanitizeEntities, tokenizeText };
|
|
1055
|
+
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, 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, processAddressSeeds, processDenyListMatches, processGazetteerMatches, processLegalFormMatches, processRegexMatches, processTriggerMatches, propagateOrgNames, redactText, resolveCountries, resolveOperator, runPipeline, runUnifiedSearch, sanitizeEntities, tokenizeText, warmLegalRoleHeads };
|
|
1039
1056
|
//# sourceMappingURL=wasm.d.mts.map
|