Datasets:
Improve contextual PII masking and regression coverage
The scrubber misses contextual contact and identifier formats and can mistake unrelated numbers for PII. This PR improves masking and adds regression coverage for both missed values and over-masking.
Changes
- Improve phone/fax lists, international and short labelled numbers, email spacing and wrapping, and contextual identifier detection.
- Preserve surrounding prices, dates, postal codes, URLs, and prose through tighter boundaries and context checks.
- Report redaction spans in original-text coordinates. Phones use
[Telefon]; other supported identifiers use[PII].
The final diff contains five files: src/scrub_pii.py, two test modules, and two synthetic JSON regression fixtures. The scrubber uses only the Python standard library. Pilot tools, review exports, evaluation archives, and generated Parquets remain local and are outside this PR.
Validation
101 tests pass with only those five files present:
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s src -p 'test_scrub_pii.py'
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s src -p 'test_pii_mixed_regressions.py'
Local evaluation on the same 100 corrected development passages and unchanged labels:
| Character-level metric | PR baseline (a916ede) |
Current (b07fce8) |
|---|---|---|
| Precision | 82.31% | 99.94% |
| Recall | 62.23% | 97.67% |
Compared with the earlier phone-context iteration, recall rises from 97.26% to 97.67%; missed characters fall from 99 to 84, with false-positive characters unchanged at 2. The other four original evaluation batches have unchanged scores relative to that iteration.
These are development results, not independent corpus-wide accuracy. The evaluation inputs and replay tools are retained locally; they are not included in this PR. Names and postal addresses remain outside the scrubber's scope. This PR does not change corpus Parquets or release totals.
refs/pr/28 ref