Skip to content

Commit

Permalink
Fix the example code for SoftCosineSimilarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Jan 25, 2019
1 parent 01c5336 commit f4a2d00
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gensim/similarities/docsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,13 +866,13 @@ class SoftCosineSimilarity(interfaces.SimilarityABC):
>>> from gensim.test.utils import common_texts
>>> from gensim.corpora import Dictionary
>>> from gensim.models import Word2Vec, WordEmbeddingSimilarityIndex
>>> from gensim.similarities import SoftCosineSimilarity, TermSimilarityMatrix
>>> from gensim.similarities import SoftCosineSimilarity, SparseTermSimilarityMatrix
>>>
>>> model = Word2Vec(common_texts, size=20, min_count=1) # train word-vectors
>>> termsim_index = WordEmbeddingSimilarityIndex(model)
>>> termsim_index = WordEmbeddingSimilarityIndex(model.wv)
>>> dictionary = Dictionary(common_texts)
>>> bow_corpus = [dictionary.doc2bow(document) for document in common_texts]
>>> similarity_matrix = TermSimilarityMatrix(termsim_index, dictionary) # construct similarity matrix
>>> similarity_matrix = SparseTermSimilarityMatrix(termsim_index, dictionary) # construct similarity matrix
>>> docsim_index = SoftCosineSimilarity(bow_corpus, similarity_matrix, num_best=10)
>>>
>>> query = 'graph trees computer'.split() # make a query
Expand Down

0 comments on commit f4a2d00

Please sign in to comment.