Skip to main content

Pii Extractor plugin: Presidio

This repository builds a Python package that installs a pii-extract-base plugin to perform PII detection for text data using the Microsoft Presidio Python library.

The name of the plugin entry point is piisa-detectors-presidio

Requirements

The package neads

  • at least Python 3.8
  • the pii-data and the pii-extract-base base packages
  • the presidio-analyzer package
  • an NLP engine model for the desired language

Installation

  • Install the package: pip install pii-extract-plg-presidio (it will automatically install its dependencies, including presidio-analyzer)
  • Download the recognition model for the desired language(s), as instructed by the presidio-analyzer installation instructions. The default plugin configuration file defines three spaCy models:
    • English model: python -m spacy download en_core_web_lg
    • Spanish model: python -m spacy download es_core_news_md
    • Italian model: python -m spacy download it_core_news_md
  • For additional information on model specification, see customizing NLP models in the Presidio documentation. If custom models are used, the nlp_config element in the plugin configuration file must be adjusted accordingly.

Usage

The package does not have any user-facing entry points (except for one console information script, see below). Instead, upon installation it defines a plugin entry point. This plugin is automatically picked up by the scripts and classes in pii-extract-base, and thus its functionality is exposed to them.

Runtime behaviour is governed by a configuration file, which sets up which recognizers from Presidio will be instantiated and used (note that the configuration defines which languages are available for detection, but the plugin can also be initialized with a subset of those languages).

The task created from the plugin is a standard PII task object, using the pii_extract.build.task.MultiPiiTask class definition. It will be called, as all PII task objects, with a DocumentChunk object containing the data to analyze. The chunk must contain language specification in its metadata, so that Presidio knows which language to use (unless the plugin task has been built with only one language; in that case if the chunk does not contain a language specification, it will use that single language).

info script

pii-extract-presidio-info is a command-line script which provides information about the plugin capabilities:

  • version: installed package versions
  • presidio-recognizers: list of recognizers in Presidio
  • presidio-entities: the total list of entities Presidio can generate
  • pii-entities: the PIISA tasks that this plugin will create, by translating from the entities detected by Presidio (this depends on the PIISA config used)

Building

The provided Makefile can be used to process the package:

  • make pkg will build the Python package, creating a file that can be installed with pip
  • make unit will launch all unit tests (using pytest, so pytest must be available)
  • make install will install the package in a Python virtualenv. The virtualenv will be chosen as, in this order:
    • the one defined in the VENV environment variable, if it is defined
    • if there is a virtualenv activated in the shell, it will be used
    • otherwise, a default is chosen as /opt/venv/pii (it will be created if it does not exist)

Metadata

Release files for pii-extract-plg-presidio 0.3.3

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-extract-plg-presidio 0.3.3
File Size Uploaded
pii-extract-plg-presidio-0.3.3.tar.gz 17.7 kB Details

Release files / pii-extract-plg-presidio-0.3.3.tar.gz

Download URL pii-extract-plg-presidio-0.3.3.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8fb5cc3b7df12881c6c7e5dc3e09eb9ad0ce37559eaa37954b928d8db4b43b57
BLAKE2b-256 checksum
How to use checksums
097313aa7636a3130d1fea064f296879287e1f206e896b0f26ce0dac7674879a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.3.3 This release

1 release file

0.3.2

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.0.2

1 release file

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