Skip to content

Fix WordEmbeddingsKeyedVectors.most_similar#2461

Merged
mpenkov merged 11 commits into
piskvorky:developfrom
Witiko:fix-topn-None
May 4, 2019
Merged

Fix WordEmbeddingsKeyedVectors.most_similar#2461
mpenkov merged 11 commits into
piskvorky:developfrom
Witiko:fix-topn-None

Conversation

@Witiko
Copy link
Copy Markdown
Contributor

@Witiko Witiko commented Apr 23, 2019

This PR continues #2356 in reaction to #2455. The PR accomplishes the following:

  • Regain support for most_similar(…, topn=x), where bool(x) is False.
  • Document most_similar(…, topn=None).
  • Support topn=None in most_similar_cosmul, similar_by_word, and similar_by_vector.
  • Disable indexer in most_similar when topn is None, since indexers don't support topn=None.

Comment thread gensim/models/keyedvectors.py Outdated
Comment thread gensim/models/keyedvectors.py Outdated
Comment thread gensim/models/keyedvectors.py Outdated
Copy link
Copy Markdown
Collaborator

@mpenkov mpenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR.

I notice this PR fixes a bug. I think it would be helpful to introduce a unit test that reproduces the bug (fails on old code) and passes on new code. This will:

  1. Objectively confirm that the bug has been fixed
  2. Prevent future regressions of the same bug

What do you think? Is it possible to test this new fix?

@mpenkov mpenkov added the bugfix label Apr 28, 2019
@Witiko
Copy link
Copy Markdown
Contributor Author

Witiko commented Apr 29, 2019

What do you think? Is it possible to test this new fix?

Thank you for the review. I added two unit tests in fbfe2d4 and fcfc638.

Copy link
Copy Markdown
Collaborator

@mpenkov mpenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you for your contribution.

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.

2 participants