-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
lemmatize: StopIteration error in Python 3.7 #2438
Comments
@ajdapretnar what's your version of Pattern? ( Also, please include the full stack trace. |
'3.6' |
And what's the stack trace? |
|
Seems unrelated to Gensim; try contacting the |
Strangely, it works when I am using just Pattern itself.
I will investigate this a bit further, but it seems like a common Python 3.7 problem. |
Great, thanks. Let us know if Pattern changed its APIs recently, and the issue is somehow connected to Gensim after all. Note that Gensim is using |
Actually, it's related to new python 3.7 behavior:
Switching to python 3.6 should solve the issue |
Sounds like something the pattern guys should fix, right? |
I tried to open a PR fixing this issue, but pattern seems to be abandoned since August 2018. I hope that it will be solved one day, because it makes all versions of Python >= 3.7 unable to use gensim's lemmatizer. |
@NicolasBizzozzero Can you please elaborate? I thought |
There is no need to use StopIteration on python generators. Remove all StopIterators, or adds a try execpt outside all functions that returns an generators. Infact you can comment the StopIterator inside read method (\pattern\text_init.py", line 609, in _read)
AFTER
TL;DR But the method that raises the StopIteration exception, specifically, it fails when creating an instance of the Verbs class, which uses a lazy dictionary, that is, it loads when it is going to be used. This is the doc of class Verbs inside pattern
The real problem is inside the _read method, which has a poorly implemented generator, we can see it in the code
The last raise StopIteration will be inside the if else condition, because if the parameter path is null or empty, this method will raise a StopIteration. It would be necessary to add an else after the if path and put the StopIteration inside the else. In addition, the StopIteration would have to be captured by try catch to capture that the file is not found in that path, and in this way it would return well if it finds the file.
|
This appears to be an easier workaround:
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. |
We removed the pattern dependency, so this problem is no longer relevant to gensim. |
For sure it did not ask for pattern as a dependency, but trying to run |
See piskvorky/gensim#2438 for more details
Problem description
Trying to run simple lemmatization as described in the documentation. Getting:
RuntimeError: generator raised StopIteration
Steps/code/corpus to reproduce
Versions
The text was updated successfully, but these errors were encountered: