@stll/anonymize-wasm 1.4.11 → 1.5.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-stopwords.mjs +2 -0
- package/dist/allow-list.mjs +1 -0
- package/dist/constants.mjs +1 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/constants2.d.mts +1 -1
- package/dist/wasm.d.mts +43 -9
- package/dist/wasm.mjs +223 -35
- package/dist/wasm.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -6,6 +6,7 @@ var address_stopwords_default = {
|
|
|
6
6
|
"agenda",
|
|
7
7
|
"agent",
|
|
8
8
|
"amount",
|
|
9
|
+
"basic",
|
|
9
10
|
"brent",
|
|
10
11
|
"central",
|
|
11
12
|
"centro",
|
|
@@ -32,6 +33,7 @@ var address_stopwords_default = {
|
|
|
32
33
|
"price",
|
|
33
34
|
"principal",
|
|
34
35
|
"rate",
|
|
36
|
+
"rent",
|
|
35
37
|
"registro",
|
|
36
38
|
"schedule",
|
|
37
39
|
"se",
|
package/dist/allow-list.mjs
CHANGED
package/dist/constants.mjs
CHANGED
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 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;AACf;;;;;;;AAWA,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;AAC3B;;;;;AAMA,MAAa,iBAAiB,CAAC,WAAW,QAAQ;;;;;;;;;;AAalD,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
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 \"crypto\",\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;AACf;;;;;;;AAWA,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;AAC3B;;;;;AAMA,MAAa,iBAAiB,CAAC,WAAW,QAAQ;;;;;;;;;;AAalD,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
package/dist/constants2.d.mts
CHANGED
|
@@ -61,7 +61,7 @@ type OperatorType = (typeof OPERATOR_TYPES)[number];
|
|
|
61
61
|
* every pipeline run and never persisted to the database.
|
|
62
62
|
* Renaming a label here requires no migration.
|
|
63
63
|
*/
|
|
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"];
|
|
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", "crypto", "monetary amount", "land parcel", "misc"];
|
|
65
65
|
//#endregion
|
|
66
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 };
|
|
67
67
|
//# sourceMappingURL=constants2.d.mts.map
|
package/dist/wasm.d.mts
CHANGED
|
@@ -392,7 +392,8 @@ type RegexMeta = {
|
|
|
392
392
|
label: string;
|
|
393
393
|
score: number;
|
|
394
394
|
sourceDetail?: Entity["sourceDetail"]; /** Post-match stdnum validator for confirmation. */
|
|
395
|
-
validator?: Validator;
|
|
395
|
+
validator?: Validator; /** Extract the identifier portion when context is part of the regex span. */
|
|
396
|
+
validatorInput?: (text: string) => string;
|
|
396
397
|
};
|
|
397
398
|
/** Flat pattern array for text-search. */
|
|
398
399
|
declare const REGEX_PATTERNS: readonly string[];
|
|
@@ -582,7 +583,12 @@ type NameCorpusData = {
|
|
|
582
583
|
* Contains the lowercase, dot-stripped form
|
|
583
584
|
* (e.g., "dr", "smt", "atty"). */
|
|
584
585
|
titleAbbreviations: ReadonlySet<string>;
|
|
585
|
-
excludedWords: ReadonlySet<string>;
|
|
586
|
+
excludedWords: ReadonlySet<string>;
|
|
587
|
+
/** Lowercased common English words. A name chain whose
|
|
588
|
+
* every token is a common word (e.g. "Loan Documents",
|
|
589
|
+
* where "Loan" coincides with a Vietnamese given name)
|
|
590
|
+
* is treated as a common-word phrase, not a person. */
|
|
591
|
+
commonWords: ReadonlySet<string>; /** Non-Western name tokens merged across all locales. */
|
|
586
592
|
nonWesternNames: ReadonlySet<string>; /** All-caps acronyms excluded from name detection. */
|
|
587
593
|
excludedAllCaps: ReadonlySet<string>; /** Raw arrays exposed for deny-list AC integration. */
|
|
588
594
|
firstNamesList: readonly string[];
|
|
@@ -1110,17 +1116,45 @@ declare const prepareBatch: (tokenizer: Tokenizer, texts: string[], entities: st
|
|
|
1110
1116
|
};
|
|
1111
1117
|
//#endregion
|
|
1112
1118
|
//#region src/util/chunker.d.ts
|
|
1119
|
+
/** A chunk paired with its start offset in the source text. */
|
|
1120
|
+
type ChunkSpan = {
|
|
1121
|
+
text: string;
|
|
1122
|
+
offset: number;
|
|
1123
|
+
};
|
|
1113
1124
|
/**
|
|
1114
|
-
* Split text into overlapping chunks
|
|
1115
|
-
*
|
|
1116
|
-
* (rough approximation of token limits).
|
|
1125
|
+
* Split text into overlapping chunks, each paired with its
|
|
1126
|
+
* exact start offset in the source text.
|
|
1117
1127
|
*
|
|
1118
|
-
*
|
|
1128
|
+
* Carrying the offset out of the splitter is the robust way to
|
|
1129
|
+
* map chunk-local entity offsets back to document offsets:
|
|
1130
|
+
* downstream code never has to re-locate a chunk by content
|
|
1131
|
+
* search (which mis-locates when boilerplate repeats; see
|
|
1132
|
+
* computeChunkOffsets).
|
|
1133
|
+
*
|
|
1134
|
+
* Character-based splitting (rough token approximation for
|
|
1135
|
+
* GLiNER's ~512 token window); breaks at sentence boundaries
|
|
1136
|
+
* when possible.
|
|
1137
|
+
*/
|
|
1138
|
+
declare const chunkTextWithOffsets: (text: string) => ChunkSpan[];
|
|
1139
|
+
/**
|
|
1140
|
+
* Split text into overlapping chunks for GLiNER's ~512 token
|
|
1141
|
+
* context window. Character-based splitting (rough token
|
|
1142
|
+
* approximation); breaks at sentence boundaries when possible.
|
|
1143
|
+
*
|
|
1144
|
+
* Prefer chunkTextWithOffsets when you also need each chunk's
|
|
1145
|
+
* document offset.
|
|
1119
1146
|
*/
|
|
1120
1147
|
declare const chunkText: (text: string) => string[];
|
|
1121
1148
|
/**
|
|
1122
|
-
* Compute the
|
|
1123
|
-
*
|
|
1149
|
+
* Compute the start offset of each chunk within the original
|
|
1150
|
+
* document text by content search.
|
|
1151
|
+
*
|
|
1152
|
+
* @deprecated Re-locates each chunk with `indexOf`, which can
|
|
1153
|
+
* match the wrong position when identical content repeats in
|
|
1154
|
+
* the document (common in boilerplate-heavy legal text) and
|
|
1155
|
+
* then desyncs every subsequent offset. Use
|
|
1156
|
+
* `chunkTextWithOffsets`, which carries exact offsets out of
|
|
1157
|
+
* the splitter.
|
|
1124
1158
|
*/
|
|
1125
1159
|
declare const computeChunkOffsets: (fullText: string, chunks: string[]) => number[];
|
|
1126
1160
|
/**
|
|
@@ -1179,5 +1213,5 @@ declare const levenshtein: (rawA: string, rawB: string) => number;
|
|
|
1179
1213
|
*/
|
|
1180
1214
|
declare const normalizeForSearch: (text: string) => string;
|
|
1181
1215
|
//#endregion
|
|
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 };
|
|
1216
|
+
export { type AnonymisationOperator, CURRENCY_PATTERN_META, type ChunkSpan, 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, chunkTextWithOffsets, 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 };
|
|
1183
1217
|
//# sourceMappingURL=wasm.d.mts.map
|