Skip to main content

A Python library for redacting PII from text using privacy-filter model

Project description

pii-safe — Redact PII from text

PyPI Python Ruff

Install

pip install pii-safe

Usage

from pii_safe import redact_text

text = "mi nombre es Dario Clavijo"
redacted = redact_text(text)
print(redacted)  # mi nombre es[REDACTED_10eda051]

Using the Redacter class

from pii_safe import Redacter

redacter = Redacter()
result1 = redacter.redact("mi nombre es Dario Clavijo")
result2 = redacter.redact("el es Dario Clavijo")

# Same PII gets consistent hash
hash_map = redacter.get_hash_map()
print(hash_map)  # {'Dario Clavijo': '10eda051'}

CLI

pii-safe input.txt
pii-safe input.txt -o output.txt

Development

git clone https://github.com/daedalus/pii-safe.git
cd pii-safe
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mypy src/

API

redact_text(text: str) -> str

Redacts PII from text using the openai/privacy-filter model.

class Redacter

Context manager for consistent PII-to-hash mapping across calls.

  • redact(text: str) -> str: Redact PII from text
  • get_hash_map() -> dict[str, str]: Get PII-to-hash mapping

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pii_safe-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pii_safe-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file pii_safe-0.1.0.tar.gz.

File metadata

  • Download URL: pii_safe-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pii_safe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7e40a0c78ff22bfffd8c8d5c7d6931f7ff031b5c1ce3cee618937e895d0ace2a
MD5 b84da7cab54c6c33d2c1dbd95909e93e
BLAKE2b-256 4edca259348297439ae32dab9beb24687db512e9567981bf70e4ca5939e4e550

See more details on using hashes here.

Provenance

The following attestation bundles were made for pii_safe-0.1.0.tar.gz:

Publisher: pypi-publish.yml on daedalus/pii-safe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pii_safe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pii_safe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pii_safe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f71bf303724e8f9d984a0b45f92448fdeafe85cb72df0201b9f618cedb45696c
MD5 99d83a0ba0e4edd2132bb307c25019ec
BLAKE2b-256 644056180d1f7728782d8e720d9fb5a53e56a4cb42d2707fb9de47d25896faa4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pii_safe-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on daedalus/pii-safe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page