1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-18 08:27:03 +02:00
This commit is contained in:
Piero Toffanin 2023-10-30 00:20:11 -04:00
parent 522b8b03d7
commit 3fd2abc1f9
2 changed files with 7 additions and 6 deletions

View File

@ -1,15 +1,15 @@
import linguars
from functools import lru_cache
import linguars
class Language:
def __init__(self, code, confidence):
self.code = code
self.confidence = float(confidence)
def __str__(self):
return ("code: {:<9} confidence: {:>5.1f} ".format(
self.code,
self.confidence))
return (f"code: {self.code:<9} confidence: {self.confidence:>5.1f} ")
@lru_cache(maxsize=None)
def load_detector(langcodes = ()):
@ -17,7 +17,7 @@ def load_detector(langcodes = ()):
for lc in langcodes:
try:
languages.append(linguars.Language.from_iso_code_639_1(lc))
except Exception as e:
except Exception:
print(f"{lc} is not supported by lingua")
pass # Not supported

View File

@ -1,6 +1,7 @@
from functools import lru_cache
from argostranslate import translate
from functools import lru_cache
from libretranslate.detect import Detector