Here is the code:
from pyemd import emd
print("sentence 1:")
print(input_document_lower[0])
print("sentence 2:")
print(input_document_lower[1])
print("similarity:")
model_w2v.wmdistance(input_document_lower[0], input_document_lower[1])
Here's the error:
sentence 1:
incorrect batch number printed primary label pbn
sentence 2:
unconfirmed oos met vial washing qualification sample per
similarity:
ImportErrorTraceback (most recent call last)
<ipython-input-201-50af089a2354> in <module>()
4 print(input_document_lower[1])
5 print("similarity:")
----> 6 model_w2v.wmdistance(input_document_lower[0], input_document_lower[1])
C:\ProgramData\Anaconda2\lib\site-packages\gensim\models\word2vec.pyc in wmdistance(self, document1, document2)
1308 Refer to the documentation for `gensim.models.KeyedVectors.wmdistance`
1309 """
-> 1310 return self.wv.wmdistance(document1, document2)
1311
1312 def most_similar_cosmul(self, positive=None, negative=None, topn=10):
C:\ProgramData\Anaconda2\lib\site-packages\gensim\models\keyedvectors.pyc in wmdistance(self, document1, document2)
386
387 if not PYEMD_EXT:
--> 388 raise ImportError("Please install pyemd Python package to compute WMD.")
389
390 # Remove out-of-vocabulary words.
ImportError: Please install pyemd Python package to compute WMD.
It is being installed properly so I really have no clue as to what is going wrong. Have any of your encountered this?
I had the same error, and for me the solution was to swap:
from gensim.similarities import WmdSimilarity
from pyemd import emd
into
from pyemd import emd
from gensim.similarities import WmdSimilarity
Don't ask me why it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With