Skip to content

Commit

Permalink
Fix locations
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrislain committed Dec 19, 2024
1 parent 301c3cb commit 027b674
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/app/ops/masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ async def call(self, input: str) -> tuple[str, Mapping[str, str]]:
analyzer = Analyzer()
anonymizer = Anonymizer()
#Passing only the relevant entities to the analyzer so the model searches for these specifically.
entities = ["PERSON"]
entities = ["PERSON", "EMAIL_ADDRESS"]
analysis = await analyzer.analyze(AnalyzerRequest(text=input, entities=entities))
anonymized = await anonymizer.anonymize(AnonymizerRequest(
text=input,
anonymizers=Anonymizers(
PERSON=Keep(),
LOCATION=Keep(),
EMAIL_ADDRESS=Keep()
),
analyzer_results=analysis,
Expand All @@ -80,6 +79,8 @@ async def call(self, input: str) -> tuple[str, Mapping[str, str]]:
# Compute a replacement value
if item.entity_type == "PERSON":
replacement = self.replace_person(item.text, input)
elif item.entity_type == "EMAIL_ADDRESS":
replacement = self.replace_email_address(item.text, input)
mapping[replacement] = item.text
anonymized.text = f"{anonymized.text[:item.start]}{replacement}{anonymized.text[item.end:]}"
return (anonymized.text, mapping)
Expand Down

0 comments on commit 027b674

Please sign in to comment.