Skip to content

feat(analyzer): add Canadian postal code (CA_POSTAL_CODE) recognizer#2164

Open
Joey239716 wants to merge 1 commit into
data-privacy-stack:mainfrom
Joey239716:feat/ca-postal-code
Open

feat(analyzer): add Canadian postal code (CA_POSTAL_CODE) recognizer#2164
Joey239716 wants to merge 1 commit into
data-privacy-stack:mainfrom
Joey239716:feat/ca-postal-code

Conversation

@Joey239716

Copy link
Copy Markdown

Change Description

Adds CaPostalCodeRecognizer for Canadian postal codes (entity CA_POSTAL_CODE)
in the A1A 1A1 (letter, digit, letter, optional space, digit, letter, digit) format

  • Two patterns: a higher-confidence match (0.4) for the canonical
    space-separated form, and a lower-confidence match (0.1) for the space-omitted
    form commonly seen in stored data.
  • Encodes Canada Post letter rules: excludes D, F, I, O, Q, U everywhere, and
    W, Z as the first letter.
  • Context: English and French context words (Canada is officially bilingual).
  • Disabled by default, consistent with other country-specific recognizers.
  • Registered in the predefined recognizers package (__init__.py) and
    default_recognizers.yaml (with country_code: ca), plus unit tests and
    documentation (supported_entities.md, CHANGELOG.md).

Issue reference

Fixes #2163

Checklist

  • I have reviewed the contribution guidelines
  • I agree to follow this project's Code of Conduct
  • I confirm that I have the right to submit this contribution and that it does not knowingly contain proprietary or confidential code.
  • My code includes unit tests
  • All unit tests and lint checks pass locally
  • My PR contains documentation updates / additions if required

Add CaPostalCodeRecognizer for Canadian postal codes in the A1A 1A1
format, following the UK_POSTCODE recognizer conventions. Uses two
patterns: a higher-confidence match for the canonical space-separated
form and a lower-confidence match for the space-omitted form. Encodes
Canada Post letter rules (excludes D, F, I, O, Q, U everywhere and
W, Z as the first letter) and includes English and French context
words. Disabled by default, consistent with other country-specific
recognizers.

Registered in the predefined recognizers package and default
recognizers config, with tests and documentation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add Canadian postal code recognizer (CA_POSTAL_CODE)

1 participant