@stll/anonymize-wasm 1.4.0 → 1.4.3

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-words-en.mjs","names":[],"sources":["../../src/data/common-words-en.json"],"sourcesContent":[""],"mappings":""}
@@ -27,6 +27,7 @@ var roles = [
27
27
  "compradora",
28
28
  "committee",
29
29
  "company",
30
+ "companies",
30
31
  "contractor",
31
32
  "contratante",
32
33
  "contratista",
@@ -0,0 +1,18 @@
1
+ //#region src/data/legal-form-leading-clauses.json
2
+ var _comment = "Per-language clause text that may precede an organization name before a legal-form suffix. `phrases` are trimmed unconditionally when found inside an over-captured legal-form span. `directPrefixes` are trimmed only when the text before the prefix already looks like prose, so company names such as `Stand By Me LLC` are preserved.";
3
+ var en = {
4
+ "phrases": [
5
+ "by and among",
6
+ "by and between",
7
+ "is between"
8
+ ],
9
+ "directPrefixes": ["by"]
10
+ };
11
+ var legal_form_leading_clauses_default = {
12
+ _comment,
13
+ en
14
+ };
15
+ //#endregion
16
+ export { _comment, legal_form_leading_clauses_default as default, en };
17
+
18
+ //# sourceMappingURL=legal-form-leading-clauses.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legal-form-leading-clauses.mjs","names":[],"sources":["../../src/data/legal-form-leading-clauses.json"],"sourcesContent":[""],"mappings":""}
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
@@ -0,0 +1,99 @@
1
+ //#region src/data/structural-single-cap-prefixes.json
2
+ var _comment = "Structural document-unit words that can precede a single-letter or letter-number marker before a legal form word, e.g. 'Schedule A LLC Members' or 'Exhibit A-1 LLC Agreement'. Lowercased; matched case-insensitively. Organised per-language; runtime unions all languages because match spans do not carry a language tag.";
3
+ var en = [
4
+ "annex",
5
+ "appendix",
6
+ "article",
7
+ "attachment",
8
+ "clause",
9
+ "exhibit",
10
+ "paragraph",
11
+ "part",
12
+ "schedule",
13
+ "section"
14
+ ];
15
+ var cs = [
16
+ "bod",
17
+ "paragraf",
18
+ "podbod",
19
+ "ustanovení",
20
+ "článek"
21
+ ];
22
+ var sk = [
23
+ "bod",
24
+ "hlava",
25
+ "oddiel",
26
+ "odsek",
27
+ "pododdiel",
28
+ "sekcia",
29
+ "časť",
30
+ "článok"
31
+ ];
32
+ var de = [
33
+ "absatz",
34
+ "abschnitt",
35
+ "abteilung",
36
+ "anlage",
37
+ "anhang",
38
+ "artikel",
39
+ "kapitel",
40
+ "klausel",
41
+ "punkt",
42
+ "sektion",
43
+ "unterabschnitt",
44
+ "unterpunkt"
45
+ ];
46
+ var es = [
47
+ "anexo",
48
+ "apartado",
49
+ "artículo",
50
+ "cláusula",
51
+ "sección"
52
+ ];
53
+ var fr = [
54
+ "annexe",
55
+ "article",
56
+ "clause",
57
+ "paragraphe",
58
+ "partie",
59
+ "section"
60
+ ];
61
+ var it = [
62
+ "allegato",
63
+ "appendice",
64
+ "articolo",
65
+ "clausola",
66
+ "paragrafo",
67
+ "sezione"
68
+ ];
69
+ var pl = [
70
+ "aneksem",
71
+ "artykuł",
72
+ "paragraf",
73
+ "punkt",
74
+ "sekcja",
75
+ "załącznik"
76
+ ];
77
+ var pt_br = [
78
+ "anexo",
79
+ "artigo",
80
+ "cláusula",
81
+ "parágrafo",
82
+ "seção"
83
+ ];
84
+ var structural_single_cap_prefixes_default = {
85
+ _comment,
86
+ en,
87
+ cs,
88
+ sk,
89
+ de,
90
+ es,
91
+ fr,
92
+ it,
93
+ pl,
94
+ "pt-br": pt_br
95
+ };
96
+ //#endregion
97
+ export { _comment, cs, de, structural_single_cap_prefixes_default as default, en, es, fr, it, pl, pt_br as "pt-br", sk };
98
+
99
+ //# sourceMappingURL=structural-single-cap-prefixes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structural-single-cap-prefixes.mjs","names":[],"sources":["../../src/data/structural-single-cap-prefixes.json"],"sourcesContent":[""],"mappings":""}
@@ -33,7 +33,22 @@ var triggers_en_default = [
33
33
  {
34
34
  "id": "en-jurisdiction",
35
35
  "label": "address",
36
- "strategy": { "type": "to-next-comma" },
36
+ "strategy": {
37
+ "type": "to-next-comma",
38
+ "maxLength": 30,
39
+ "stopWords": [
40
+ "or",
41
+ "and",
42
+ "in",
43
+ "sitting",
44
+ "shall",
45
+ "that",
46
+ "which",
47
+ "without",
48
+ "for",
49
+ "to"
50
+ ]
51
+ },
37
52
  "triggers": [
38
53
  "State of",
39
54
  "Commonwealth of",
package/dist/wasm.d.mts CHANGED
@@ -15,7 +15,7 @@ type Entity = {
15
15
  text: string;
16
16
  score: number;
17
17
  source: DetectionSource;
18
- sourceDetail?: "custom-deny-list" | "custom-regex";
18
+ sourceDetail?: "custom-deny-list" | "custom-regex" | "gazetteer-extension";
19
19
  };
20
20
  /**
21
21
  * Entity after human review. Extends the base Entity
@@ -52,6 +52,16 @@ type TriggerStrategy = {
52
52
  * word-boundary, case-insensitive.
53
53
  */
54
54
  stopWords?: string[];
55
+ /**
56
+ * Hard cap on the captured span length, in characters,
57
+ * regardless of where the next comma / stop char sits.
58
+ * Use for triggers that label short formulaic phrases
59
+ * ("State of Delaware") and must not absorb the rest
60
+ * of a long forum-selection clause when the comma is
61
+ * sentences away. Falls back to the default 100-char
62
+ * fallback when omitted.
63
+ */
64
+ maxLength?: number;
55
65
  } | {
56
66
  type: "to-end-of-line";
57
67
  } | {
@@ -259,8 +269,19 @@ type Dictionaries = {
259
269
  /**
260
270
  * Pre-loaded city names, already merged across
261
271
  * all desired countries.
272
+ *
273
+ * Prefer `citiesByCountry` when callers also pass
274
+ * `denyListCountries` / `denyListRegions`; merged
275
+ * city arrays cannot be scoped after injection.
262
276
  */
263
277
  cities?: readonly string[];
278
+ /**
279
+ * Pre-loaded city names keyed by ISO 3166-1 alpha-2
280
+ * country code. When provided, the deny-list builder
281
+ * applies `denyListCountries` / `denyListRegions`
282
+ * before adding city patterns to the search automaton.
283
+ */
284
+ citiesByCountry?: Readonly<Record<string, readonly string[]>>;
264
285
  };
265
286
  type PipelineConfig = {
266
287
  threshold: number;
@@ -280,6 +301,15 @@ type PipelineConfig = {
280
301
  * deny-list search automaton.
281
302
  */
282
303
  enableNameCorpus: boolean;
304
+ /**
305
+ * Optional language scope for first-name/surname
306
+ * dictionaries, using the keys present in
307
+ * `dictionaries.firstNames` / `dictionaries.surnames`
308
+ * (for example `["en", "de"]`). When omitted, all
309
+ * injected name languages are used for backward
310
+ * compatibility.
311
+ */
312
+ nameCorpusLanguages?: string[];
283
313
  enableDenyList: boolean;
284
314
  denyListCountries?: string[];
285
315
  denyListRegions?: string[];
@@ -357,16 +387,17 @@ declare const CURRENCY_PATTERN_META: Readonly<RegexMeta>;
357
387
  declare const processRegexMatches: (allMatches: Match[], sliceStart: number, sliceEnd: number, meta_: readonly RegexMeta[]) => Entity[];
358
388
  //#endregion
359
389
  //#region src/detectors/deny-list.d.ts
360
- type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "customDenyList" | "dictionaries">;
390
+ type DenyListConfig = Pick<PipelineConfig, "enableDenyList" | "enableNameCorpus" | "nameCorpusLanguages" | "denyListCountries" | "denyListRegions" | "denyListExcludeCategories" | "customDenyList" | "dictionaries">;
361
391
  /**
362
392
  * Source tag for each pattern in the automaton.
363
393
  * "deny-list" = standard deny list entry
394
+ * "city" = city dictionary entry
364
395
  * "custom-deny-list" = caller-owned exact term
365
396
  * "first-name" = name corpus first name
366
397
  * "surname" = name corpus surname
367
398
  * "title" = academic/professional title
368
399
  */
369
- type PatternSource = "deny-list" | "custom-deny-list" | "first-name" | "surname" | "title";
400
+ type PatternSource = "deny-list" | "city" | "custom-deny-list" | "first-name" | "surname" | "title";
370
401
  /**
371
402
  * Pre-built deny list data. Constructed once by
372
403
  * `buildDenyList`, reused across `processDenyListMatches`
@@ -404,7 +435,7 @@ declare const buildDenyList: (config: DenyListConfig, ctx?: PipelineContext) =>
404
435
  * the search instance was built on a different context
405
436
  * (e.g. cachedSearch).
406
437
  */
407
- declare const ensureDenyListData: (ctx?: PipelineContext, dictionaries?: Dictionaries) => Promise<void>;
438
+ declare const ensureDenyListData: (ctx?: PipelineContext, dictionaries?: Dictionaries, nameCorpusLanguages?: readonly string[]) => Promise<void>;
408
439
  /**
409
440
  * Process deny list matches from the unified search.
410
441
  * Receives all matches; filters to the deny list slice
@@ -500,6 +531,7 @@ type PipelineContext = {
500
531
  searchKey: string;
501
532
  searchPromise: Promise<UnifiedSearchInstance> | null;
502
533
  nameCorpus: NameCorpusData | null;
534
+ nameCorpusKey: string;
503
535
  nameCorpusPromise: Promise<void> | null;
504
536
  stopwords: ReadonlySet<string> | null;
505
537
  stopwordsPromise: Promise<ReadonlySet<string>> | null;
@@ -541,6 +573,22 @@ declare const createPipelineContext: () => PipelineContext;
541
573
  declare const sanitizeEntities: (entities: Entity[]) => Entity[];
542
574
  declare const mergeAndDedup: (...layers: Entity[][]) => Entity[];
543
575
  type NerInferenceFn = (fullText: string, labels: string[], threshold: number, signal?: AbortSignal) => Promise<Entity[]>;
576
+ type PipelineSearchOptions = {
577
+ config: PipelineConfig;
578
+ gazetteerEntries?: GazetteerEntry[];
579
+ context?: PipelineContext;
580
+ };
581
+ /**
582
+ * Pre-build and cache the unified search instance for a
583
+ * pipeline configuration. Use the same context in
584
+ * `runPipeline` to reuse the prepared automata without
585
+ * passing `cachedSearch` around manually.
586
+ */
587
+ declare const preparePipelineSearch: ({
588
+ config,
589
+ gazetteerEntries,
590
+ context
591
+ }: PipelineSearchOptions) => Promise<UnifiedSearchInstance>;
544
592
  /**
545
593
  * Options for {@link runPipeline}.
546
594
  *
@@ -770,7 +818,7 @@ declare const propagateOrgNames: (entities: Entity[], fullText: string) => Entit
770
818
  * with per-language first names and surnames. When
771
819
  * omitted, only legacy config files are used.
772
820
  */
773
- declare const initNameCorpus: (ctx?: PipelineContext, dictionaries?: Dictionaries) => Promise<void>;
821
+ declare const initNameCorpus: (ctx?: PipelineContext, dictionaries?: Dictionaries, languages?: readonly string[]) => Promise<void>;
774
822
  /**
775
823
  * Detect person names by looking up tokens against the
776
824
  * name corpus, then chaining adjacent name-like tokens.
@@ -1052,5 +1100,5 @@ declare const levenshtein: (rawA: string, rawB: string) => number;
1052
1100
  */
1053
1101
  declare const normalizeForSearch: (text: string) => string;
1054
1102
  //#endregion
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 };
1103
+ 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 };
1056
1104
  //# sourceMappingURL=wasm.d.mts.map