Skip to content

Commit

Permalink
Merge pull request #18 from privateai/DEID-1443-pre-commit-hook-fails…
Browse files Browse the repository at this point in the history
…-for-deid-3-0-0-beta-3

Update pii_dict format according to deid 3.0.0beta3
  • Loading branch information
letmerecall authored Feb 7, 2023
2 parents a339048 + 6f06a13 commit 3c439aa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pii_check/pii_check_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def locate_pii_in_files(content, files, checked, pii_dict):
for number, line in enumerate(lines, 1):
if content in line:
if (
pii_dict["stt_idx"],
pii_dict["end_idx"],
pii_dict["location"]["stt_idx"],
pii_dict["location"]["end_idx"],
number,
file,
) in checked:
Expand Down Expand Up @@ -115,16 +115,16 @@ def check_for_pii(url, api_key, enabled_entity_list, blocked_list):
continue
for pii_dict in item["entities"]:
line, file = locate_pii_in_files(content, files, checked, pii_dict)
checked.append((pii_dict["stt_idx"], pii_dict["end_idx"], line, file))
checked.append((pii_dict["location"]["stt_idx"], pii_dict["location"]["end_idx"], line, file))
skip = False
for item in flagged:
if line > item[0] and line < item[1] and file == item[2]:
skip = True
break
if skip == False:
msg.append(
f"PII found - type: {pii_dict['best_label']}, line number: {line}, file: {file}, start index: {pii_dict['stt_idx'] + 1}, end "
f"index: {pii_dict['end_idx'] + 1} "
f"PII found - type: {pii_dict['best_label']}, line number: {line}, file: {file}, start index: {pii_dict['location']['stt_idx'] + 1}, end "
f"index: {pii_dict['location']['end_idx'] + 1} "
)

if not msg:
Expand Down

0 comments on commit 3c439aa

Please # to comment.