Skip to content

Remove duplicate NN-NNNNNNN pattern from the SSN filter - #86

Open
HarshRajSinghania wants to merge 3 commits into
philterd:mainfrom
HarshRajSinghania:fix/ssn-remove-ein-tin-pattern
Open

HarshRajSinghania wants to merge 3 commits into
philterd:mainfrom
HarshRajSinghania:fix/ssn-remove-ein-tin-pattern

Conversation

@HarshRajSinghania

Copy link
Copy Markdown

Summary

Removes the duplicate NN-NNNNNNN pattern from SSNFilter so that form is only detected as an EIN.

Fixes #84.

Motivation

ssn_filter.py and ein_filter.py compiled the same regex and attributed it to different entity types. The SSN copy existed only to be outscored when ein was also enabled. When ein was off, 12-3456789 was reported as an SSN. PhiSQL has no TIN type; the only taxpayer number written NN-NNNNNNN is an EIN.

Implementation

  • Deleted _TIN_PATTERNS and _TIN_CONFIDENCE from phileas/filters/ssn_filter.py. SSNFilter.detect now returns only SSN forms.
  • Left EINFilter unchanged.
  • Updated SSN/EIN characterization tests so an ssn-only policy does not detect 12-3456789, an ein policy does, and the redacted text is asserted.
  • Corrected docs/filters.md and docs/index.md so TIN language is not attached to the SSN filter.
  • Recorded the behaviour change under RELEASE_NOTES.md (Unreleased).

Testing

python3 -m pip install -e .
python3 -m pytest tests/test_ssn_detection.py tests/test_ein_detection.py -q

Result: 145 passed.

Harsh Raj Singhania added 3 commits September 15, 2026 18:17
The EIN-shaped form is already detected by EINFilter. Leaving a copy in
SSNFilter mislabels the value as an SSN when ein is not enabled.

Fixes philterd#84.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the duplicate NN-NNNNNNN pattern from the SSN filter

1 participant