Skip to content

Commit 150664d

Browse files
WenwenHLFRonShakutaiSharonHartomri374
authored
Add Japanese and Chinese mobile number test cases for PhoneRecognizer (#1808)
* Add Japanese and Chinese mobile number test cases This commit adds international PHONE_NUMBER test cases for Presidio Analyzer: - Japanese mobile number formats: 090/080/070 - Chinese mobile number formats: 11-digit numbers starting with 1 These tests improve international coverage for the PhoneRecognizer. * Extend phone number tests to include JP and CN using supported_regions override This update adds Japanese and Chinese phone number examples to the phone recognizer test suite. The recognizer fixture is extended with supported_regions = DEFAULT_SUPPORTED_REGIONS + ("JP", "CN") so that the new cases can be detected without changing the library’s default behavior. Only the test fixture is modified; leniency and other tests remain unchanged. --------- Co-authored-by: Ron Shakutai <58519179+ShakutaiGit@users.noreply.github.com> Co-authored-by: Sharon Hart <sharonh.dev@gmail.com> Co-authored-by: Omri Mendels <omri374@users.noreply.github.com>
1 parent 9c8c690 commit 150664d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

presidio-analyzer/tests/test_phone_recognizer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
@pytest.fixture(scope="module")
88
def recognizer():
9-
return PhoneRecognizer()
9+
return PhoneRecognizer(
10+
supported_regions=PhoneRecognizer.DEFAULT_SUPPORTED_REGIONS + ("JP", "CN")
11+
)
1012

1113

1214

@@ -24,6 +26,8 @@ def recognizer():
2426
("_: +55 11 98456 5666", 1, ["PHONE_NUMBER"], ((3, 20), ), 0.4),
2527
("Brazil: +55 11 98456 5666", 1, ["PHONE_NUMBER"], ((8, 25), ), 0.4),
2628
("BR: +55 11 98456 5666", 1, ["PHONE_NUMBER"], ((4, 21), ), 0.4),
29+
("My Japanese number is 090-1234-5678", 1, ["PHONE_NUMBER"],((22, 35), ), 0.4),
30+
("My CN number is 13812345678", 1, ["PHONE_NUMBER"],((16, 27), ), 0.4),
2731
# fmt: on
2832
],
2933
)
@@ -135,4 +139,4 @@ def test_get_analysis_explanation():
135139
phone_recognizer = PhoneRecognizer()
136140
test_region = "US"
137141
explanation = phone_recognizer._get_analysis_explanation(test_region)
138-
assert explanation.recognizer == "PhoneRecognizer"
142+
assert explanation.recognizer == "PhoneRecognizer"

0 commit comments

Comments
 (0)