Skip to content

feat(analyzer): add Korean Corporate Registration Number (KR_CRN) recognizer#2178

Open
developer0hye wants to merge 1 commit into
data-privacy-stack:mainfrom
developer0hye:feat/kr-crn-recognizer
Open

feat(analyzer): add Korean Corporate Registration Number (KR_CRN) recognizer#2178
developer0hye wants to merge 1 commit into
data-privacy-stack:mainfrom
developer0hye:feat/kr-crn-recognizer

Conversation

@developer0hye

Copy link
Copy Markdown
Contributor

Change Description

This PR adds a new recognizer, KrCrnRecognizer (KR_CRN), to detect and validate South Korean Corporate Registration Numbers (법인등록번호) — the 13-digit identifier the court registry office assigns to every legal entity upon incorporation.

Korea currently has only the tax-oriented business identifier covered (KR_BRN, #1822). Jurisdictions with both identifier kinds have both covered: AU_ABN/AU_ACN, DE_VAT_ID/DE_HANDELSREGISTER, SE_ORGANISATIONSNUMMER, SG_UEN. The CRN routinely appears next to the BRN in Korean contracts, invoices and corporate filings, and resolves to the entity's representative and registered address through the public corporate registry, so leaving it undetected undermines de-identification of such documents.

Implementation details:

  • Pattern: AAAABB-CCCCCCD, 13 digits with optional hyphen after the 6th. The corporate type code (digits 5–6) is constrained to the codes assigned in attached Table 3 of the Supreme Court rule on registration numbers (법인 및 재외국민의 부동산등기용등록번호 부여에 관한 규칙): 11–15 commercial companies, 21–22 civil-law corporations, 31–53 special-law corporations, 71 other, 81–86 foreign corporations. This also reduces overlap with KR_RRN, which shares the hyphenated 6-7 digit shape.
  • Check digit validation: (10 - (alternating 1,2 weighted sum of the first 12 digits mod 10)) mod 10, boosting the score on match. Supreme Court Rule No. 3173 (effective 2025-01-31) expanded the serial number to 7 digits and abolished the check digit, so validate_result returns None rather than False on mismatch — the same approach KrRrnRecognizer takes for post-2020 RRNs with random serials.
  • Registry: registered in default_recognizers.yaml with enabled: false and country_code: kr under both ko and kr, matching the other Korean recognizers. The constructor accepts the name kwarg the YAML loader passes (see KrPassportRecognizer is missing from the predefined registry and defaults to wrong language code 'kr' #2176 for why this matters).
  • Context terms include the Korean words that actually accompany the number in Korean text (법인등록번호, 법인번호) alongside English ones.
  • Also deduplicated the repeated entries in country_specific/korea/__init__.py's __all__ while registering the new recognizer there.

Added unit tests covering checksum pass/fail, hyphenated and plain forms, corporate type code constraints, the None-on-mismatch validation contract, the ko default language, the name kwarg, and end-to-end loading from the YAML registry for both ko and kr.

Issue reference

Closes #2177

Checklist

  • I have reviewed the contribution guidelines
  • I agree to follow this project's Code of Conduct
  • I confirm that I have the right to submit this contribution and that it does not knowingly contain proprietary or confidential code.
  • My code includes unit tests
  • All unit tests and lint checks pass locally
  • My PR contains documentation updates / additions if required

🤖 Generated with Claude Code

…ognizer

Adds KrCrnRecognizer for the 13-digit corporate identifier assigned by
the Korean court registry office, complementing the tax-oriented KR_BRN
recognizer. The pattern constrains the corporate type code (digits 5-6)
to the codes assigned in attached Table 3 of the Supreme Court rule,
and validates the check digit for CRNs issued before 2025-01-31, when
Supreme Court Rule No. 3173 abolished it.

Closes data-privacy-stack#2177

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add Korean Corporate Registration Number (KR_CRN) recognizer

1 participant