Originally published in Portuguese on 27 October 2026: Portuguese version.
I ran DataFog 4.9.0, with the default configuration, on 200 synthetic clinical notes in Portuguese. It covered 26 of 26 emails, 8 of 133 CPFs (Brazilian taxpayer ID) and 0 of 120 CNS numbers (Brazilian national health card number). After redact(), 196 of the 200 notes still showed a full CPF or CNS.
Code, data and recorded output: demos/09-datafog-pii-pt in nursia-research-lab.
How I ran it
- DataFog 4.9.0, installed with
pip install datafog==4.9.0, Python 3.11, CPU.regexengine, the default. No model, no key. - The same 200 notes from demo 06: four styles (progress note, discharge, referral, prescription), fixed seed, all synthetic. CPF and CNS pass the check digit, but they are random and belong to nobody.
- The corpus has hard cases on purpose. Half of the CPFs come without punctuation (66 of 133).
- DataFog telemetry turned off in the script, with
DATAFOG_NO_TELEMETRY=1andDO_NOT_TRACK=1.
The core of the test is two calls (the engine is the detection engine; a span is the stretch of text where the data sits):
entidades = datafog.scan(texto).entities
redigido = datafog.redact(texto, entities=entidades).redacted_text
For each piece of personal data in the answer key, I measured three things. Exact: same start, same end and the right type. Covered: the whole item falls inside some entity, of any type. That is what matters for redaction. Leaked: the item’s text still appears in the note after redact().
Results
| Type | Support | Exact | Covered | Partial | Leaked after redact |
|---|---|---|---|---|---|
| 26 | 26 (100%) | 26 (100%) | 0 | 0 | |
| Date | 98 | 17 (17.3%) | 17 (17.3%) | 0 | 81 |
| Phone | 60 | 0 | 16 (26.7%) | 27 (45.0%) | 17 |
| CPF | 133 | 0 | 8 (6.0%) | 0 | 125 |
| CNS | 120 | 0 | 0 | 0 | 120 |
| Person | 292 | 0 | 0 | 0 | 292 |
| Address | 58 | 0 | 0 | 0 | 58 |
All 200 notes have a CPF or a CNS. In 196, at least one of the two is still whole after redact().
Where does it fail, and why?
CPF and CNS do not exist for the regex engine
The 4.9.0 regex engine lists seven types: EMAIL, PHONE, SSN, CREDIT_CARD, IP_ADDRESS, DATE and ZIP_CODE. No CPF, no CNS, no name, no Brazilian address. Person and address at 0% are expected, because the engine does not have those types.
The 8 covered CPFs were an accident. All of them had no punctuation, and DataFog labeled them as PHONE. Of the 66 CPFs without punctuation, 8 were covered. Of the 67 with punctuation, none.
Phone numbers become ZIP codes, and the area code stays
Phone numbers in the 99123-4567 format came out as ZIP_CODE, 43 times across the 200 notes. With an area code, the entity catches only the tail and the area code stays in the text: 27 partial cases. The 16 fully covered ones are mobile numbers without an area code. The 17 left over are eight-digit landlines, in the 9999-9999 format, with no entity at all.
Dates: the regex reads month/day
It found 17 of 98. The 50 dates written out in words, like “3 de março” (3 March), do not get in. Of the 48 numeric ones, the 17 whose first field is 12 or less got in. The 31 with a first field above 12, like 24/04/25, slipped through. The regex reads the American format, month before day.
The first note in the corpus did not change at all
In results/exemplo.txt, note 1 has a CNS, a CPF, an address and two names. After redact(), the text came out identical.
False positives were almost nonexistent
On numbers that are not personal data (batch, bed, dose, blood pressure, protocol), DataFog flagged 2, both in protocol numbers.
How to read this table
The “Exact” column is the benchmark metric: the span and the type have to match. It is too strict for deciding whether the data leaks. A CPF labeled as a phone number, for example, counts as an error under “Exact” and as a hit under “Covered”, because the black bar covers the eleven digits either way. That is why the column that decides is “Covered”, and the final proof is “Leaked after redact”: I searched for the original text of each item in the redacted note.
There is a blind spot. “Leaked” looks at the full text of the item. In a partial phone number, the area code stays and the rest goes. That is why phone has 17 leaked and 27 partial, instead of 44 leaked. Partial data is still information left behind, and the “Partial” column exists for that.
For comparison
In demo 06, default Presidio 2.2.364 with Portuguese spaCy let a CPF or CNS through in 200 of 200 notes. With presidio-br, leakage was 0 in 200. On CPF and CNS, DataFog regex lands in the same place as default Presidio. On names and dates, Presidio with spaCy did better (recall of 82.2% and 49.0%, against 0% and 17.3% for DataFog). Neither ships a CPF recognizer out of the box. Presidio accepts a new recognizer; I wrote how in CPF recognizer in Presidio. I did not test how to add a CPF pattern to DataFog.
What would I do?
- Before trusting an anonymization library, run it on your synthetic corpus and search for the data in the output. Do not trust the entity name.
- Measure the note after
redact(), not only the entity list. The two numbers differ: the entity list says what was found, the text says what was left.
Limits
- Only the
regexengine. DataFog has NER engines (spaCy, GLiNER) that download a model. I did not run them. The result holds for what comes withpip install datafog, not for the whole library. - 200 synthetic notes, one seed. Real notes are noisier.
- It measures detection and the text after
redact(). It does not measure re-identification by combining fields. - The
localesoption does not help with Portuguese: 4.9.0 rejectsptand accepts onlyde, German. I saw this from the error message; the demo does not use the option. - Average time of about 0.2 ms per note on this machine (0.15 to 0.21 ms in the runs I did).
Source and how to reproduce
After cloning the repository and going into demos/09-datafog-pii-pt, it is three commands:
pip install -r requirements.txt
python3 demo.py
python3 -m pytest tests -q
- Folder in the repository: demos/09-datafog-pii-pt. Recorded output in
results/. - DataFog: github.com/DataFog/datafog-python, version 4.9.0. The repository’s LICENSE is MIT; the PyPI classifier says Apache.
The demo is part of the NursIA research repository (PPGINFOS/UFSC, FAPESC grant).

