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

Missing ic argument in res, jcn and lin similarity functions of wordnet #2970

Merged

Conversation

aperezlebel
Copy link
Contributor

Hello,

I just ran into a little bug when using res_similarity, jcn_similarity and lin_similarity functions. The ic argument is not passed to the corresponding methods of the Synset class.

Example:

import nltk
from nltk.corpus import wordnet as wn
from nltk.corpus.reader.wordnet import jcn_similarity, lin_similarity, res_similarity

nltk.download('wordnet')

# Random synsets
s1 = wn.synset_from_pos_and_offset('n', 7579787)
s2 = wn.synset_from_pos_and_offset('n', 2226429)

ic = {}
res_similarity(s1, s2, ic)
jcn_similarity(s1, s2, ic)
lin_similarity(s1, s2, ic)

Throws:
TypeError: 'bool' object is not subscriptable

@tomaarsen
Copy link
Member

Well spotted! The verbose parameter on the calling side was filling the ic parameter on the function side. Alongside your changes I've ensured that verbose is only passed as a keyword argument. I've also fixed the pre-commit failing tests (caused by some ill-formatted code).

I appreciate it! I'll merge this once tests pass.

@tomaarsen tomaarsen merged commit 8e71ee6 into nltk:develop May 1, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants