mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-25 01:11:00 +00:00
Fix some warnings
This commit is contained in:
parent
6c5fa2a4ee
commit
522b8b03d7
2 changed files with 4 additions and 4 deletions
|
@ -17,7 +17,8 @@ def load_detector(langcodes = ()):
|
|||
for lc in langcodes:
|
||||
try:
|
||||
languages.append(linguars.Language.from_iso_code_639_1(lc))
|
||||
except:
|
||||
except Exception as e:
|
||||
print(f"{lc} is not supported by lingua")
|
||||
pass # Not supported
|
||||
|
||||
return linguars.LanguageDetector(languages=languages)
|
||||
|
@ -29,7 +30,6 @@ class Detector:
|
|||
|
||||
def detect(self, text):
|
||||
top_3_choices = self.detector.confidence(text)[:3]
|
||||
print(top_3_choices)
|
||||
if top_3_choices[0][1] == 0:
|
||||
return [Language("en", 0)]
|
||||
return [Language(lang.iso_code_639_1, round(conf * 100)) for lang, conf in top_3_choices]
|
||||
|
|
|
@ -37,8 +37,8 @@ def detect_languages(text):
|
|||
for i in range(len(d)):
|
||||
d[i].text_length = len(t)
|
||||
candidates.extend(d)
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
# total read bytes of the provided text
|
||||
text_length_total = sum(c.text_length for c in candidates)
|
||||
|
|
Loading…
Reference in a new issue