Open Heart-beatsss opened 2 years ago
I met the same issue just now :(
me as well...
the same issue for me
lt seems that the variable "translation" is None, which means the request is failed. I can translate the toturial sentence, while fail in my own sentence.
def get_translation(self, text): data = self._make_request(text) translation = data['responseData']['translatedText'] if translation: return translation else: matches = data['matches'] next_best_match = next(match for match in matches) return next_best_match['translation']
Thanks for pasting the original code, so that it could be possible for reminding me of the question I faced previously.
Maybe you could try to split the whole passage into several sentences with NLP toolkits and try again.
In fact, I gave up the task at that time because it is unworthy of debugging considering efficiency. So what I said above may just a uncertain solution to think further, and hope you could solve the bug soon.
At 2022-06-22 16:03:00, "Jiongrui Huang" @.***> wrote:
lt seems that the variable "translation" is None, which means the request is failed. I can translate the toturial sentence, while fail in my own sentence.
def get_translation(self, text):
data = self._make_request(text)
translation = data['responseData']['translatedText']
if translation:
return translation
else:
matches = data['matches']
next_best_match = next(match for match in matches)
return next_best_match['translation']
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
\translate\providers\mymemory_translated.py
def get_translation(self, text):
data = self._make_request(text)
translation = data['responseData']['translatedText']
if translation:
return translation
else:
matches = data['matches']
next_best_match = next(match for match in matches)
return next_best_match['translation']
translation is None -> matches is None -> error
Traceback (most recent call last): File "...translate\translate.py", line 45, in
return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)
File "...translate\providers\mymemory_translated.py", line 49, in get_translation
next_best_match = next(match for match in matches)
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "...", line 20, in
twitterProcess_1()
File "...", line 18, in twitterProcess_1
print(translator.translate(text))
File "...translate.py", line 45, in translate
return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)
RuntimeError: generator raised StopIteration