【发布时间】:2015-10-20 06:20:23
【问题描述】:
我从一些 python 任务开始,我在使用 gensim 时遇到了问题。我正在尝试从我的磁盘加载文件并处理它们(拆分它们并小写()它们)
我的代码如下:
dictionary_arr=[]
for file_path in glob.glob(os.path.join(path, '*.txt')):
with open (file_path, "r") as myfile:
text=myfile.read()
for words in text.lower().split():
dictionary_arr.append(words)
dictionary = corpora.Dictionary(dictionary_arr)
列表 (dictionary_arr) 包含所有文件中所有单词的列表,然后我使用 gensim corpora.Dictionary 来处理列表。但是我遇到了一个错误。
TypeError: doc2bow expects an array of unicode tokens on input, not a single string
我不明白有什么问题,不胜感激。
【问题讨论】: