Closed omrilidor closed 2 years ago
Hi @omrilidor, specifically for 2, you can get the anonymized answer by calling:
from hebsafeharbor import HebSafeHarbor
hsh = HebSafeHarbor()
text = """שרון לוי התאשפזה ב02.02.2012 וגרה בארלוזרוב 16 רמת גן"""
doc = {"text": text}
output = hsh([doc])
print(output[0].anonymized_text.text)
Output:
<שם> התאשפזה ב<יום>.02.2012 וגרה <מיקום_> 16 רמת גן
Or if you'd like to get the full output from all the intermediate steps:
print(output[0].__dict__)
For (3), you can convert texts in a pandas data frame to Docs and call HebSafeHarbor on a list of docs:
import pandas as pd
from hebsafeharbor import HebSafeHarbor
hsh = HebSafeHarbor()
# Data frame with texts
df = pd.DataFrame({"text":["יוסי כהן כיהן בתפקיד שנים רבות", "שרון לוי התאשפזה ב02.02.2012 וגרה בארלוזרוב 16 רמת גן"]})
# Translate text column to Docs:
docs = [{"text":text} for text in df.text]
# Call HebSafeHarbor
outputs = hsh(docs)
# Add the anonymized text to the data frame:
df['anonymized'] = [output.anonymized_text.text for output in outputs]
print(df)
Output:
text anonymized
0 יוסי כהן כיהן בתפקיד שנים רבות <שם_> כיהן בתפקיד שנים רבות
1 שרון לוי התאשפזה ב02.02.2012 וגרה בארלוזרוב 16... <שם_> התאשפזה ב<יום_>.02.2012 וגרה <מיקום_> 16...