Metadata-Version: 2.4
Name: pii-safe
Version: 0.1.0
Summary: A Python library for redacting PII from text using privacy-filter model
Project-URL: Homepage, https://github.com/daedalus/pii-safe
Project-URL: Repository, https://github.com/daedalus/pii-safe
Project-URL: Issues, https://github.com/daedalus/pii-safe/issues
Author-email: Dario Clavijo <clavijodario@gmail.com>
License: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: transformers>=4.30
Provides-Extra: all
Requires-Dist: hatch; extra == 'all'
Requires-Dist: mypy; extra == 'all'
Requires-Dist: pytest; extra == 'all'
Requires-Dist: pytest-cov; extra == 'all'
Requires-Dist: pytest-mock; extra == 'all'
Requires-Dist: ruff; extra == 'all'
Provides-Extra: dev
Requires-Dist: hatch; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: lint
Requires-Dist: mypy; extra == 'lint'
Requires-Dist: ruff; extra == 'lint'
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest-mock; extra == 'test'
Description-Content-Type: text/markdown

# pii-safe — Redact PII from text

[![PyPI](https://img.shields.io/pypi/v/pii-safe.svg)](https://pypi.org/project/pii-safe/)
[![Python](https://img.shields.io/pypi/pyversions/pii-safe.svg)](https://pypi.org/project/pii-safe/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

## Install

```bash
pip install pii-safe
```

## Usage

```python
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

```python
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

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

## Development

```bash
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