Skip to content

Commit

Permalink
PR piskvorky#986 merged in wmd in keyedvectors.py
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolgulati committed Oct 31, 2016
1 parent 7a6c281 commit 0690597
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gensim/models/keyedvectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def wmdistance(self, document1, document2):
dictionary = Dictionary(documents=[document1, document2])
vocab_len = len(dictionary)

if vocab_len == 1:
# Both documents are composed by a single unique token
return 0.0

# Sets for faster look-up.
docset1 = set(document1)
docset2 = set(document2)
Expand Down

0 comments on commit 0690597

Please sign in to comment.