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 in Dutch verb conjugation #295

Open
EmmaGerritse opened this issue Dec 18, 2019 · 2 comments
Open

Comments

@EmmaGerritse
Copy link

When running the following code:

import pattern.nl
from pattern.nl import conjugate
from pattern.nl import PRESENT, SG, PAST
conjugate("ben", PRESENT, 3, SG)

I get the following error:

Traceback (most recent call last):
  File "/home/emma/miniconda3/lib/python3.7/site-packages/Pattern-3.6-py3.7.egg/pattern/text/__init__.py", line 609, in _read
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/emma/miniconda3/lib/python3.7/site-packages/Pattern-3.6-py3.7.egg/pattern/text/__init__.py", line 2208, in conjugate
    b = self.lemma(verb, parse=kwargs.get("parse", True))
  File "/home/emma/miniconda3/lib/python3.7/site-packages/Pattern-3.6-py3.7.egg/pattern/text/__init__.py", line 2172, in lemma
    self.load()
  File "/home/emma/miniconda3/lib/python3.7/site-packages/Pattern-3.6-py3.7.egg/pattern/text/nl/inflect.py", line 246, in load
    _Verbs.load(self)
  File "/home/emma/miniconda3/lib/python3.7/site-packages/Pattern-3.6-py3.7.egg/pattern/text/__init__.py", line 2127, in load
    for v in _read(self._path):
RuntimeError: generator raised StopIteration

However, if I run conjugate("ben", PRESENT, 3, SG) again in the same shell it works as expected.

@ichuniq
Copy link

ichuniq commented Dec 28, 2019

This is one of the behaviors applied in python 3.7 and Pattern is based on 3.6.
This is also discussed in #282 #283 and stackoverflow

@Pikamander2
Copy link

This appears to be an easy workaround:

def pattern_stopiteration_workaround():
    try:
        print(lexeme('gave'))
    except:
        pass

def main():
    pattern_stopiteration_workaround()
    #Add your other code here

Basically, the pattern code will fail the first time you run it, so you first need to run it once and catch the Exception it throws.

It's worked well enough for my own scripts, but I don't know if it fixes every possible issue.

Ideally though, somebody should fork the clips/pattern project since it's no longer maintained.

endolith added a commit to endolith/character-extraction that referenced this issue Jul 28, 2023
endolith added a commit to endolith/character-extraction that referenced this issue Jul 28, 2023
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

3 participants