pii-mask

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

OptionTypeDefaultDescription
entitiesArray<'Person' | 'Place' | 'Organization'>['Person', 'Place']Entity types to detect
confidencenumber0.7Whole-value detection: minimum share of the value the entity covers
customLexiconRecord<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.

Try it in the browser ↗

On this page