-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: generator raised StopIteration #95
Comments
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.
|
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: