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 1717from contextlib import chdir
1818from dataclasses import dataclass
1919from difflib import SequenceMatcher
20- from itertools import combinations
2120from pathlib import Path
2221from subprocess import call
2322import sys
@@ -154,7 +153,7 @@ def progress_from_resources(resources: Iterable[ResourceLanguageStatistics]) ->
154153def get_number_of_translators ():
155154 translators = set (_fetch_translators ())
156155 _remove_bot (translators )
157- _check_for_aliases (translators )
156+ translators = _eliminate_aliases (translators )
158157 return len (translators )
159158
160159
@@ -170,12 +169,18 @@ def _remove_bot(translators: set[str]) -> None:
170169 translators .remove ("Transifex Bot <>" )
171170
172171
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
179184
180185
181186def language_switcher (entry : ResourceLanguageStatistics ) -> bool :
You can’t perform that action at this time.
0 commit comments