From d7cbe1835f46ae258e583b3228177bf6d08f489b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Novotn=C3=BD?= Date: Mon, 28 Jan 2019 11:03:28 +0100 Subject: [PATCH] Fix the example code for SparseTermSimilarityMatrix (#2359) --- gensim/similarities/termsim.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gensim/similarities/termsim.py b/gensim/similarities/termsim.py index 6a0b6d12b5..167b73b241 100644 --- a/gensim/similarities/termsim.py +++ b/gensim/similarities/termsim.py @@ -128,13 +128,13 @@ class SparseTermSimilarityMatrix(SaveLoad): >>> 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