Skip to content

Commit db917f5

Browse files
committed
fix: sweep three digits under one-digit area codes
A one-digit code covers a whole range of a country, and two digits of continuation still missed narrow ranges without an area code under it: Morocco's VoIP 0592 offered a block for every landline under +212 5. One- digit codes now get every three-digit continuation, which adds six exclusions (Morocco, Myanmar, Ecuador, Taiwan, UAE) for about 20 seconds more generation.
1 parent b9f98aa commit db917f5

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎app/src/main/java/com/sysadmindoc/callshield/data/areacodes/GeographicAreaCodes.kt‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.sysadmindoc.callshield.data.areacodes
22

33
// Generated by scripts/generate_geographic_area_codes.py from libphonenumber
44
// metadata (Python phonenumbers 9.0.41): 18953 area codes in 91 calling codes,
5-
// and 539 lengths where one of them doesn't apply.
5+
// and 545 lengths where one of them doesn't apply.
66
// Don't edit by hand.
77

88
/**
@@ -1124,6 +1124,7 @@ internal object GeographicAreaCodes {
11241124
private val EXCLUDED: Map<String, String> =
11251125
mapOf(
11261126
"20" to " 15@10 ",
1127+
"212" to " 5@9 ",
11271128
"229" to " 01@10 ",
11281129
"252" to " 1@6 1@8 3@6 3@9 4@6 4@9 ",
11291130
"32" to " 4@9 80@8 9@8 ",
@@ -1133,14 +1134,15 @@ internal object GeographicAreaCodes {
11331134
"386" to " 3@8 4@8 5@8 7@8 ",
11341135
"46" to " 90@10 90@7 90@8 90@9 ",
11351136
"55" to " 43@8 48@8 ",
1137+
"593" to " 2@8 4@8 ",
11361138
"64" to " 2@10 2@8 2@9 7@9 9@10 9@8 9@9 ",
11371139
"66" to " 18@10 19@10 ",
11381140
"81" to " 6@10 6@9 ",
11391141
"86" to
11401142
" 10@7 10@8 20@7 20@8 21@7 21@8 22@7 22@8 23@7 23@8 24@7 24@8 25@7 25@8 27@7 27@8 28@7 28@8 29@7 " +
11411143
"29@8 410@8 410@9 413@8 413@9 994@8 994@9 ",
11421144
"880" to " 3822@10 3824@10 4422@10 4423@10 4424@10 4426@10 4455@10 6423@10 6424@10 668@10 ",
1143-
"886" to " 2@7 2@9 5@9 7@10 ",
1145+
"886" to " 2@7 2@9 5@9 7@10 7@11 ",
11441146
"91" to
11451147
" 160@10 180@10 180@11 180@12 180@13 180@8 180@9 186@11 186@13 6111@10 6112@10 6114@10 6115@10 " +
11461148
"6132@10 6135@10 6150@10 6151@10 6152@10 6153@10 6154@10 6155@10 6156@10 6157@10 6158@10 6159@10 " +
@@ -1179,9 +1181,9 @@ internal object GeographicAreaCodes {
11791181
"7635@10 7636@10 7637@10 7638@10 7640@10 7641@10 7642@10 7643@10 7644@10 7645@10 7646@10 7647@10 " +
11801182
"7648@10 7649@10 7650@10 7651@10 7652@10 7653@10 7656@10 7657@10 7701@10 7703@10 7704@10 7705@10 " +
11811183
"7706@10 7707@10 788@10 79@10 ",
1182-
"95" to " 1@7 ",
1184+
"95" to " 1@7 1@8 ",
11831185
"967" to " 7@9 ",
1184-
"971" to " 4@9 6@9 9@9 ",
1186+
"971" to " 4@9 6@9 7@9 9@9 ",
11851187
"996" to " 312@9 ",
11861188
)
11871189
}

‎scripts/generate_geographic_area_codes.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,19 @@ def area_code(cc: int, nsn: str) -> str | None:
8686

8787

8888
def sweep(code: str, lengths: list[int]):
89-
"""[samples] plus every two-digit continuation, which two seeds per next digit miss (Finland's 800 under 8)."""
89+
"""[samples] plus every two-digit continuation, which two seeds per next digit miss (Finland's 800 under 8).
90+
91+
A one-digit code covers so much that it gets every three-digit continuation
92+
too: Morocco's VoIP 0592 sits under its landlines' 5.
93+
"""
9094
yield from samples(code, lengths)
95+
digits = 3 if len(code) == 1 else 2
9196
for n in lengths:
9297
rest = n - len(code)
9398
if rest < SUBSCRIBER_MIN:
9499
continue
95-
for pair in range(100):
96-
yield code + f"{pair:02d}" + SEEDS[0][: rest - 2]
100+
for continuation in range(10**digits):
101+
yield code + f"{continuation:0{digits}d}" + SEEDS[0][: rest - digits]
97102

98103

99104
def found_codes(cc: int, code: str, lengths: list[int]) -> dict[int, set[str]]:

0 commit comments

Comments
 (0)