Last active
May 19, 2021 08:09
-
-
Save suryavanshi/13c0f3299930155964473dbd3934fba7 to your computer and use it in GitHub Desktop.
presidio_pii.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#From - https://microsoft.github.io/presidio/getting_started/ | |
from presidio_analyzer import AnalyzerEngine | |
from presidio_anonymizer import AnonymizerEngine | |
text="My phone number is 212-555-5555" | |
# Set up the engine, loads the NLP module (spaCy model by default) | |
# and other PII recognizers | |
analyzer = AnalyzerEngine() | |
# Call analyzer to get results | |
results = analyzer.analyze(text=text, | |
entities=["PHONE_NUMBER"], | |
language='en') | |
print(results) | |
# Analyzer results are passed to the AnonymizerEngine for anonymization | |
anonymizer = AnonymizerEngine() | |
anonymized_text = anonymizer.anonymize(text=text,analyzer_results=results) | |
print(anonymized_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment