We used Faker to create pseudo data. Now we can create an operator and add it to the anonymizer. For complete information about operators and their creation, see the Presidio documentation for simple and custom anonymization.from presidio_anonymizer.entities import OperatorConfignew_operators = {    "POLISH_PHONE_NUMBER": OperatorConfig(        "custom", {"lambda": fake_polish_phone_number}    )}anonymizer.add_operators(new_operators)anonymizer.anonymize("My polish phone number is 666555444")    'My polish phone number is 538 521 657'Important considerations‚ÄãAnonymizer detection rates‚ÄãThe level of anonymization and the precision of detection are just as good as the quality of the recognizers implemented.Texts from different sources and in different languages have varying characteristics, so it is necessary to test the detection precision and iteratively add recognizers and operators to achieve better and better results.Microsoft Presidio gives a lot of freedom to refine anonymization. The library's author has provided his recommendations and a step-by-step guide for improving detection rates.Instance anonymization‚ÄãPresidioAnonymizer has no built-in memory. Therefore, two occurrences of the entity in the subsequent texts will be replaced with two different fake values:print(anonymizer.anonymize("My name is John Doe. Hi John Doe!"))print(anonymizer.anonymize("My name is John Doe. Hi John Doe!"))    My name is Robert Morales. Hi Robert Morales!    My name is Kelly Mccoy. Hi Kelly Mccoy!To preserve previous anonymization results, use PresidioReversibleAnonymizer, which has built-in memory:from langchain_experimental.data_anonymizer import PresidioReversibleAnonymizeranonymizer_with_memory = PresidioReversibleAnonymizer()print(anonymizer_with_memory.anonymize("My name is John Doe. Hi John Doe!"))print(anonymizer_with_memory.anonymize("My name is John Doe. Hi John Doe!"))    My name is Ashley Cervantes. Hi Ashley Cervantes!    My name is Ashley Cervantes. Hi Ashley
Open In Colab
Open In Colab ->: We used Faker to create pseudo data. Now we can create an operator and add it to the anonymizer. For complete information about operators and their creation, see the Presidio documentation for simple and custom anonymization.from presidio_anonymizer.entities import OperatorConfignew_operators = {    "POLISH_PHONE_NUMBER": OperatorConfig(        "custom", {"lambda": fake_polish_phone_number}    )}anonymizer.add_operators(new_operators)anonymizer.anonymize("My polish phone number is 666555444")    'My polish phone number is 538 521 657'Important considerations‚ÄãAnonymizer detection rates‚ÄãThe level of anonymization and the precision of detection are just as good as the quality of the recognizers implemented.Texts from different sources and in different languages have varying characteristics, so it is necessary to test the detection precision and iteratively add recognizers and operators to achieve better and better results.Microsoft Presidio gives a lot of freedom to refine anonymization. The library's author has provided his recommendations and a step-by-step guide for improving detection rates.Instance anonymization‚ÄãPresidioAnonymizer has no built-in memory. Therefore, two occurrences of the entity in the subsequent texts will be replaced with two different fake values:print(anonymizer.anonymize("My name is John Doe. Hi John Doe!"))print(anonymizer.anonymize("My name is John Doe. Hi John Doe!"))    My name is Robert Morales. Hi Robert Morales!    My name is Kelly Mccoy. Hi Kelly Mccoy!To preserve previous anonymization results, use PresidioReversibleAnonymizer, which has built-in memory:from langchain_experimental.data_anonymizer import PresidioReversibleAnonymizeranonymizer_with_memory = PresidioReversibleAnonymizer()print(anonymizer_with_memory.anonymize("My name is John Doe. Hi John Doe!"))print(anonymizer_with_memory.anonymize("My name is John Doe. Hi John Doe!"))    My name is Ashley Cervantes. Hi Ashley Cervantes!    My name is Ashley Cervantes. Hi Ashley