Open jhkd-kevin opened 3 years ago
from BackTranslation import BackTranslation
trans = BackTranslation()
# set Korean as middle language. and auto detect the source language
result = trans.translate('Anh ấy đã chữa khỏi cảm cúm bằng aspirin.', tmp='ko')
# source text
print(result.source_text)
# Anh ấy đã chữa khỏi cảm cúm bằng aspirin.
# middle text
print(result.tran_text)
# 그는 아스피린으로 독감을 잡았습니다.
# backtranslated text
print(result.result_text)
# Ông bị cúm với aspirin.
Hope it will help you
I can use google translator And I actually follow your step: This is my complete code:
from BackTranslation import BackTranslation trans = BackTranslation(url=[ 'translate.google.com', 'translate.google.co.kr', ]) result = trans.translate('Anh ấy đã chữa khỏi cảm cúm bằng aspirin.', tmp='ko')
print(result.source_text) print(result.tran_text) print(result.result_text)
However, As I run it, it call back
ConnectError: [Errno 0] Error
@jhkd-kevin Is there any more error info?
This is full error info, thanks for your help: ConnectError Traceback (most recent call last)
@jhkd-kevin Sorry for the late reply.
I applied your code in my env. It works fine. I am not sure where the error from. But, there are two possible reasons. plz try the following solutions.
from BackTranslation import BackTranslation
trans = BackTranslation()
result = trans.translate('Anh ấy đã chữa khỏi cảm cúm bằng aspirin.', tmp='ko')
from BackTranslation import BackTranslation
trans = BackTranslation(url=['url that you used from browser']) # plz replace it
result = trans.translate('Anh ấy đã chữa khỏi cảm cúm bằng aspirin.', tmp='ko')
please let me know whether this is work. Thanks
Can you provide a complete example such as translation: "Anh ấy đã chữa khỏi cảm cúm bằng aspirin. "