Is your feature request related to a problem? Please describe.
Presidio's Canadian coverage is currently limited to a single recognizer
(CA_SIN). Canadian postal codes are common PII in address data, forms, and
free text, but there is no predefined recognizer for them, so they go
undetected using the built-in recognizer set.
Describe the solution you'd like
I would like to contribute a Canadian postal code recognizer to
presidio-analyzer, following the conventions of the existing postal-code
recognizers already in the project.
Suggested first scope:
CA_POSTAL_CODE — a Canadian postal code
in the standard A1A 1A1 format (Forward Sortation Area + Local Delivery Unit).
- Similar postal-code recognizers already exist in Presidio, such as
UK_POSTCODE and DE_PLZ, so this fits an established pattern.
UK_POSTCODE is the closest precedent: it is alphanumeric like Canada's and
has no checksum, so detection relies on a tight regex plus context words.
- Canada Post's format has clear public letter rules (the letters D, F, I, O,
Q, U are never used, and W and Z are not used as the first letter), which
keeps the regex specific and limits false positives.
- Because the space between the FSA and LDU is often omitted in stored data, I
plan to match both A1A 1A1 and A1A1A1, scoring the canonical spaced form
higher — the same two-tier idea used by the existing CA_SIN recognizer for
its delimited vs. undelimited forms.
- Context words would be bilingual (English and French, e.g. "postal code" /
"code postal"), since Canada is officially bilingual and CA_SIN already
sets this precedent.
I also plan to update the relevant documentation as part of the contribution.
Describe alternatives you've considered
As of Presidio 2.2.363, the published recognizer set surfaces a few relevant
options:
- A single pattern with an optional space at one confidence level, as
UK_POSTCODE does. This is simpler, but it cannot score the canonical spaced
form higher than the space-omitted form.
- A user-defined custom
PatternRecognizer. This works today, but a predefined
recognizer benefits all Canadian users and keeps country coverage consistent.
Additional context
Format and letter-rule reference:
https://en.wikipedia.org/wiki/Postal_codes_in_Canada
Is your feature request related to a problem? Please describe.
Presidio's Canadian coverage is currently limited to a single recognizer
(
CA_SIN). Canadian postal codes are common PII in address data, forms, andfree text, but there is no predefined recognizer for them, so they go
undetected using the built-in recognizer set.
Describe the solution you'd like
I would like to contribute a Canadian postal code recognizer to
presidio-analyzer, following the conventions of the existing postal-coderecognizers already in the project.
Suggested first scope:
CA_POSTAL_CODE— a Canadian postal codein the standard
A1A 1A1format (Forward Sortation Area + Local Delivery Unit).UK_POSTCODEandDE_PLZ, so this fits an established pattern.UK_POSTCODEis the closest precedent: it is alphanumeric like Canada's andhas no checksum, so detection relies on a tight regex plus context words.
Q, U are never used, and W and Z are not used as the first letter), which
keeps the regex specific and limits false positives.
plan to match both
A1A 1A1andA1A1A1, scoring the canonical spaced formhigher — the same two-tier idea used by the existing
CA_SINrecognizer forits delimited vs. undelimited forms.
"code postal"), since Canada is officially bilingual and
CA_SINalreadysets this precedent.
I also plan to update the relevant documentation as part of the contribution.
Describe alternatives you've considered
As of Presidio
2.2.363, the published recognizer set surfaces a few relevantoptions:
UK_POSTCODEdoes. This is simpler, but it cannot score the canonical spacedform higher than the space-omitted form.
PatternRecognizer. This works today, but a predefinedrecognizer benefits all Canadian users and keeps country coverage consistent.
Additional context
Format and letter-rule reference:
https://en.wikipedia.org/wiki/Postal_codes_in_Canada