hhhwwwuuu / BackTranslation

back translation for NLP
https://pypi.org/project/BackTranslation/
MIT License
25 stars 2 forks source link

Proxy Support #2

Open mustfkeskin opened 3 years ago

mustfkeskin commented 3 years ago

Hello I think google ban my ip I want to send request using proxy How i can use proxy BackTranslation

hhhwwwuuu commented 3 years ago

i just added this request. you can install with pip install BackTranslation==0.3.0 please try it with the following sample, and let me know is it work well. thx

from BackTranslation import BackTranslation
trans = BackTranslation(url=[
      'translate.google.com',
      'translate.google.co.kr',
    ], proxies={'http': '127.0.0.1:1234', 'http://host.name': '127.0.0.1:4012'})
result = trans.translate('hello', src='en', tmp = 'zh-cn')
print(result.result_text)
# 'Hello there'
mustfkeskin commented 3 years ago

I think proxies not work

MNGR: Port 24000 updated MNGR: Port 24001 updated

I have 2 proxy services which running on ports 24000 and 24001

from BackTranslation import BackTranslation
trans = BackTranslation(url=[
      'translate.google.com',
      'translate.google.com.tr',
    ], proxies={'http':'http://127.0.0.1:24000',
                'http': 'http://127.0.0.1:24001'})

I run this code different cell in jupyter notebook

for i in range(10000):
    result = trans.translate('mustafa koşa koşa okula gitti', src='tr', tmp = 'en')
    print(result.result_text)

I got this error when I try to translate same text thousands of time AttributeError: 'Translator' object has no attribute 'raise_Exception'