Skip to content

Detect Employer Identification Numbers (EIN) #53

Description

@jzonthemtn

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

  • A new EINFilter detects NN-NNNNNNN at word boundaries and is registered in filter_service.py.
  • EIN participates in span disambiguation against SSN so bare nine-digit runs are not blindly claimed as EIN.
  • onlyValidPrefixes (default false) restricts matches to IRS-issued two-digit prefixes when true; the engine carries the prefix set.
  • A policy with identifiers.ein loads and redacts, and validates against redaction-policy schema 1.2.0.
  • Tests cover detection, the hyphen-position SSN/EIN distinction, onlyValidPrefixes on and off, and a strategy applied to EIN spans.
  • Documentation is updated for the new entity type and the onlyValidPrefixes option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions