Python Genism词组库不接受通用术语
我正在尝试使用Gensim.phrases库来识别文本中的短语 我使用了以下方法:Python Genism词组库不接受通用术语,python,gensim,Python,Gensim,我正在尝试使用Gensim.phrases库来识别文本中的短语 我使用了以下方法: bigram = models.Phrases(txt_to_words,min_count=min_count, threshold=threshold,common_terms=common_terms) 我得到了一个错误: <ipython-input-13-1c8b06a0b078> in words_to_phrases(txt_to_words, min_count, threshold
bigram = models.Phrases(txt_to_words,min_count=min_count, threshold=threshold,common_terms=common_terms)
我得到了一个错误:
<ipython-input-13-1c8b06a0b078> in words_to_phrases(txt_to_words, min_count, threshold)
33 common_terms=["of", "with", "without", "and", "or", "the", "a","in","to","is","but"]
34
---> 35 bigram = models.Phrases(txt_to_words,min_count=min_count, threshold=threshold,common_terms=common_terms)
36
37 # trigram
TypeError: __init__() got an unexpected keyword argument 'common_terms'
单词到短语(txt单词、最小计数、阈值)
33通用术语=[“of”、“with”、“without”、“and”、“or”、“the”、“a”、“in”、“to”、“is”、“but”]
34
--->35 bigram=models.Phrases(txt_to_words,min_count=min_count,threshold=threshold,common_terms=common_terms)
36
37#三元图
TypeError:\uuuu init\uuuuuuuuuuuuuuuuuuuuuu()获得意外的关键字参数“common\u terms”
我有最新的gensim软件包2.0+
知道它为什么不识别公共术语参数吗?嗯。。。最新版本是
3.4.0
。
尝试使用pip安装-U gensim
更新gensim
这个玩具示例适用于我:
from gensim.models.phrases import Phrases
txt_to_words = [['first', 'sentence'], ['and', 'second', 'sentence']]
common_terms = ["of", "with", "without", "and", "or", "the", "a","in","to","is","but"]
bigram = Phrases(txt_to_words, min_count=1, common_terms=common_terms)
有些事情真的很奇怪。我刚刚更新到gensim 3.4.0,但它仍然给出了相同的错误。其他人也有类似的问题,记录在。在
gensim3.1
之前,没有通用术语
参数。奇怪的是更新并没有帮你解决这个问题。我可以看到,我在conda env中使用pip更新的当前gensim版本是3.4.0。但它仍然无法识别此参数,因此,当您在代码中运行gensim.\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu?