Skip to content

Commit

Permalink
NiFi scripts: updated anon script.
Browse files Browse the repository at this point in the history
  • Loading branch information
vladd-bit committed Dec 4, 2023
1 parent 88ec3bc commit cbba074
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nifi/user-scripts/anonymise_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from medcat.cat import CAT


def special_deid(cat, text, record):
return record, deid_text(cat, text)

Expand All @@ -31,8 +30,11 @@ def special_deid(cat, text, record):
cat = CAT.load_model_pack(model_pack_path)

for record in records:
_anon_text = deid_text(cat, record[text_field_name])
record[text_field_name] = _anon_text
final_records.append(record)
if text_field_name in record.keys():
_anon_text = deid_text(cat, record[text_field_name])
record[text_field_name] = _anon_text
final_records.append(record)
else:
final_records.append(record)

sys.stdout.write(json.dumps(final_records))

0 comments on commit cbba074

Please sign in to comment.