Skip to content

Commit

Permalink
Merge pull request #46 from baloise/main
Browse files Browse the repository at this point in the history
removing "false positives" in ano_llm
  • Loading branch information
robbizbal authored Nov 26, 2024
2 parents b78da69 + acaa416 commit 07b3295
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/ano_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def find_entities(text, model=OLLAMA_MODEL, temperature=0.1, template=TEMPLATE,
return result
result = {k: {'matches': (m:=sorted(list(set(v)), key=len, reverse=True)), 'replacement': m[0]}
for k, v in json.loads(result.strip()).items() if len(v) > 0}
result = {k: {'matches': m, 'replacement': v.get('replacement')} for k, v in result.items()
if len(m:=[i for i in v.get('matches') if text.find(i) >= 0]) > 0}
for k, v in result.items():
text = text.replace(v.get('replacement'), k)
return {'text': text, 'replace_dict': result}

0 comments on commit 07b3295

Please sign in to comment.