53 lines
2.0 KiB
Python
Executable File
53 lines
2.0 KiB
Python
Executable File
|
|
from translation_resources import ibm_watson, google, aws, azure, lingvanex, yandex
|
|
from final_translation1.py import compare_outputs
|
|
|
|
def dial_comparison_ph1a(text, source_lang, target_lang):
|
|
print(source_lang)
|
|
print(target_lang)
|
|
translated_text=[]
|
|
sources_name = {'0':'Google', '1':'AWS', '2':'Azure', '3':'Lingvanex', '4':'Yandex'}
|
|
sentences=sentence_tokenize.sentence_split(text, lang=source_lang)
|
|
for sentence in sentences:
|
|
print(sentence)
|
|
if sentence == "":
|
|
continue
|
|
t0 = google(sentence, source_lang, target_lang)
|
|
#print(t0)
|
|
t1 = aws(sentence, source_lang, target_lang)
|
|
#print(t1)
|
|
t2 = azure(sentence, target_lang)
|
|
#print(t2)
|
|
t3 = lingvanex(sentence, source_lang, target_lang)
|
|
#print(t3)
|
|
t4 = yandex(sentence, source_lang, target_lang)
|
|
#print(t4)
|
|
trans = {'0':t0, '1':t1, '2':t2, '3':t3, '4':t4}
|
|
trans_text = compare_outputs(sentence, t0, trans, sources_name)
|
|
translated_text.append(trans_text)
|
|
return " ".join(translated_text)
|
|
|
|
def dial_comparison_ph1b(text, source_lang, target_lang):
|
|
translated_text=[]
|
|
sources_name = {'0':'Google', '1':'IBM_Watson', '2':'AWS', '3':'Azure', '4':'Lingvanex', '5':'Yandex'}
|
|
sentences=sentence_tokenize.sentence_split(text, lang=source_lang)
|
|
for sentence in sentences:
|
|
print(sentence)
|
|
if sentence == "":
|
|
continue
|
|
t0 = google(sentence, source_lang, target_lang)
|
|
#print(t0)
|
|
t1 = ibm_watson(sentence, source_lang, target_lang)
|
|
#print(t1)
|
|
t2 = aws(sentence, source_lang, target_lang)
|
|
#print(t2)
|
|
t3 = azure(sentence, target_lang)
|
|
#print(t3)
|
|
t4 = lingvanex(sentence, source_lang, target_lang)
|
|
#print(t4)
|
|
t5 = yandex(sentence, source_lang, target_lang)
|
|
#print(t5)
|
|
trans = {'0':t0, '1':t1, '2':t2, '3':t3, '4':t4, '5':t5}
|
|
trans_text = compare_outputs(sentence, t0, trans, sources_name)
|
|
translated_text.append(trans_text)
|
|
return " ".join(translated_text) |