freemt
commited on
Commit
·
30e9d58
1
Parent(s):
a8fe3e5
Update using blocks
Browse files- app.py +9 -0
- app_blocks.py +9 -0
app.py
CHANGED
@@ -15,6 +15,15 @@ def opusmt(
|
|
15 |
to_lang: str = "zh",
|
16 |
) -> Union[str, List[str]]:
|
17 |
"""Translate via easyntm-opus-mt."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
logger.debug("%s, %s, %s", text[:100], from_lang, to_lang)
|
19 |
if to_lang in ["auto"]:
|
20 |
if from_lang in ["zh"]:
|
|
|
15 |
to_lang: str = "zh",
|
16 |
) -> Union[str, List[str]]:
|
17 |
"""Translate via easyntm-opus-mt."""
|
18 |
+
try:
|
19 |
+
from_lang = str(from_lang).strip()
|
20 |
+
except Exception:
|
21 |
+
from_lang = "auto"
|
22 |
+
try:
|
23 |
+
to_lang = str(to_lang).strip()
|
24 |
+
except Exception:
|
25 |
+
to_lang = "auto"
|
26 |
+
|
27 |
logger.debug("%s, %s, %s", text[:100], from_lang, to_lang)
|
28 |
if to_lang in ["auto"]:
|
29 |
if from_lang in ["zh"]:
|
app_blocks.py
CHANGED
@@ -15,6 +15,15 @@ def opusmt(
|
|
15 |
to_lang: str = "zh",
|
16 |
) -> Union[str, List[str]]:
|
17 |
"""Translate via easyntm-opus-mt."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
logger.debug("%s, %s, %s", text[:100], from_lang, to_lang)
|
19 |
if to_lang in ["auto"]:
|
20 |
if from_lang in ["zh"]:
|
|
|
15 |
to_lang: str = "zh",
|
16 |
) -> Union[str, List[str]]:
|
17 |
"""Translate via easyntm-opus-mt."""
|
18 |
+
try:
|
19 |
+
from_lang = str(from_lang).strip()
|
20 |
+
except Exception:
|
21 |
+
from_lang = "auto"
|
22 |
+
try:
|
23 |
+
to_lang = str(to_lang).strip()
|
24 |
+
except Exception:
|
25 |
+
to_lang = "auto"
|
26 |
+
|
27 |
logger.debug("%s, %s, %s", text[:100], from_lang, to_lang)
|
28 |
if to_lang in ["auto"]:
|
29 |
if from_lang in ["zh"]:
|