Skip to content
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

Open
Heart-beatsss opened this issue Apr 24, 2022 · 6 comments
Open

RuntimeError: generator raised StopIteration #95

Heart-beatsss opened this issue Apr 24, 2022 · 6 comments

Comments

@Heart-beatsss
Copy link

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

@Hollie7
Copy link

Hollie7 commented May 11, 2022

I met the same issue just now :(

@HudsonLeong
Copy link

me as well...

@IMMORTAL23
Copy link

the same issue for me

@IMMORTAL23
Copy link

IMMORTAL23 commented Jun 22, 2022

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'] 

@HudsonLeong
Copy link

HudsonLeong commented Oct 11, 2022 via email

@akynazh
Copy link

akynazh commented Feb 18, 2023

\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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants