buildCompromiseDetectors
Build NLP-powered person and place detectors.
Usage
import { createMasker } from '@pii-mask/core';
import { buildCompromiseDetectors } from '@pii-mask/nlp';
const nlpDetectors = buildCompromiseDetectors({
entities: ['Person', 'Place'],
confidence: 0.7,
});
const masker = createMasker({
mode: 'mask',
extend: nlpDetectors,
});
const { result } = masker.maskString('Emeka Okafor lives in Lagos');Options
| Option | Type | Default | Description |
|---|---|---|---|
entities | Array<'Person' | 'Place' | 'Organization'> | ['Person', 'Place'] | Entity types to detect |
confidence | number | 0.7 | Whole-value detection: minimum share of the value the entity covers |
customLexicon | Record<string, 'Person' | 'Place' | 'Organization'> | {} | Extra terms, matched as whole words; kept per detector set |
In freeform text only the entity itself is masked ('John Smith lives in New York' → '[REDACTED] lives in [REDACTED]'), never the whole string. Names compromise doesn't know can be added with customLexicon or the regional lexicons.