qfa.adapters.presidio_anonymizer#

Presidio-based anonymisation adapter.

Implements AnonymizationPort by delegating to Microsoft Presidio’s analyzer and anonymizer engines. Owns the heavy spaCy-backed pipelines so the application service layer never imports Presidio directly.

Classes

PresidioAnonymizer()

AnonymizationPort implementation backed by Presidio.

class qfa.adapters.presidio_anonymizer.PresidioAnonymizer[source]#

Bases: AnonymizationPort

AnonymizationPort implementation backed by Presidio.

Replaces detected entities with stable placeholders of the form <ENTITY_TYPE_N> (e.g. <PERSON_0>, <LOCATION_1>) so the same value gets the same placeholder within a single anonymize call. DATE_TIME entities are preserved verbatim — they carry relevant context for analysis without identifying individuals.

anonymize(text: str) tuple[str, dict[str, str]][source]#

Replace sensitive entities in text with placeholders.

deanonymize(text: str, mapping: dict[str, str]) str[source]#

Restore original values in text using mapping.