Implements the engine side of philterd/phisql#33 (RFC: add an EIN filter) for the Python port: a new ein identifier for the U.S. Employer Identification Number (federal tax ID, format NN-NNNNNNN).
Blocked on philterd/phisql#33. Do not start until that RFC is accepted and the ein filter lands in redaction-policy schema 1.2.0 (an additive edit in place of the current schema version).
Behavior
- Detect EINs in text. The canonical form is
NN-NNNNNNN (two digits, hyphen, seven digits), matched at word boundaries.
- Bare nine-digit runs are ambiguous with SSN and other identifiers. Detect the hyphenated form reliably; participate in span disambiguation against SSN rather than blindly claiming every
NNNNNNNNN.
- Optional
onlyValidPrefixes (default false): when true, keep only matches whose two-digit prefix is one the IRS issues. The engine carries the set of valid IRS EIN prefixes; the default false matches any EIN-formatted value.
- Loads/compiles as an
ein filter with an einFilterStrategies array of the standard strategies.
Implementation notes (mirror the SSN filter)
phileas/filters/ssn_filter.py (SSNFilter) → add phileas/filters/ein_filter.py (EINFilter) with detection + onlyValidPrefixes.
- Register it in
phileas/services/filter_service.py (add (EINFilter, "EIN") alongside (SSNFilter, "SSN")).
- Advance the schema the port pins/validates against to the 1.2.0 revision that adds
ein.
Acceptance criteria
Implements the engine side of philterd/phisql#33 (RFC: add an EIN filter) for the Python port: a new
einidentifier for the U.S. Employer Identification Number (federal tax ID, formatNN-NNNNNNN).Blocked on philterd/phisql#33. Do not start until that RFC is accepted and the
einfilter lands in redaction-policy schema 1.2.0 (an additive edit in place of the current schema version).Behavior
NN-NNNNNNN(two digits, hyphen, seven digits), matched at word boundaries.NNNNNNNNN.onlyValidPrefixes(defaultfalse): whentrue, keep only matches whose two-digit prefix is one the IRS issues. The engine carries the set of valid IRS EIN prefixes; the defaultfalsematches any EIN-formatted value.einfilter with aneinFilterStrategiesarray of the standard strategies.Implementation notes (mirror the SSN filter)
phileas/filters/ssn_filter.py(SSNFilter) → addphileas/filters/ein_filter.py(EINFilter) with detection +onlyValidPrefixes.phileas/services/filter_service.py(add(EINFilter, "EIN")alongside(SSNFilter, "SSN")).ein.Acceptance criteria
EINFilterdetectsNN-NNNNNNNat word boundaries and is registered infilter_service.py.onlyValidPrefixes(defaultfalse) restricts matches to IRS-issued two-digit prefixes whentrue; the engine carries the prefix set.identifiers.einloads and redacts, and validates against redaction-policy schema 1.2.0.onlyValidPrefixeson and off, and a strategy applied to EIN spans.onlyValidPrefixesoption.