Repository navigation
Open
Description
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 of0.3. validate_result: Verifies syntactic format and the official GİB Modulo-10 checksum algorithm. Candidates failing the checksum returnFalseand are discarded; candidates passing the checksum returnNoneto preserve the0.3base score (avoiding false-positive promotion of coincidental 10-digit numbers to1.0) while allowing surrounding context words ("vergi kimlik","vkn","vergi no","tax id", etc.) to boost confidence viaContextAwareEnhancer.invalidate_result: Filters dummy repeated digit sequences (e.g.,4444444444,0000000000).
- Pattern: 10 digits (
- Configuration & Docs: Register in
conf/default_recognizers.yaml(enabled: false,country_code: tr,supported_languages: ["tr"]) and document indocs/supported_entities.md.
Describe alternatives you've considered
- Using a custom
PatternRecognizerwith 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, returningNoneon 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$ .
Metadata
Metadata
Assignees
Labels
No labels
Activity