Bowman': 'John Doe'},     'PHONE_NUMBER': {'7344131647': '313-666-7440'},     'EMAIL_ADDRESS': {'jamesmichael@example.com': 'real.slim.shady@gmail.com'},     'CREDIT_CARD': {'4838637940262': '4916 0387 9536 0861',      '3537672423884966': '4001 9192 5753 7193'}}Thanks to the built-in memory, entities that have already been detected and anonymised will take the same form in subsequent processed texts, so no duplicates will exist in the mapping:print(    anonymizer.anonymize(        "My VISA card number is 4001 9192 5753 7193 and my name is John Doe."    ))anonymizer.deanonymizer_mapping    My VISA card number is 3537672423884966 and my name is William Bowman.    {'PERSON': {'Maria Lynch': 'Slim Shady', 'William Bowman': 'John Doe'},     'PHONE_NUMBER': {'7344131647': '313-666-7440'},     'EMAIL_ADDRESS': {'jamesmichael@example.com': 'real.slim.shady@gmail.com'},     'CREDIT_CARD': {'4838637940262': '4916 0387 9536 0861',      '3537672423884966': '4001 9192 5753 7193'}}We can save the mapping itself to a file for future use: # We can save the deanonymizer mapping as a JSON or YAML fileanonymizer.save_deanonymizer_mapping("deanonymizer_mapping.json")# anonymizer.save_deanonymizer_mapping("deanonymizer_mapping.yaml")And then, load it in another PresidioReversibleAnonymizer instance:anonymizer = PresidioReversibleAnonymizer()anonymizer.deanonymizer_mapping    {}anonymizer.load_deanonymizer_mapping("deanonymizer_mapping.json")anonymizer.deanonymizer_mapping    {'PERSON': {'Maria Lynch': 'Slim Shady', 'William Bowman': 'John Doe'},     'PHONE_NUMBER': {'7344131647': '313-666-7440'},     'EMAIL_ADDRESS': {'jamesmichael@example.com': 'real.slim.shady@gmail.com'},     'CREDIT_CARD': {'4838637940262': '4916 0387 9536 0861',      '3537672423884966': '4001 9192 5753 7193'}}Custom deanonymization strategy‚ÄãThe default deanonymization strategy is to exactly match the substring in the text with the mapping entry. Due to the indeterminism of LLMs, it may be that the model will
Open In Colab
Open In Colab ->: Bowman': 'John Doe'},     'PHONE_NUMBER': {'7344131647': '313-666-7440'},     'EMAIL_ADDRESS': {'jamesmichael@example.com': 'real.slim.shady@gmail.com'},     'CREDIT_CARD': {'4838637940262': '4916 0387 9536 0861',      '3537672423884966': '4001 9192 5753 7193'}}Thanks to the built-in memory, entities that have already been detected and anonymised will take the same form in subsequent processed texts, so no duplicates will exist in the mapping:print(    anonymizer.anonymize(        "My VISA card number is 4001 9192 5753 7193 and my name is John Doe."    ))anonymizer.deanonymizer_mapping    My VISA card number is 3537672423884966 and my name is William Bowman.    {'PERSON': {'Maria Lynch': 'Slim Shady', 'William Bowman': 'John Doe'},     'PHONE_NUMBER': {'7344131647': '313-666-7440'},     'EMAIL_ADDRESS': {'jamesmichael@example.com': 'real.slim.shady@gmail.com'},     'CREDIT_CARD': {'4838637940262': '4916 0387 9536 0861',      '3537672423884966': '4001 9192 5753 7193'}}We can save the mapping itself to a file for future use: # We can save the deanonymizer mapping as a JSON or YAML fileanonymizer.save_deanonymizer_mapping("deanonymizer_mapping.json")# anonymizer.save_deanonymizer_mapping("deanonymizer_mapping.yaml")And then, load it in another PresidioReversibleAnonymizer instance:anonymizer = PresidioReversibleAnonymizer()anonymizer.deanonymizer_mapping    {}anonymizer.load_deanonymizer_mapping("deanonymizer_mapping.json")anonymizer.deanonymizer_mapping    {'PERSON': {'Maria Lynch': 'Slim Shady', 'William Bowman': 'John Doe'},     'PHONE_NUMBER': {'7344131647': '313-666-7440'},     'EMAIL_ADDRESS': {'jamesmichael@example.com': 'real.slim.shady@gmail.com'},     'CREDIT_CARD': {'4838637940262': '4916 0387 9536 0861',      '3537672423884966': '4001 9192 5753 7193'}}Custom deanonymization strategy‚ÄãThe default deanonymization strategy is to exactly match the substring in the text with the mapping entry. Due to the indeterminism of LLMs, it may be that the model will