|
说明:win10,python3.6.4,IDE:pycharm
有已经分词,去停用词,去低频词的100份txt文档,每份txt文档内容示例如下
经济 生态 发现去除效果 水力 停留时间 占地面积 水力 抗冲击 潜流湿地 特征
参考https://blog.csdn.net/sinat_26917383/article/details/79339727#t11博客下关于官网的代码,但是报错
Traceback (most recent call last):
File "D:/ATModel/no_loop5.py", line 80, in <module>
dictionary = Dictionary(docs) # 百度后,此处docs改为[docs]不能解决实际问题
File "D:\Python3.6.4\lib\site-packages\gensim\corpora\dictionary.py", line 79, in __init__
self.add_documents(documents, prune_at=prune_at)
File "D:\Python3.6.4\lib\site-packages\gensim\corpora\dictionary.py", line 195, in add_documents
self.doc2bow(document, allow_update=True) # ignore the result, here we only care about updating token ids
File "D:\Python3.6.4\lib\site-packages\gensim\corpora\dictionary.py", line 233, in doc2bow
raise TypeError("doc2bow expects an array of unicode tokens on input, not a single string")
TypeError: doc2bow expects an array of unicode tokens on input, not a single string
好像是我没有处理docs,没有单词和对应id的映射,但不知道怎么解决。
卡在这里快一个月了,希望得到帮助,求解决
|
-
第12篇文档处理后结果
|