gpt4 book ai didi

python - 安装 pyemd 时出现错误,即使我刚刚安装它

转载 作者:太空狗 更新时间:2023-10-30 01:26:00 25 4
gpt4 key购买 nike

代码如下:

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])

这是错误:

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.

它正在正确安装,所以我真的不知道出了什么问题。大家遇到过这种情况吗?

最佳答案

我有同样的错误,对我来说解决方案是交换:

from gensim.similarities import WmdSimilarity
from pyemd import emd

进入

from pyemd import emd
from gensim.similarities import WmdSimilarity

不要问我为什么会这样。

关于python - 安装 pyemd 时出现错误,即使我刚刚安装它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47105869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com