update logging positions and enable OPUS
Browse files
app.py
CHANGED
@@ -172,16 +172,16 @@ def nllb_trans(article, target_language):
|
|
172 |
|
173 |
|
174 |
def mbart_trans(article, target_language):
|
175 |
-
logger.info(f"Article to translate : {article}")
|
176 |
-
logger.info(f"Chose which translation model: mbart model")
|
177 |
-
logger.info(f"Language selected: {target_language}")
|
178 |
-
|
179 |
result_lang = detect_lang(article)
|
180 |
if target_language == "English":
|
181 |
target_lang = "en"
|
182 |
elif target_language == "Chinese":
|
183 |
target_lang = "zh"
|
184 |
|
|
|
|
|
|
|
|
|
185 |
if result_lang != target_lang:
|
186 |
if target_language == "English":
|
187 |
translated = mbart_m2en_model.translate(article, target_lang="en")
|
@@ -199,16 +199,16 @@ def mbart_trans(article, target_language):
|
|
199 |
|
200 |
|
201 |
def m2m_trans(article, target_language):
|
202 |
-
logger.info(f"Article to translate : {article}")
|
203 |
-
logger.info(f"Chose which translation model: m2m model")
|
204 |
-
logger.info(f"Language selected: {target_language}")
|
205 |
-
|
206 |
result_lang = detect_lang(article)
|
207 |
if target_language == "English":
|
208 |
target_lang = "en"
|
209 |
elif target_language == "Chinese":
|
210 |
target_lang = "zh"
|
211 |
|
|
|
|
|
|
|
|
|
212 |
if result_lang != target_lang:
|
213 |
if target_language == "English":
|
214 |
translated = m2m_model.translate(article, target_lang)
|
@@ -226,11 +226,11 @@ def m2m_trans(article, target_language):
|
|
226 |
|
227 |
|
228 |
def translate(article, toolkit, target_language):
|
229 |
-
|
230 |
-
|
231 |
# if toolkit == "NLLB":
|
232 |
# translated = nllb_trans(article, target_language)
|
233 |
-
|
234 |
translated = mbart_trans(article, target_language)
|
235 |
elif toolkit == "M2M":
|
236 |
translated = m2m_trans(article, target_language)
|
|
|
172 |
|
173 |
|
174 |
def mbart_trans(article, target_language):
|
|
|
|
|
|
|
|
|
175 |
result_lang = detect_lang(article)
|
176 |
if target_language == "English":
|
177 |
target_lang = "en"
|
178 |
elif target_language == "Chinese":
|
179 |
target_lang = "zh"
|
180 |
|
181 |
+
logger.info(f"Article to translate : {article}")
|
182 |
+
logger.info(f"Chose which translation model: mbart model")
|
183 |
+
logger.info(f"Language selected: {target_language}")
|
184 |
+
|
185 |
if result_lang != target_lang:
|
186 |
if target_language == "English":
|
187 |
translated = mbart_m2en_model.translate(article, target_lang="en")
|
|
|
199 |
|
200 |
|
201 |
def m2m_trans(article, target_language):
|
|
|
|
|
|
|
|
|
202 |
result_lang = detect_lang(article)
|
203 |
if target_language == "English":
|
204 |
target_lang = "en"
|
205 |
elif target_language == "Chinese":
|
206 |
target_lang = "zh"
|
207 |
|
208 |
+
logger.info(f"Article to translate : {article}")
|
209 |
+
logger.info(f"Chose which translation model: m2m model")
|
210 |
+
logger.info(f"Language selected: {target_language}")
|
211 |
+
|
212 |
if result_lang != target_lang:
|
213 |
if target_language == "English":
|
214 |
translated = m2m_model.translate(article, target_lang)
|
|
|
226 |
|
227 |
|
228 |
def translate(article, toolkit, target_language):
|
229 |
+
if toolkit == "OPUS":
|
230 |
+
translated = opus_trans(article, target_language)
|
231 |
# if toolkit == "NLLB":
|
232 |
# translated = nllb_trans(article, target_language)
|
233 |
+
elif toolkit == "MBART":
|
234 |
translated = mbart_trans(article, target_language)
|
235 |
elif toolkit == "M2M":
|
236 |
translated = m2m_trans(article, target_language)
|