Created
September 8, 2023 15:43
-
-
Save fsndzomga/2a04d2df95a453437243b7f1d535cb27 to your computer and use it in GitHub Desktop.
LangChain Data Anonymizer
This file contains hidden or 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 langchain_experimental.data_anonymizer import PresidioAnonymizer | |
from faker import Faker | |
fake = Faker() | |
DATA = [] | |
DATA_ANON = [] | |
for _ in range(2): | |
name = fake.name() | |
phone = fake.phone_number() | |
email = fake.email() | |
DATA.append(f"My name is {name}, call me at {phone} or email me at {email}") | |
anonymizer = PresidioAnonymizer() | |
for email in DATA: | |
text = anonymizer.anonymize( | |
"My name is Slim Shady, call me at 313-666-7440 or email me at [email protected]" | |
) | |
DATA_ANON.append(text) | |
print("Original array: ", DATA) | |
print("Final array: ", DATA_ANON) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment