71 lines
2.2 KiB
Python
Executable File
71 lines
2.2 KiB
Python
Executable File
from conversion.translation.translation_resources import ibm_watson, aws, azure, google_simple, lingvanex
|
|
from openpyxl import Workbook
|
|
import time
|
|
|
|
|
|
def test_run():
|
|
wb = Workbook()
|
|
ws = wb.active
|
|
|
|
# -> Text Used for Testing
|
|
text = "My name is dharmesh and my age is 15. Can you help me with studies."
|
|
|
|
# -> Heading Row
|
|
testdata = [['API', 'Response Time']]
|
|
|
|
# -> Adding Heading Row
|
|
for data in testdata:
|
|
ws.append(data)
|
|
|
|
|
|
# for service in [aws, azure, google_simple, lingvanex]:
|
|
# current_pair = []
|
|
# current_pair.append(str("Azure"))
|
|
# # -> Translation using Lingvanex Translate
|
|
# start_time = time.time()
|
|
# azure(text, "hi")
|
|
# end_time = time.time()
|
|
# current_pair.append(str(end_time-start_time))
|
|
# for data in [current_pair]:
|
|
# ws.append(data)
|
|
# wb.save("/home/user/mnf/project/MNF/media/file_112_response.xlsx")
|
|
|
|
|
|
current_pair = []
|
|
current_pair.append(str("Google"))
|
|
# -> Translation using Google Translate
|
|
start_time = time.time()
|
|
google_simple(text, "en", "hi")
|
|
end_time = time.time()
|
|
current_pair.append(str(end_time - start_time))
|
|
# -> Appending the Pair
|
|
for data in [current_pair]:
|
|
ws.append(data)
|
|
wb.save("/home/user/mnf/project/MNF/media/file_112_response.xlsx")
|
|
|
|
current_pair = []
|
|
current_pair.append(str("AWS"))
|
|
# -> Translation using Google Translate
|
|
start_time = time.time()
|
|
aws(text, "en", "hi")
|
|
end_time = time.time()
|
|
current_pair.append(str(end_time - start_time))
|
|
# -> Appending the Pair
|
|
for data in [current_pair]:
|
|
ws.append(data)
|
|
wb.save("/home/user/mnf/project/MNF/media/file_112_response.xlsx")
|
|
|
|
current_pair = []
|
|
current_pair.append(str("Lingvanex"))
|
|
# -> Translation using Google Translate
|
|
start_time = time.time()
|
|
lingvanex(text, "en", "hi")
|
|
end_time = time.time()
|
|
current_pair.append(str(end_time - start_time))
|
|
# -> Appending the Pair
|
|
for data in [current_pair]:
|
|
ws.append(data)
|
|
wb.save("/home/user/mnf/project/MNF/media/file_112_response.xlsx")
|
|
|
|
|
|
return True |