File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 17
17
from contextlib import chdir
18
18
from dataclasses import dataclass
19
19
from difflib import SequenceMatcher
20
- from itertools import combinations
21
20
from pathlib import Path
22
21
from subprocess import call
23
22
import sys
@@ -154,7 +153,7 @@ def progress_from_resources(resources: Iterable[ResourceLanguageStatistics]) ->
154
153
def get_number_of_translators ():
155
154
translators = set (_fetch_translators ())
156
155
_remove_bot (translators )
157
- _check_for_aliases (translators )
156
+ translators = _eliminate_aliases (translators )
158
157
return len (translators )
159
158
160
159
@@ -170,12 +169,18 @@ def _remove_bot(translators: set[str]) -> None:
170
169
translators .remove ("Transifex Bot <>" )
171
170
172
171
173
- def _check_for_aliases (translators ) -> None :
174
- for pair in combinations (translators , 2 ):
175
- if (ratio := SequenceMatcher (lambda x : x in '<>@' , * pair ).ratio ()) > 0.64 :
176
- warn (
177
- f"{ pair } are similar ({ ratio :.3f} ). Please add them to aliases list or bump the limit."
178
- )
172
+ def _eliminate_aliases (translators : set [str ]) -> set [str ]:
173
+ unique = set ()
174
+ for name in translators :
175
+ for match in unique :
176
+ if (ratio := SequenceMatcher (lambda x : x in '<>@' , name , match ).ratio ()) > 0.64 :
177
+ print (
178
+ f"{ pair } are similar ({ ratio :.3f} ). Deduplicating."
179
+ )
180
+ break
181
+ else :
182
+ unique .add (name )
183
+ return unique
179
184
180
185
181
186
def language_switcher (entry : ResourceLanguageStatistics ) -> bool :
You can’t perform that action at this time.
0 commit comments