process_file_4.py 435 B

1234567891011121314
  1. def pseudonymize_text(replacements, text):
  2. """ Create new text with pseudos in place of NER """
  3. index = 0
  4. pseudonymized_text = ''
  5. for key in sorted(replacements.keys()):
  6. chunk = text[index:key[0]]
  7. # print(text[key[0]:key[1]])
  8. pseudonymized_text += chunk
  9. pseudonymized_text += replacements[key]
  10. index = key[1]
  11. pseudonymized_text += text[index:]
  12. return pseudonymized_text