Text Anonymizer
Text Anonymizer is a Python library that anonymizes text by replacing entities with placeholders and allows for de-anonymization. It uses the spaCy library for natural language processing and entity recognition.
Features
- Text anonymization by replacing entities with placeholders
- De-anonymization to restore original text
- Entity recognition for various types (PERSON, ORGANIZATION, LOCATION, EMAIL, URL, etc.)
- Command-line interface for easy usage
Installation
You can install the Text Anonymizer library using pip:
pip install text-anonymizer
This will also install the required dependencies, including spaCy.
After installation, you need to download the spaCy English language model:
python -m spacy download en_core_web_sm
Usage
As a Python Library
Here's a simple example of how to use the Text Anonymizer in your Python code:
from text_anonymizer import anonymize, deanonymize
# Original text
text = "John Smith from Acme Corporation called me at john.smith@acme.com."
# Anonymize the text
anonymized_text, anonymization_map = anonymize(text)
print("Anonymized text:", anonymized_text)
# Output: [ENTITY_PERSON_1] from [ENTITY_ORG_1] called me at [ENTITY_EMAIL_1].
# De-anonymize the text
original_text = deanonymize(anonymized_text, anonymization_map)
print("Original text:", original_text)
# Output: John Smith from Acme Corporation called me at john.smith@acme.com.
Command-line Interface
Text Anonymizer also provides a command-line interface for easy usage:
# Anonymize a text file
text-anonymizer anonymize input.txt output.txt
# De-anonymize a text file
text-anonymizer deanonymize input.txt output.txt --map_file map.json
Documentation
For detailed documentation, including API reference and advanced usage, please visit our documentation page.
Development
To set up the development environment:
-
Clone the repository:
git clone https://github.com/viktorbezdek/text-anonymizer.git cd text-anonymizer
-
Install Poetry (if not already installed):
pip install poetry
-
Install dependencies:
poetry install -
Activate the virtual environment:
poetry shell -
Run tests:
pytest
Contributing
Contributions are welcome! Please see our Contributing Guide for more details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
See CHANGELOG.md for a detailed history of changes.
Metadata
Release files for text-anonymizer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| text_anonymizer-0.1.0.tar.gz | 4.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| text_anonymizer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / text_anonymizer-0.1.0.tar.gz
| Download URL | text_anonymizer-0.1.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb949b52832be637435ec4a65134bb43030c6fe8d9d81da84aa2d6d55031ab15
|
|
BLAKE2b-256 checksum How to use checksums |
58e0f1f0f31283329054989aebf762bda1b8ecda27d6a30171624d004f845afa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / text_anonymizer-0.1.0-py3-none-any.whl
| Download URL | text_anonymizer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96d2deeda36575427097de671a52bc6ec55709c27f11d73e0da9cfb4ec24a6d0
|
|
BLAKE2b-256 checksum How to use checksums |
0f456abb291862d7b52af7c07e68f93c4988381fac95b872e14cc34bced96a75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for text-anonymizer 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.