richylyq commited on
Commit
765a96d
1 Parent(s): d895aa7

updating logging

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -184,17 +184,15 @@ def mbart_trans(article, target_language):
184
 
185
  if result_lang != target_lang:
186
  if target_language == "English":
187
- logger.info(
188
- f'Translated Result: {mbart_m2en_model.translate(article, target_lang="en")}'
189
- )
190
- return mbart_m2en_model.translate(article, target_lang="en")
191
  else:
192
- logger.info(
193
- f'Translated Result: {mbart_m2en_model.translate(article, target_lang="zh")}'
194
- )
195
- return mbart_en2m_model.translate(article, target_lang="zh")
196
  else:
197
- logger.warn(
198
  "Error: You chose the same language as the article detected language. Please reselect language and try again."
199
  )
200
  return "Error: You chose the same language as the article detected language. Please reselect language and try again."
@@ -210,19 +208,18 @@ def m2m_trans(article, target_language):
210
  target_lang = "en"
211
  elif target_language == "Chinese":
212
  target_lang = "zh"
 
213
  if result_lang != target_lang:
214
  if target_language == "English":
215
- logger.info(
216
- f"Translation Result: {m2m_model.translate(article, target_lang)}"
217
- )
218
- return m2m_model.translate(article, target_lang)
219
  elif target_language == "Chinese":
220
- logger.info(
221
- f"Translation Result: {m2m_model.translate(article, target_lang)}"
222
- )
223
- return m2m_model.translate(article, target_lang)
224
  else:
225
- logger.warn(
226
  f"Error: You chose the same language as the article detected language. Please reselect language and try again."
227
  )
228
  return "Error: You chose the same language as the article detected language. Please reselect language and try again."
 
184
 
185
  if result_lang != target_lang:
186
  if target_language == "English":
187
+ translated = mbart_m2en_model.translate(article, target_lang="en")
188
+ logger.info(f"Translated Result: {translated}")
189
+ return translated
 
190
  else:
191
+ translated = mbart_m2en_model.translate(article, target_lang="zh")
192
+ logger.info(f"Translated Result: {translated}")
193
+ return translated
 
194
  else:
195
+ logger.warning(
196
  "Error: You chose the same language as the article detected language. Please reselect language and try again."
197
  )
198
  return "Error: You chose the same language as the article detected language. Please reselect language and try again."
 
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)
215
+ logger.info(f"Translation Result: {translated}")
216
+ return translated
 
217
  elif target_language == "Chinese":
218
+ translated = m2m_model.translate(article, target_lang)
219
+ logger.info(f"Translation Result: {translated}")
220
+ return translated
 
221
  else:
222
+ logger.warning(
223
  f"Error: You chose the same language as the article detected language. Please reselect language and try again."
224
  )
225
  return "Error: You chose the same language as the article detected language. Please reselect language and try again."