mirror of
https://github.com/data-privacy-stack/presidio.git
synced 2026-07-23 11:20:55 -05:00
* modules changes, doc changes * updates on notebook and e2e * backward compatibility of OperatorConfig * revert file structure * revert customize_presidio_analyzer, doesn't belong in this PR * update to spark notebook * updates to notebook * Update getting_entity_values.ipynb * Update getting_entity_values.ipynb * grouped imports * Update test_context_support.py
24 lines
727 B
Python
24 lines
727 B
Python
from presidio_analyzer import AnalyzerEngine
|
|
from presidio_anonymizer import AnonymizerEngine
|
|
from presidio_anonymizer.entities import OperatorConfig
|
|
from pprint import pprint
|
|
import json
|
|
|
|
text_to_anonymize = "His name is Tom and his phone number is 212-555-5555"
|
|
|
|
analyzer = AnalyzerEngine()
|
|
anonymizer = AnonymizerEngine()
|
|
|
|
analyzer_results = analyzer.analyze(text=text_to_anonymize, language="en")
|
|
print("PII Detection:")
|
|
print(analyzer_results)
|
|
|
|
|
|
anonymized_results = anonymizer.anonymize(
|
|
text=text_to_anonymize,
|
|
analyzer_results=analyzer_results,
|
|
operators={"DEFAULT": OperatorConfig("replace", {"new_value": "<ANONYMIZED>"})},
|
|
)
|
|
print("\nPII Anonymization:")
|
|
pprint(json.loads(anonymized_results.to_json()))
|