Skip to content

Commit

Permalink
Merge pull request #39 from baloise/main
Browse files Browse the repository at this point in the history
Minor updates
  • Loading branch information
robbizbal authored Nov 13, 2024
2 parents 8e59143 + 35d6f4b commit df75f46
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api/demask.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class MaskRequest(BaseModel):
@router.post("/demask", response_class=JSONResponse, include_in_schema=True)
async def mask(request: MaskRequest):
deanontext = revert_replacements(request.text, request.entities)
return {"deanonymized_text": deanontext}
return {"deanonymized_text": deanontext.strip().replace('"', '')}
6 changes: 3 additions & 3 deletions src/api/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ async def mask(request: MaskRequest):
request.llmModel = OLLAMA_MODEL

llm_entities = llm_find_entities(text=request.text, base_url=request.llmURL, model=request.llmModel)
return {"original_text": request.text, "entities": llm_entities['replace_dict'], "anonymized_text": llm_entities['text']}
return {"original_text": request.text.strip().replace('"', ''), "entities": llm_entities['replace_dict'], "anonymized_text": llm_entities['text'].strip().replace('"', '')}
case BackendType.NER:
spacy_entities = ano.find_entities(request.text)
return {"original_text": request.text, "entities": spacy_entities['replace_dict'], "anonymized_text": spacy_entities['text']}
return {"original_text": request.text.strip().replace('"', ''), "entities": spacy_entities['replace_dict'], "anonymized_text": spacy_entities['text'].strip().replace('"', '')}
case BackendType.REG:
regex_entities = reg_find_entities(request.text)
return {"original_text": request.text, "entities": regex_entities['replace_dict'], "anonymized_text": regex_entities['text']}
return {"original_text": request.text.strip().replace('"', ''), "entities": regex_entities['replace_dict'], "anonymized_text": regex_entities['text'].strip().replace('"', '')}
case _:
return {"original_text": "Invalid backend type"}
6 changes: 4 additions & 2 deletions src/static/scripts/mask_downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ document.getElementById('downloadBtn').addEventListener('click', function() {
linkNT.href = URL.createObjectURL(blobNewText);
linkNT.download = 'yoyo-anonymizedText.txt'; // Specify the file name

linkE.click();
URL.revokeObjectURL(linkE.href);
setTimeout(function() {
linkE.click();
URL.revokeObjectURL(linkE.href);
}, 50);

setTimeout(function() {
linkNT.click();
Expand Down
2 changes: 1 addition & 1 deletion src/templates/html/mask.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h3>Input</h3>
<select id="backendType" name="backendType" required>
<option value="REG">REG</option>
<option value="LLM">LLM</option>
<option value="NER">NER</option>
<!-- <option value="NER">NER</option> -->
</select>
</div>
<label class="flex-item checkbox-label" id="LLMcustomLabel"><input type="checkbox" id="LLMcustom" name="LLMcustom">use custom settings</label>
Expand Down

0 comments on commit df75f46

Please sign in to comment.