Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class KrRrnRecognizer(PatternRecognizer):
PATTERNS = [
Pattern(
"RRN (Medium)",
r"\b\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])(-?)\d{7}\b",
r"(?<!\d)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])(-?)[1-4]\d{6}(?!\d)",
0.5,
)
]
Expand Down
16 changes: 10 additions & 6 deletions presidio-analyzer/tests/test_kr_rrn_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@ def entities():
# Valid RRNs, but medium match
("960121-1234567", 1, ((0, 14),), ((0.5, 0.5),), ),
("9601211234567", 1, ((0, 13),), ((0.5, 0.5),), ),
("000505-7637892", 1, ((0, 14),), ((0.5, 0.5),), ),
("0005057637892", 1, ((0, 13),), ((0.5, 0.5),), ),
("000505-3637892", 1, ((0, 14),), ((0.5, 0.5),), ),
("0005053637892", 1, ((0, 13),), ((0.5, 0.5),), ),
("His Korean RRN is 960121-1234567", 1, ((18, 32),), ((0.5, 0.5),), ),

# Valid RRNs, strong match by validate_result()
("960121-1021413", 1, ((0, 14),), ((1.0, 1.0),), ),
("9601211021413", 1, ((0, 13),), ((1.0, 1.0),), ),
("050912-0000008", 1, ((0, 14),), ((1.0, 1.0),), ),
("0509120000008", 1, ((0, 13),), ((1.0, 1.0),), ),
("050912-2000019", 1, ((0, 14),), ((1.0, 1.0),), ),
("0509122000019", 1, ((0, 13),), ((1.0, 1.0),), ),
("His RRN is 9601211021413", 1, ((11, 24),), ((1.0, 1.0),), ),

# Invalid RRNs
("001332-1234567", 0, (), (),),
("0013321234567", 0, (), (),),
("960121+1021413", 0, (), (),),
("960121-10214131", 0, (), (),),
("960111-10214131", 0, (), (),),
("960303-0021413", 0, (), (),),
("760413-5212134", 0, (), (),),
("000402-6214431", 0, (), (),),
("051102-9234110", 0, (), (),),
],
)
def test_when_all_rrns_then_succeed(
Expand All @@ -53,4 +57,4 @@ def test_when_all_rrns_then_succeed(
fn_score = max_score
assert_result_within_score_range(
res, entities[0], st_pos, fn_pos, st_score, fn_score
)
)
Loading