Skip to content

feat: add Croatian (hr) PII language pack with OIB validator - #1598

Merged
maziyarpanahi merged 7 commits into
maziyarpanahi:masterfrom
PouyanJay:feat/croatian-oib-pii
Jul 15, 2026
Merged

maziyarpanahi merged 7 commits into
maziyarpanahi:masterfrom
PouyanJay:feat/croatian-oib-pii

Conversation

@PouyanJay

Copy link
Copy Markdown
Contributor

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: OIB national_id plus Croatian date, phone (+385), street-address (ulica/trg/avenija/cesta), and context-gated postcode cues
  • hr registered in LANGUAGE_PII_PATTERNS / NATIONAL_ID_ONLY_LANGUAGES, hr -> hr_HR locale (native Faker locale), fake data, locale format hints
  • Synthetic golden fixture at openmed/eval/golden/fixtures/i18n/hr.jsonl (the issue's golden/hr.jsonl path is not read by the fixture loader; all sibling fixtures live under fixtures/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 with faker_method="ssn" through the national-ID registry, exactly like the existing Turkish TCKN registration, with no custom provider class. This keeps clinical_ids.py and providers/__init__.py untouched 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 failed
  • pre-commit hooks pass on all changed files
  • Locale-coherence gate auto-covers hr, including a 40-seed surrogate -> validator round-trip
  • Golden fixture de-identifies offline with zero leakage

Out of scope, as per the issue: no Croatian model training, no registry data bundled.

Closes #889

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.
@maziyarpanahi maziyarpanahi added feature New capability good first issue Good for newcomers help wanted Extra attention is needed P2 Medium roadmap-v2 OpenMed V2 roadmap backlog labels Jul 15, 2026
@maziyarpanahi

Copy link
Copy Markdown
Owner

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.

@maziyarpanahi
maziyarpanahi merged commit 4ce92e3 into maziyarpanahi:master Jul 15, 2026
19 checks passed
maziyarpanahi added a commit to PouyanJay/openmed that referenced this pull request Jul 15, 2026
@PouyanJay
PouyanJay deleted the feat/croatian-oib-pii branch August 20, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New capability good first issue Good for newcomers help wanted Extra attention is needed P2 Medium roadmap-v2 OpenMed V2 roadmap backlog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Croatian (hr) PII language pack with OIB personal-identification validator

2 participants