langchain_experimental.data_anonymizer.deanonymizer_mapping.create_anonymizer_mapping¶
langchain_experimental.data_anonymizer.deanonymizer_mapping.create_anonymizer_mapping(original_text: str, analyzer_results: List[RecognizerResult], anonymizer_results: EngineResult, is_reversed: bool = False) → Dict[str, Dict[str, str]][source]¶
Creates or updates the mapping used to anonymize and/or deanonymize text.
This method exploits the results returned by the
analysis and anonymization processes.
If is_reversed is True, it constructs a mapping from each original
entity to its anonymized value.
If is_reversed is False, it constructs a mapping from each
anonymized entity back to its original text value.
If there are multiple entities of the same type, the mapping will
include a count to differentiate them. For example, if there are
two names in the input text, the mapping will include NAME_1 and NAME_2.
Example of mapping:
{
“PERSON”: {“<original>”: “<anonymized>”,
“John Doe”: “Slim Shady”
},
“PHONE_NUMBER”: {
“111-111-1111”: “555-555-5555”
}