Update modules/translation/translation_base.py
Browse files
modules/translation/translation_base.py
CHANGED
|
@@ -168,15 +168,19 @@ class TranslationBase(ABC):
|
|
| 168 |
A List of
|
| 169 |
List[dict] with translation
|
| 170 |
"""
|
|
|
|
| 171 |
try:
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
dic
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
return input_list_dict
|
| 182 |
|
|
|
|
| 168 |
A List of
|
| 169 |
List[dict] with translation
|
| 170 |
"""
|
| 171 |
+
|
| 172 |
try:
|
| 173 |
+
if src_lang != tgt_lang:
|
| 174 |
+
print("translation done")
|
| 175 |
+
return input_list_dict
|
| 176 |
+
self.cache_parameters(model_size=model_size,src_lang=src_lang,tgt_lang=tgt_lang,max_length=max_length,add_timestamp=add_timestamp)
|
| 177 |
+
self.update_model(model_size=model_size,src_lang=src_lang,tgt_lang=tgt_lang,progress=progress)
|
| 178 |
+
|
| 179 |
+
total_progress = len(input_list_dict)
|
| 180 |
+
for index, dic in enumerate(input_list_dict):
|
| 181 |
+
progress(index / total_progress, desc="Translating..")
|
| 182 |
+
translated_text = self.translate(dic["text"], max_length=max_length)
|
| 183 |
+
dic["text"] = translated_text
|
| 184 |
|
| 185 |
return input_list_dict
|
| 186 |
|