textaugment icon indicating copy to clipboard operation
textaugment copied to clipboard

Traslation: HTTPError: HTTP Error 404: Not Found

Open Nomiluks opened this issue 2 years ago • 1 comments

I am unable to translate text from one language to other.

Code:

from textaugment import Translate

t = Translate(src="en", to="fr")
t.augment('In the afternoon, John is going to town')

Error: `--------------------------------------------------------------------------- HTTPError Traceback (most recent call last) in 2 3 t = Translate(src="en", to="fr") ----> 4 t.augment('In the afternoon, John is going to town')

/usr/local/lib/python3.7/site-packages/textaugment/translate.py in augment(self, data) 134 data = TextBlob(data.lower()) 135 try: --> 136 data = data.translate(from_lang=self.src, to=self.to) 137 data = data.translate(from_lang=self.to, to=self.src) 138 except NotTranslated:

/usr/local/lib/python3.7/site-packages/textblob/blob.py in translate(self, from_lang, to) 545 """ 546 return self.class(self.translator.translate(self.raw, --> 547 from_lang=from_lang, to_lang=to)) 548 549 def detect_language(self):

/usr/local/lib/python3.7/site-packages/textblob/translate.py in translate(self, source, from_lang, to_lang, host, type_) 52 tk=calculate_tk(source), 53 ) ---> 54 response = self.request(url, host=host, type=type, data=data) 55 result = json.loads(response) 56 if isinstance(result, list):

/usr/local/lib/python3.7/site-packages/textblob/translate.py in request(self, url, host, type, data) 90 if host or type_: 91 req.set_proxy(host=host, type=type_) ---> 92 resp = request.urlopen(req) 93 content = resp.read() 94 return content.decode('utf-8')

/usr/local/lib/python3.7/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 220 else: 221 opener = _opener --> 222 return opener.open(url, data, timeout) 223 224 def install_opener(opener):

/usr/local/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout) 529 for processor in self.process_response.get(protocol, []): 530 meth = getattr(processor, meth_name) --> 531 response = meth(req, response) 532 533 return response

/usr/local/lib/python3.7/urllib/request.py in http_response(self, request, response) 639 if not (200 <= code < 300): 640 response = self.parent.error( --> 641 'http', request, response, code, msg, hdrs) 642 643 return response

/usr/local/lib/python3.7/urllib/request.py in error(self, proto, *args) 567 if http_err: 568 args = (dict, 'default', 'http_error_default') + orig_args --> 569 return self._call_chain(*args) 570 571 # XXX probably also want an abstract factory that knows when it makes

/usr/local/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args) 501 for handler in handlers: 502 func = getattr(handler, meth_name) --> 503 result = func(*args) 504 if result is not None: 505 return result

/usr/local/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs) 647 class HTTPDefaultErrorHandler(BaseHandler): 648 def http_error_default(self, req, fp, code, msg, hdrs): --> 649 raise HTTPError(req.full_url, code, msg, hdrs, fp) 650 651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found

`

Nomiluks avatar Oct 05 '21 14:10 Nomiluks

[Upstream] Translation is broken due to Google API change

see sloria/TextBlob#397 We will update the code once resolved or use alternative method

JosephSefara avatar Oct 05 '21 15:10 JosephSefara

@Nomiluks could you help with checking again and if still persists suggest a change or do a pull request.

vukosim avatar Nov 17 '23 08:11 vukosim

Error is related to dependency package.

JosephSefara avatar Nov 22 '23 13:11 JosephSefara