Repository navigation
feat: add Croatian (hr) PII language pack with OIB validator - #1598
Conversation
Add Croatian as a national-ID-only language: - validate_croatian_oib: 11-digit OIB with an ISO 7064 MOD 11,10 check digit over the first 10 digits - _CROATIAN_PII_PATTERNS: OIB national_id plus Croatian date, phone (+385), street address, and context-gated postcode cues - register hr in LANGUAGE_PII_PATTERNS, NATIONAL_ID_ONLY_LANGUAGES, hr -> hr_HR locale, fake data, and locale format hints - surrogates use Faker's native hr_HR ssn method, which already emits ISO 7064-valid OIBs (verified 500/500 against the new validator); registered through the national-ID registry like the Turkish TCKN precedent, so no custom provider is needed - synthetic Croatian golden fixture (fixtures/i18n/hr.jsonl) - unit tests: validator accept/reject, 200-sample native-Faker round-trip, Anonymizer surrogate round-trip, pattern spans, fixture offsets, offline no-leakage de-identification All values are synthetic, generated algorithmically from the checksum rules. Closes maziyarpanahi#889.
|
Pouyan, thank you for this polished Croatian language pack. The ISO 7064 OIB validator, native Faker integration, synthetic golden fixture, registry wiring, and no-leakage coverage fit the existing architecture very well. I verified the OIB algorithm against Croatia’s official specification and added a focused maintainer hardening pass: canonical 11 ASCII digits are now required without silent trimming or normalization, and the digit-only safety sweep remains context-gated to avoid broad false positives. Your original commit is preserved and the branch is current with master. The focused coverage passes, the full suite passes (4,801 tests, 52 skipped), formatting, lint, and type gates pass, and all hosted checks are green. This is ready to merge—thank you for the consistently thoughtful work. |
Summary
Implements #889: adds Croatian as a national-ID-only language pack, mirroring the structure of the Latvian pack and the sibling packs proposed in #1592 (Estonian) and #1597 (Serbian).
validate_croatian_oib: 11-digit OIB with an ISO 7064 MOD 11,10 check digit over the first 10 digits; OIB has no embedded structure, so validation is checksum + shape_CROATIAN_PII_PATTERNS: OIBnational_idplus Croatian date, phone (+385), street-address (ulica/trg/avenija/cesta), and context-gated postcode cueshrregistered inLANGUAGE_PII_PATTERNS/NATIONAL_ID_ONLY_LANGUAGES,hr -> hr_HRlocale (native Faker locale), fake data, locale format hintsopenmed/eval/golden/fixtures/i18n/hr.jsonl(the issue'sgolden/hr.jsonlpath is not read by the fixture loader; all sibling fixtures live underfixtures/i18n/)No custom Faker provider (deviation from the issue's letter)
The issue asks for "an OIB Faker surrogate provider", but Faker's native
hr_HR.ssn()already generates ISO 7064-valid OIBs — verified 500/500 samples against this PR's independently implemented validator, plus a 200-sample seeded round-trip in the test suite. It is therefore registered withfaker_method="ssn"through the national-ID registry, exactly like the existing Turkish TCKN registration, with no custom provider class. This keepsclinical_ids.pyandproviders/__init__.pyuntouched and the diff at 7 files.Relationship to #1592 and #1597
The three PII-pack PRs add adjacent lines to the same registries (
NATIONAL_ID_ONLY_LANGUAGES,LANG_TO_LOCALE,NATIONAL_ID_PROVIDERS,_LOCALE_ID_METHODS, and the exact-set test assertion). They are independent and mergeable in any order; whichever PRs merge later will be rebased promptly (mechanical one-line conflicts only).Data provenance
Every OIB in code, tests, and the fixture is synthetic, generated algorithmically from the ISO 7064 rules. No real personal identifiers anywhere.
Verification
make test: 4680 passed, 44 skipped, 0 failedpre-commithooks pass on all changed fileshr, including a 40-seed surrogate -> validator round-tripOut of scope, as per the issue: no Croatian model training, no registry data bundled.
Closes #889