Skip to content

Commit

Permalink
In similarity_matrix, process rows in index order when IDFs are the same
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Mar 17, 2018
1 parent db303b2 commit 6dcb687
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gensim/models/keyedvectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ def similarity_matrix(self, dictionary, tfidf=None, threshold=0.0, exponent=2.0,
else:
assert max(tfidf.idfs) < matrix_order
word_indices = [
index for index, _ in sorted(tfidf.idfs.items(), key=lambda x: x[1], reverse=True)
index for index, _
in sorted(tfidf.idfs.items(), key=lambda x: (x[1], -x[0]), reverse=True)
]

# Traverse rows.
Expand Down

0 comments on commit 6dcb687

Please sign in to comment.