richylyq commited on
Commit
f010b24
1 Parent(s): 2866119

minor update to app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -53,14 +53,16 @@ def opus_trans(article, target_language):
53
  Returns:
54
  string: translated piece of article based off target_language
55
  """
56
- if target_language == "en":
57
  result_lang = "zh"
58
- elif target_language == "zh":
 
59
  result_lang = "en"
 
60
  # result_lang = detect_lang(article, target_language)
61
 
62
- task_name = f"translation_{result_lang}_to_{target_language}"
63
- model_name = f"Helsinki-NLP/opus-mt-{result_lang}-{target_language}"
64
  translator = pipeline(task_name, model=model_name, tokenizer=model_name)
65
  translated = translator(article)[0]["translation_text"]
66
  print(translated)
 
53
  Returns:
54
  string: translated piece of article based off target_language
55
  """
56
+ if target_language == "English":
57
  result_lang = "zh"
58
+ target_lang = "en"
59
+ elif target_language == "Chinese":
60
  result_lang = "en"
61
+ target_lang = "zh"
62
  # result_lang = detect_lang(article, target_language)
63
 
64
+ task_name = f"translation_{result_lang}_to_{target_lang}"
65
+ model_name = f"Helsinki-NLP/opus-mt-{result_lang}-{target_lang}"
66
  translator = pipeline(task_name, model=model_name, tokenizer=model_name)
67
  translated = translator(article)[0]["translation_text"]
68
  print(translated)