Skip to content

Add Turkish Tax Identification Number (TR_TAX_ID / VKN) recognizer #2449

Open

Description

@theharuun

Is your feature request related to a problem? Please describe.
Presidio currently supports TR_NATIONAL_ID (TCKN) and TR_LICENSE_PLATE under country_specific/turkey, but lacks a predefined recognizer for the Turkish Tax Identification Number (Vergi Kimlik Numarası / VKN) (TR_TAX_ID). In Turkish financial, legal, e-invoice, and KVKK compliance workflows, the 10-digit VKN issued by the Turkish Revenue Administration (Gelir İdaresi Başkanlığı - GİB) is a primary identifier that frequently appears in unstructured text and structured records.

Describe the solution you'd like
Add TrTaxIdRecognizer under presidio_analyzer/predefined_recognizers/country_specific/turkey/:

  • Entity: TR_TAX_ID
  • Language & Country Code: supported_language="tr", COUNTRY_CODE = "tr"
  • Official Specification: Vergi Kimlik Numarası Genel Tebliği (Sıra No: 2), published in Official Gazette (Resmî Gazete) No: 23793.
  • Format & Validation:
    • Pattern: 10 digits (\b[0-9]{10}\b) with a calibrated base score of 0.3.
    • validate_result: Verifies syntactic format and the official GİB Modulo-10 checksum algorithm. Candidates failing the checksum return False and are discarded; candidates passing the checksum return None to preserve the 0.3 base score (avoiding false-positive promotion of coincidental 10-digit numbers to 1.0) while allowing surrounding context words ("vergi kimlik", "vkn", "vergi no", "tax id", etc.) to boost confidence via ContextAwareEnhancer.
    • invalidate_result: Filters dummy repeated digit sequences (e.g., 4444444444, 0000000000).
  • Configuration & Docs: Register in conf/default_recognizers.yaml (enabled: false, country_code: tr, supported_languages: ["tr"]) and document in docs/supported_entities.md.

Describe alternatives you've considered

  • Using a custom PatternRecognizer with only a 10-digit regex (\b[0-9]{10}\b) without GİB Modulo-10 checksum filtering produces excessive false positives on phone numbers, order IDs, and timestamps.
  • Promoting checksum matches directly to 1.0 (validate_result -> True) was also considered, but since a Modulo-10 check passes ~10% of random 10-digit numbers and cannot verify live assignment in GİB databases, returning None on valid checksum and relying on context enhancement provides a much safer precision/recall balance.

Additional context

  • Official GİB VKN algorithm specification: For the first 9 digits $d_0 \dots d_8$ with weights $i = 9 - k$ ($k \in [0, 8]$), $c_1 = (d_k + i) \bmod 10$; if $c_1 \neq 0$, $c_2 = (c_1 \times 2^i) \bmod 9$ (with $c_2 = 9$ when $c_2 = 0$), else $c_2 = 0$. The 10th digit $d_9$ must equal $(10 - (\sum c_2 \bmod 10)) \bmod 10$.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions