Skip to content

PII Instrument

PiiInstrument is an instrument that identifies and edits PII (Personally Identifiable Information) entities in a text using Presidio.

Configuration

Argument Type Description
entities list[str] List of PII entity types to identify and edit. Supported entities include:
- PERSON
- EMAIL_ADDRESS
- PHONE_NUMBER
- CREDIT_CARD
- IP_ADDRESS
- more
edit_mode str The editing strategy to apply to identified PII. Options include:
- "redact": Remove PII completely
- "replace": Replace PII with a placeholder string
- "hash": Replace PII with a hash value
- "mask": Replace characters with * while preserving length
language str Language of the text to analyze. Defaults to "en" (English)

Usage Example

examples/basic_pii.py
from eunomia.instruments import PiiInstrument
from eunomia.orchestra import Orchestra

eunomia = Orchestra(
    instruments=[
        PiiInstrument(entities=["EMAIL_ADDRESS", "PERSON"], edit_mode="replace")
    ]
)

text_original = "Hello, my name is John Doe and my email is john.doe@example.com."
text_edited = eunomia.run(text_original)

print(text_edited)