-
-
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
keywords.py gives IndexError: list index out of range
when words
parameter is provided.
#2598
Comments
IndexError: list index out of range
when words parameter is provided.IndexError: list index out of range
when words
parameter is provided.
This could well be a bug. Are you able to step through the problem with a debugger? |
Yes going through with the debugger I can see why the following lines (in length = len(lemmas) * ratio if words is None else words
return [(scores[lemmas[i]], lemmas[i],) for i in range(int(length))] I'm unsure what would be the best way to handle this, perhaps just cap the maximum value of the final range if |
@arielFrischer Can you go through the source and determine what are the invariants are of these variables? Unfortunately none of are familiar with this code. |
I looked at the code; IMO there is an implicit (unchecked) invariant that If @mpenkov can we somehow track the original contributor and check with them what this is about? Because I'm not sure if a simple |
Hi, can I have a go at this? |
Sure. I think the main part of this ticket will be investigating what the original contributor was trying to achieve, as @piskvorky pointed out. |
Really confused why I'm getting this error. Perhaps I'm making a silly mistake I'm not familiar with gensim and nlp in general.
Im running on Windows 10 Home 64-bit, conda version : 4.7.11, conda-build version : 2.18.8, python version : 3.7.3.final.0
My code is attempting to get keywords per sentence in a loop. To simplify matters I've isolated the following code that causes this, trying to get keywords from gensim's
keywords.py
.I've tried setting
scores=True
,lemmatize=False
, andsplit=False
but the same error persists. I've also tried removing the parenthesis and removing the apostrophe, the error persisted. What did work is removing thewords
parameter altogether, but still it shouldn't create an error if it's provided. Thanks for the help in advance!The text was updated successfully, but these errors were encountered: