Repository navigation
Apply NANP leading-digit rule to suppress Unix timestamp phone false positives - #41
Merged
Merged
Conversation
…et of numbers found in code / docs unix timestamps around the current year. This will fail in 2033.
Contributor
|
Hey @seancraven , sorry for the delay on this. First, thanks for putting it together. The timestamp false positives are a real issue, and this is a sensible improvement. I’m happy to move this forward. I’ll add a couple of regression cases for the intentionally unchanged + behavior and Unicode offsets and unblock CI. the libphonenumber idea makes sense I think as a followup. I went ahead and created a new issue for that. Let me know if you have any other questions. Thanks again for your contribution here. Sid |
Contributor
|
everything merged, targeting for release of 0.4.4. |
Contributor
Author
|
Thanks Sid Keep up the good work, happy hacking! |
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.
Hi,
I've opened this separately as I'm really not so much a fan of this.
By introducing the NANP checks on US/CA numbers we can eliminate a fair amount of what I assume will be a common false positive. However, the long-term solution is probably to set up some automation to include the Google libphonenumber rules table, and do the validation in a similar way.
I'm happy to implement this, but it needs a bit more time.
Objective
Stop 10-digit Unix timestamps (e.g.
"start": 1800005580) being detected asPHONE. The phone detector only checked digit counts, so any 10-digit number with non-alphanumeric boundaries was reported as a North American phone number. A synthetic trajectory JSON file produced 153 such false positives.Changes
is_valid_phonenow requires numbers written without+to follow the North American Numbering Plan: the 1st and 4th digits (the first digits of the area code and exchange code) must be between 2 and 9. The leading1of 11-digit numbers is dropped before the check.+numbers are unchanged (7–15 digits). Development fixtures label 8-digit numbers such as+1-555-1002asPHONE, so applying the rule there would break them.detects_phone_numbers_following_nanp_ruleand negative testrejects_phone_candidates_breaking_nanp_rule.Limitations: this only deconflicts timestamps while they start with 1, which holds until 2033-05-18. Other 10-digit values whose 1st and 4th digits are 2–9 still match. All 128 existing non-
+phone fixtures already follow the rule.Verification
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features