def pseudonymize_html_text(replacements, text): """ Create html blocs with pseudos in place of NER for dash tool""" index = 0 pseudonymized_text = '' for key in sorted(replacements.keys()): chunk = text[index:key[0]] # print(text[key[0]:key[1]]) pseudonymized_text += chunk pseudonymized_text += "" + replacements[key] + "" index = key[1] pseudonymized_text += text[index:] return pseudonymized_text