fahmek
In this guide

Detection catalogue

This catalogue is generated from the recognizer packs the engine actually loads and from the format documents that are their evidence. It cannot drift from what the service does: a test of the suite fails when this file is out of date.

Common rules#

  • Detection runs on normalized text (Arabic-Indic digits converted to ASCII, tatweel and bidi control characters removed, NFKC).
  • Returned positions always refer to the original text, in Unicode codepoints: never UTF-16 units, never bytes.
  • Space, dot and hyphen separators are accepted between digit groups; they are removed before any validation.
  • No machine-learning model: regular expressions, checksums and context words only (v1).
  • An identifier whose detection depends on context stays below the masking threshold of the default policy when no context word is present: the detection is then reported, not applied.

Confidence levels#

LevelMeaningChecksum claimed?
VERIFIEDOfficial specification or official example, independently cross-checked (algorithm validated by computation against a registry example)Yes
OFFICIAL-PARTIALStructure confirmed by official or legal sources, but the validation algorithm is not publicly documentedNo: format only
COMMUNITYFormat inferred from concurring secondary sources and observed documents; no official public specificationNo: pattern and context words only

Language registers#

Every pack ships test cases in the five registers:

  • Modern Standard Arabic (MSA)
  • Darija in Arabic script
  • Darija in Latin script (Arabizi)
  • French
  • mixed French/Arabic (code-switching)

Accuracy is reported per register, never as an aggregate.

EMAIL#

Common ASCII email syntax; no deliverability or exhaustive RFC claim.

  • Format document: docs/formats/email.md
  • Confidence level: VERIFIED (bounded syntax subset)
  • Default action: masking (redact)
  • Confidence: base 0.95, cap 0.95
  • Validation: none: detection by shape and context only

Patterns (on normalized text, ASCII digits):

  • email: (?i)(?<![\w.!#$%&'*+/=?^`{|}~@-])[a-z0-9!#$%&'*+/=?^`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^`{|}~-]+)*@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+(?![\w@-])

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (1), Darija in Arabic script (1), Darija in Latin script (Arabizi) (1), French (2), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 1

Limits: wording of the format document (verbatim):

Confidence: VERIFIED (bounded syntax subset) — RFC 5322 §3.4.1 defines addr-spec, local-part and domain. This pack deliberately detects unquoted ASCII dot-atom local parts and dotted DNS-style domains, not every legal mailbox. No DNS lookup, delivery check, identity claim or external request is performed.

MA_CIN#

CIN / CNIE number: 1-2 Latin letters then 4-8 digits, context-gated, per docs/formats/ma_cin.md.

  • Format document: docs/formats/ma_cin.md
  • Confidence level: COMMUNITY
  • Default action: masking (redact)
  • Confidence: base 0.25, cap 0.99
  • Validation: none: detection by shape and context only
  • Context words: window ±40 codepoints, bonus +0.60
    • French: CIN, C.I.N, CNIE, carte nationale, carte d'identité, n° de carte, pièce d'identité
    • Arabic: البطاقة الوطنية, والبطاقة الوطنية, بالبطاقة الوطنية, للبطاقة الوطنية, فالبطاقة الوطنية, كالبطاقة الوطنية, وبالبطاقة الوطنية, وللبطاقة الوطنية, وكالبطاقة الوطنية, فبالبطاقة الوطنية, فللبطاقة الوطنية, بطاقة التعريف, وبطاقة التعريف, ببطاقة التعريف, لبطاقة التعريف, فبطاقة التعريف, كبطاقة التعريف, وببطاقة التعريف, ولبطاقة التعريف, وكبطاقة التعريف, فببطاقة التعريف, فلبطاقة التعريف, رقم البطاقة, ورقم البطاقة, برقم البطاقة, لرقم البطاقة, فرقم البطاقة, كرقم البطاقة, وبرقم البطاقة, ولرقم البطاقة, وكرقم البطاقة, فبرقم البطاقة, فلرقم البطاقة, ب.ت.و, وب.ت.و, بب.ت.و, لب.ت.و, فب.ت.و, كب.ت.و, وبب.ت.و, ولب.ت.و
    • Arabizi: cin, carte nationale, lbita9a, bita9a wataniya, la carte, nmra d la carte, nmra d cin, nmra dl carta, la kart

Patterns (on normalized text, ASCII digits):

  • letters_digits: (?<![A-Za-z0-9])[A-Za-z]{1,2}[ .\-]?\d{4,8}(?![A-Za-z0-9])

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (1), Darija in Arabic script (1), Darija in Latin script (Arabizi) (1), French (5), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 1
  • Capped-confidence cases (detection without context): 2

Limits: wording of the format document (verbatim):

Confidence: COMMUNITY — the DGSN publishes no public format specification. Format is inferred from consistent secondary sources and observable official documents. Pattern + context detection only. No checksum exists publicly; do not invent one. No authoritative prefix list — do not hard-filter on prefixes.

Catalogue wording (to be quoted as is):

CIN : détection par motif et mots de contexte. Aucune spécification publique officielle du format n'existe ; aucune clé de contrôle n'est publiée. La détection est par nature probabiliste sur cet identifiant.

MA_CNSS#

CNSS employee registration number: exactly 9 digits, context-gated, per docs/formats/ma_cnss.md.

  • Format document: docs/formats/ma_cnss.md
  • Confidence level: COMMUNITY
  • Default action: masking (redact)
  • Confidence: base 0.20, cap 0.99
  • Validation: none: detection by shape and context only
  • Context words: window ±40 codepoints, bonus +0.70
    • French: CNSS, n° CNSS, immatriculation, n° d'immatriculation, affiliation, n° d'affiliation, sécurité sociale, damancom, n CNSS
    • Arabic: الضمان الاجتماعي, والضمان الاجتماعي, بالضمان الاجتماعي, للضمان الاجتماعي, فالضمان الاجتماعي, كالضمان الاجتماعي, وبالضمان الاجتماعي, وللضمان الاجتماعي, وكالضمان الاجتماعي, فبالضمان الاجتماعي, فللضمان الاجتماعي, رقم الانخراط, ورقم الانخراط, برقم الانخراط, لرقم الانخراط, فرقم الانخراط, كرقم الانخراط, وبرقم الانخراط, ولرقم الانخراط, وكرقم الانخراط, فبرقم الانخراط, فلرقم الانخراط, رقم التسجيل, ورقم التسجيل, برقم التسجيل, لرقم التسجيل, فرقم التسجيل, كرقم التسجيل, وبرقم التسجيل, ولرقم التسجيل, وكرقم التسجيل, فبرقم التسجيل, فلرقم التسجيل, الصندوق الوطني للضمان الاجتماعي, والصندوق الوطني للضمان الاجتماعي, بالصندوق الوطني للضمان الاجتماعي, للصندوق الوطني للضمان الاجتماعي, فالصندوق الوطني للضمان الاجتماعي, كالصندوق الوطني للضمان الاجتماعي, وبالصندوق الوطني للضمان الاجتماعي, وللصندوق الوطني للضمان الاجتماعي, وكالصندوق الوطني للضمان الاجتماعي, فبالصندوق الوطني للضمان الاجتماعي, فللصندوق الوطني للضمان الاجتماعي
    • Arabizi: cnss, damane, damancom, ta3widat, nmra d CNSS, nmra d'inscription, raqm tasjil, ra9m tasjil, nmrtk d cnss

Patterns (on normalized text, ASCII digits):

  • nsn9: (?<!\d)\d{9}(?!\d)

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (1), Darija in Arabic script (1), Darija in Latin script (Arabizi) (1), French (4), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 1
  • Capped-confidence cases (detection without context): 1

Limits: wording of the format document (verbatim):

Confidence: COMMUNITY — employee numbers use nine digits, supported by the previously inspected physical card and a historical CNSS-authored e-BDS specification reproduced publicly (see the employer format document). A current issuer-hosted technical copy has not been retrieved. Detection uses pattern and context; no checksum is activated or claimed.

MA_CNSS_AFFILIATION#

CNSS employer affiliation, 7 digits; historical reproduced specification, context-only.

  • Format document: docs/formats/ma_cnss_affiliation.md
  • Confidence level: COMMUNITY
  • Default action: masking (redact)
  • Confidence: base 0.20, cap 0.99
  • Validation: none: detection by shape and context only
  • Context words: window ±40 codepoints, bonus +0.70
    • French: affiliation, n° d'affiliation, numéro d'affiliation, CNSS, damancom
    • Arabic: رقم الانخراط, ورقم الانخراط, برقم الانخراط, لرقم الانخراط, فرقم الانخراط, كرقم الانخراط, وبرقم الانخراط, ولرقم الانخراط, وكرقم الانخراط, فبرقم الانخراط, فلرقم الانخراط
    • Arabizi: cnss, affiliation, nmra dyal cnss

Patterns (on normalized text, ASCII digits):

  • employer7: (?<![^\W_])\d{7}(?![^\W_])

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (1), Darija in Arabic script (1), Darija in Latin script (Arabizi) (1), French (3), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 1
  • Capped-confidence cases (detection without context): 1

Limits: wording of the format document (verbatim):

Confidence: COMMUNITY — seven-digit employer namespace documented in a public reproduction of the CNSS-authored e-BDS specification V1.3, pp. 16 and 22 (field N_Num_Affilie, numeric width 7). The current issuer-hosted copy could not be retrieved on 2026-09-07; this is not independently authenticated or claimed current. Detection uses shape and context only.

MA_ICE#

Identifiant Commun de l'Entreprise: 15 digits (9+4+2), format-only, tag by default, per docs/formats/ma_ice.md.

  • Format document: docs/formats/ma_ice.md
  • Confidence level: OFFICIAL-PARTIAL
  • Default action: flag only (tag): never masked by default
  • Confidence: base 0.45, cap 0.99
  • Validation: none: detection by shape and context only
  • Context words: window ±40 codepoints, bonus +0.45
    • French: ICE, identifiant commun, I.C.E, n° ICE, RC, IF, patente
    • Arabic: التعريف الموحد للمقاولة, والتعريف الموحد للمقاولة, بالتعريف الموحد للمقاولة, للتعريف الموحد للمقاولة, فالتعريف الموحد للمقاولة, كالتعريف الموحد للمقاولة, وبالتعريف الموحد للمقاولة, وللتعريف الموحد للمقاولة, وكالتعريف الموحد للمقاولة, فبالتعريف الموحد للمقاولة, فللتعريف الموحد للمقاولة, رقم التعريف الموحد, ورقم التعريف الموحد, برقم التعريف الموحد, لرقم التعريف الموحد, فرقم التعريف الموحد, كرقم التعريف الموحد, وبرقم التعريف الموحد, ولرقم التعريف الموحد, وكرقم التعريف الموحد, فبرقم التعريف الموحد, فلرقم التعريف الموحد
    • Arabizi: ice

Patterns (on normalized text, ASCII digits):

  • ice15: (?<!\d)\d{9}[ .\-]?\d{4}[ .\-]?\d{2}(?!\d)

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (1), Darija in Arabic script (1), Darija in Latin script (Arabizi) (1), French (4), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 2
  • Capped-confidence cases (detection without context): 2

Limits: wording of the format document (verbatim):

Confidence: OFFICIAL-PARTIAL — existence, legal basis, and 15-digit 9+4+2 structure are documented by official/legal sources. The 2-digit control key exists, but the sources inspected do not specify its algorithm. BO 5952 pp. 1690–1691 was visually inspected on 2026-09-07: the complete decree (articles 1–12) contains no checksum formula; article 8 assigns technical characteristics to the managing committee. Until an issuer's technical specification yields the formula: format-only detection, no checksum claim. Never guess the algorithm.

MA_PHONE#

Moroccan phone number, ANRT closed 10-digit plan (trunk 0 or +212 / 00212), Z in 5-8, per docs/formats/ma_phone.md.

  • Format document: docs/formats/ma_phone.md
  • Confidence level: VERIFIED (structure) / CHURNING (operator prefix blocks)
  • Default action: masking (redact)
  • Confidence: base 0.80, cap 0.99
  • Validation: function ma_phone_nsn
  • Context words: window ±40 codepoints, bonus +0.15
    • French: tél, téléphone, portable, GSM, numéro, appelez, joignable, whatsapp
    • Arabic: الهاتف, والهاتف, بالهاتف, للهاتف, فالهاتف, كالهاتف, وبالهاتف, وللهاتف, وكالهاتف, فبالهاتف, فللهاتف, رقم, الرقم, ورقم, والرقم, برقم, بالرقم, لرقم, للرقم, فرقم, فالرقم, كرقم, كالرقم, وبرقم, وبالرقم, ولرقم, وللرقم, وكالرقم, فبرقم, فبالرقم, فلرقم, فللرقم, اتصل, واتصل, فاتصل, جوال, الجوال, وجوال, والجوال, بجوال, بالجوال, لجوال, للجوال, فجوال, فالجوال, كجوال, كالجوال, وبجوال, وبالجوال, ولجوال, وللجوال, وكالجوال, فبالجوال, فللجوال, واتساب, الواتساب, وواتساب, والواتساب, بواتساب, بالواتساب, لواتساب, للواتساب, فواتساب, فالواتساب, كواتساب, كالواتساب, وبواتساب, وبالواتساب, ولواتساب, وللواتساب, وكالواتساب, فبالواتساب, فللواتساب
    • Arabizi: tel, telifon, nmra, 3ayet, whatsapp, rqm, raqm, nmrti

Patterns (on normalized text, ASCII digits):

  • national_or_international: (?<!\d)(?:(?:\+|00)212[ .\-]?(?:\(0\)[ .\-]?)?|0)[5-8](?:[ .\-]?\d){8}(?!\d)

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (1), Darija in Arabic script (1), Darija in Latin script (Arabizi) (2), French (6), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 2
  • Capped-confidence cases (detection without context): 1

Limits: wording of the format document (verbatim):

Confidence: VERIFIED (structure) / CHURNING (operator prefix blocks) — structure is defined by ANRT's Plan National de Numérotation (deployed March 2009, closed 10-digit plan). Operator prefix allocations change regularly (new blocks were still being opened through 2025), so the recognizer keys on STRUCTURE, never on an operator allowlist.

MA_RIB#

Relevé d'Identité Bancaire: 24 digits (bank 3, branch 3, account 16, key 2), mod-97 control key per docs/formats/ma_rib_iban.md.

  • Format document: docs/formats/ma_rib_iban.md
  • Confidence level: VERIFIED
  • Default action: masking (redact)
  • Confidence: base 0.85, cap 0.99
  • Validation: function ma_rib_mod97, required length 24
  • Context words: window ±40 codepoints, bonus +0.10
    • French: RIB, relevé d'identité bancaire, IBAN, compte, virement, bénéficiaire
    • Arabic: ريب, الريب, وريب, والريب, بريب, بالريب, لريب, للريب, فريب, فالريب, كريب, كالريب, وبالريب, وللريب, وكالريب, فبالريب, فللريب, الحساب البنكي, والحساب البنكي, بالحساب البنكي, للحساب البنكي, فالحساب البنكي, كالحساب البنكي, وبالحساب البنكي, وللحساب البنكي, وكالحساب البنكي, فبالحساب البنكي, فللحساب البنكي, التعريف البنكي, والتعريف البنكي, بالتعريف البنكي, للتعريف البنكي, فالتعريف البنكي, كالتعريف البنكي, وبالتعريف البنكي, وللتعريف البنكي, وكالتعريف البنكي, فبالتعريف البنكي, فللتعريف البنكي, تحويل, التحويل, وتحويل, والتحويل, بتحويل, بالتحويل, لتحويل, للتحويل, فتحويل, فالتحويل, كتحويل, كالتحويل, وبتحويل, وبالتحويل, ولتحويل, وللتحويل, وكالتحويل, فبتحويل, فبالتحويل, فلتحويل, فللتحويل, حساب, الحساب, وحساب, والحساب, بحساب, بالحساب, لحساب, للحساب, فحساب, فالحساب, كحساب, كالحساب, وبحساب, وبالحساب, ولحساب, وللحساب, وكالحساب, فبحساب, فبالحساب, فلحساب, فللحساب
    • Arabizi: rib, compte, l7sab, lhssab, virement
  • Prefix list (best-effort): 8 codes; an unknown prefix lowers the confidence by 0.20 and never removes the detection

Patterns (on normalized text, ASCII digits):

  • blocks: (?<!\d)\d{3}[ .\-]?\d{3}[ .\-]?\d{16}[ .\-]?\d{2}(?!\d)

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (2), Darija in Arabic script (1), Darija in Latin script (Arabizi) (1), French (5), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 2

Limits: wording of the format document (verbatim):

Confidence: VERIFIED — structure and both check algorithms confirmed by multiple independent Moroccan sources AND computationally cross-validated against the official SWIFT IBAN Registry example (2026-08-27).

MA_IBAN#

Moroccan IBAN: MA + 2 check digits + 24-digit RIB (28 chars), ISO 13616 / ISO 7064 mod 97-10 per docs/formats/ma_rib_iban.md.

  • Format document: docs/formats/ma_rib_iban.md
  • Confidence level: VERIFIED
  • Default action: masking (redact)
  • Confidence: base 0.90, cap 0.99
  • Validation: function iban_mod97_10, required length 28
  • Context words: window ±40 codepoints, bonus +0.05
    • French: RIB, relevé d'identité bancaire, IBAN, compte, virement, bénéficiaire
    • Arabic: ريب, الريب, وريب, والريب, بريب, بالريب, لريب, للريب, فريب, فالريب, كريب, كالريب, وبالريب, وللريب, وكالريب, فبالريب, فللريب, الحساب البنكي, والحساب البنكي, بالحساب البنكي, للحساب البنكي, فالحساب البنكي, كالحساب البنكي, وبالحساب البنكي, وللحساب البنكي, وكالحساب البنكي, فبالحساب البنكي, فللحساب البنكي, التعريف البنكي, والتعريف البنكي, بالتعريف البنكي, للتعريف البنكي, فالتعريف البنكي, كالتعريف البنكي, وبالتعريف البنكي, وللتعريف البنكي, وكالتعريف البنكي, فبالتعريف البنكي, فللتعريف البنكي, تحويل, التحويل, وتحويل, والتحويل, بتحويل, بالتحويل, لتحويل, للتحويل, فتحويل, فالتحويل, كتحويل, كالتحويل, وبتحويل, وبالتحويل, ولتحويل, وللتحويل, وكالتحويل, فبتحويل, فبالتحويل, فلتحويل, فللتحويل, حساب, الحساب, وحساب, والحساب, بحساب, بالحساب, لحساب, للحساب, فحساب, فالحساب, كحساب, كالحساب, وبحساب, وبالحساب, ولحساب, وللحساب, وكالحساب, فبحساب, فبالحساب, فلحساب, فللحساب
    • Arabizi: rib, compte, l7sab, lhssab, virement
  • Prefix list (best-effort): 8 codes; an unknown prefix lowers the confidence by 0.20 and never removes the detection

Patterns (on normalized text, ASCII digits):

  • ma_prefixed: (?i)(?<![A-Z0-9])MA\d{2}[ .\-]?(?:\d[ .\-]?){24}(?![A-Z0-9])

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (1), Darija in Arabic script (1), Darija in Latin script (Arabizi) (1), French (5), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 2
  • Capped-confidence cases (detection without context): 1

Limits: wording of the format document (verbatim):

Confidence: VERIFIED — structure and both check algorithms confirmed by multiple independent Moroccan sources AND computationally cross-validated against the official SWIFT IBAN Registry example (2026-08-27).

PAN#

13-19 digit payment-card candidates, Luhn checked; no issuance claim.

  • Format document: docs/formats/pan.md
  • Confidence level: VERIFIED (Luhn algorithm; bounded candidate coverage)
  • Default action: masking (redact)
  • Confidence: base 0.90, cap 0.90
  • Validation: function luhn

Patterns (on normalized text, ASCII digits):

  • pan: (?<![\w])(?<!\d[ .-])[1-9](?:[ .-]?\d){12,18}(?![ .-]?\d)(?!\w)

Built-in test set:

  • Registers covered: Modern Standard Arabic (MSA) (1), Darija in Arabic script (1), Darija in Latin script (Arabizi) (1), French (2), mixed French/Arabic (code-switching) (1)
  • Negative cases (no detection expected): 1

Limits: wording of the format document (verbatim):

Confidence: VERIFIED (Luhn algorithm; bounded candidate coverage) — the rightmost digit checks the preceding digits with Luhn mod 10. Passing Luhn does not establish issuance, activity, a card brand, or PCI compliance.

Sources#

The format documents under docs/formats/ are the only source of the patterns and algorithms; they cite their own official references and list the human checks still open.

This page is the guide shipped with fahmek, kept in sync with each release.