I wanted to check if WmdSimilarity is any better (it should not be) from multiprocessing wmdistance, but it did not work at all.
So, I made a little example and the result was exactly the same...
Could someone check what is wrong with me or gensim? ;)
from gensim.models import Word2Vec
from gensim.similarities import WmdSimilarity
a = "Trump’s decision not to join the Trans-Pacific Partnership (TPP) came as little surprise. During his election campaign he railed against international trade deals, blaming them for job losses and focusing anger in the industrial heartland. Obama had argued that this deal would provide an effective counterweight to China in the region."
b = "Trump's decision to withdraw the US from TPP is also a first step in the administration's efforts to amass a governing coalition to push the new President's agenda, one that includes the blue-collar workers who defected from Democrats and flocked to Trump's candidacy in November."
c = "Although the Trans-Pacific Partnership had not been approved by Congress, Mr. Trump’s decision to withdraw not only doomed former President Barack Obama’s signature trade achievement, but also carried broad geopolitical implications in a fast-growing region. The deal, which was to link a dozen nations from Canada and Chile to Australia and Japan in a complex web of trade rules, was sold as a way to permanently tie the United States to East Asia and create an economic bulwark against a rising China."
w2v_model = Word2Vec(corpus, alpha=0.025, vector_size=50,
window=5, min_count=1, workers=2, epochs=50, sg = 0)
corpus = "\n".join([a,b,c])
model = w2v(corpus)
Word2Vec(vocab=47, vector_size=50, alpha=0.025) <class 'gensim.models.word2vec.Word2Vec'>
Traceback (most recent call last):
File "/home/tedo/diagnose/proba.py", line 18, in <module>
File "/usr/local/lib/python3.9/dist-packages/gensim/similarities/docsim.py", line 1099, in __str__
return "%s<%i docs, %i features>" % (self.__class__.__name__, len(self), self.w2v_model.wv.syn0.shape)
AttributeError: 'WmdSimilarity' object has no attribute 'w2v_model'