Skip to main content

pii-presidio

Microsoft Presidio plugin: multi-language PII recognizers with reversible anonymization, built on pii-core and pii-veil.

Install

pip install pii-presidio
python -m spacy download pl_core_news_sm   # required for Polish NLP analysis

pii-presidio pulls in presidio-analyzer, presidio-anonymizer, pii-core, and pii-veil. spaCy itself comes via Presidio; the Polish language model has to be downloaded separately (Presidio's standard pattern).

Recognizers

from pii_presidio import get_recognizers
from presidio_analyzer import AnalyzerEngine, RecognizerRegistry
from presidio_analyzer.nlp_engine import NlpEngineProvider

nlp_engine = NlpEngineProvider(nlp_configuration={
    "nlp_engine_name": "spacy",
    "models": [{"lang_code": "pl", "model_name": "pl_core_news_sm"}],
}).create_engine()

registry = RecognizerRegistry(supported_languages=["pl"])
for r in get_recognizers(["pl"]):
    registry.add_recognizer(r)

analyzer = AnalyzerEngine(registry=registry, nlp_engine=nlp_engine, supported_languages=["pl"])
results = analyzer.analyze(text="PESEL 44051401359, email jan@example.pl", language="pl")

Each pii_core detector becomes one PatternRecognizer. Confidence scores are 0.85 for checksum-validated detectors (PESEL, NIP, REGON, IBAN, credit card) and 0.4 for regex-only ones (ID card, passport, phone, email). Per-detector context words are pre-set to common Polish keywords; pass your own via PiiCoreRecognizer(detector, context=[...]) if you need different boosts.

KRS and postal-code detectors are excluded by default (their raw regexes match ordinary 10-digit and XX-XXX strings); enable them with include_opt_in=True and pair with strict context filtering.

Reversible anonymization

from pii_veil import Mapping, Shield
from pii_presidio import ReversibleReplaceOperator, reversible_operators
from presidio_anonymizer import AnonymizerEngine

mapping = Mapping()
engine = AnonymizerEngine()
engine.add_anonymizer(ReversibleReplaceOperator)

result = engine.anonymize(
    text="PESEL 44051401359, email jan@example.pl",
    analyzer_results=results,
    operators=reversible_operators(mapping),
)
# result.text -> "PESEL [PL_PESEL_001], email [EMAIL_001]"

# Send result.text to an LLM, get a response back, then:
restored = Shield(mapping=mapping).deanonymize(llm_response_text)

The Mapping is the round-trip handle. It uses the same JSON format as standalone pii-veil, so you can interleave the two -- anonymize via Presidio, deanonymize via Shield, or vice versa.

Entity name mapping

pii_core.PIIType Presidio entity name
PL_PESEL, PL_NIP, PL_REGON, PL_ID_CARD, PL_PASSPORT, PL_KRS, PL_POSTAL_CODE same string (country-prefixed)
PL_PHONE PHONE_NUMBER
PL_IBAN IBAN_CODE
EMAIL EMAIL_ADDRESS
CREDIT_CARD CREDIT_CARD

Cross-language types use Presidio's standard names so existing pipelines that filter entities=["EMAIL_ADDRESS"] pick our recognizers up unchanged.

Sibling packages

  • pii-core -- multi-language detection primitives this plugin reuses.
  • pii-veil -- non-Presidio reversible anonymization with the same Mapping format.

License

Apache-2.0. See LICENSE.

Release files for pii-presidio 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pii-presidio 0.1.0
File Size Uploaded
pii_presidio-0.1.0.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pii-presidio 0.1.0
File Interpreter ABI Platform
pii_presidio-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.5 kB

Release files / pii_presidio-0.1.0.tar.gz

Download URL pii_presidio-0.1.0.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
742a1938b1f25477f8edca52d87c58a5d1ca6381b8f7b9bda585becaa4e57ddc
BLAKE2b-256 checksum
How to use checksums
9fd867c080098ed13af867efce4c34b127df50a073ba3b6cc5757803e331e7ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / pii_presidio-0.1.0-py3-none-any.whl

Download URL pii_presidio-0.1.0-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9dd5843d73e529650c8b4c8fbc2e248e6524db9bf033823eefe5ba6146f0583
BLAKE2b-256 checksum
How to use checksums
25e55c5f571fdfa58fe89cc94585bbef12ec14087f02ae2393a0f8230a449489
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page