Repository navigation
Conversation
…ing with 1 Without a '+', libphonenumber strips the leading 1 as the country code and then the area code's 1 as a national prefix, so 1-112-997-5633 was missed while +1 112-997-5633 was found. When a configured region uses country code 1, also scan a copy of the text in which a bare '1-' is '+1', keeping a match from the copy only where the text had none. Same as the Java library. Fixes philterd#107.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #107.
Without a
+, libphonenumber reads the leading1of1-112-997-5633as the country code and then the area code's1as a national prefix, which leaves nine digits, so the match is dropped.+1 112-997-5633and112-997-5633were found.As suggested in the issue (and as in philterd/phileas#458), when a configured region uses country code 1, the filter also scans, once, a copy of the text in which a bare
1country code followed by a separator becomes+1.1-and+1have the same length, so offsets carry over. A match from the copy is kept only where the scan of the text found nothing overlapping, soItem 1 112-997-5633still gives112-997-5633with the same confidence. Span text and confidence now come fromtext[match.start:match.end]rather thanraw_string, which would be the rewritten copy.Tests (
TestBareCountryCode):1-112-997-5633,1 112 997 5633,1.112.997.5633and1-109-299-5128 x512give one span covering the whole number, with input offsets and text; aGB-only filter does not rewrite;Item 1 112-997-5633and1 (112) 997-5633keep their spans and confidence; and+1 112-997-5633,1-212-997-5633(found) and11129975633(not found) are pinned. The five positive cases fail on main. The phone number section ofdocs/filters.mdnow describes the possible-number check, the+1reading and the11129975633case, and there is a release note under Unreleased.Full suite: 2403 passed, 2 skipped (without
tests/test_ph_eye_filter_download_e2e.py).AI assistance (Claude Code) was used for this change.