Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion glove/glove.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def most_similar(self, word, number=5):
except KeyError:
raise Exception('Word not in dictionary')

return self._similarity_query(self.word_vectors[word_idx], number)[1:]
return self._similarity_query(self.word_vectors[word_idx], number + 1)[1:]

def most_similar_paragraph(self, paragraph, number=5, **kwargs):
"""
Expand Down
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ If you want to process a wikipedia corpus, you can pass file from [here](http://
Running this on my machine yields roughly the following results:

```
In [1]: glove.most_similar('physics')
In [1]: glove.most_similar('physics', number=4)
Out[1]:
[('biology', 0.89425889335342257),
('chemistry', 0.88913708236100086),
('quantum', 0.88859617025616333),
('mechanics', 0.88821824562025431)]

In [4]: glove.most_similar('north')
In [4]: glove.most_similar('north', number=4)
Out[4]:
[('west', 0.99047203572917908),
('south', 0.98655786905501008),
('east', 0.97914140138065575),
('coast', 0.97680427897282185)]

In [6]: glove.most_similar('queen')
In [6]: glove.most_similar('queen', number=4)
Out[6]:
[('anne', 0.88284931171714842),
('mary', 0.87615260138308615),
('elizabeth', 0.87362497374226267),
('prince', 0.87011034923161801)]

In [19]: glove.most_similar('car')
In [19]: glove.most_similar('car', number=4)
Out[19]:
[('race', 0.89549347066796814),
('driver', 0.89350343749207217),
Expand Down