gensimを用いてtfidf処理を行おうとしたら、エラーがでます
以下にエラー箇所とエラー文を示します
python
1gensim_dictionary = corpora.Dictionary(doc_nltk) 2 3------------------------------------------------------------ 4Traceback (most recent call last): 5 File "tfidf_gensim_hyouka.py", line 71, in <module> 6 tfidf() 7 File "tfidf_gensim_hyouka.py", line 34, in tfidf 8 gensim_dictionary = corpora.Dictionary(doc_nltk) 9 File "C:\Users\AppData\Local\conda\conda\envs\anaconda\lib\site-packages\gensim\corpora\dictionary.py", line 58, in __init__ 10 self.add_documents(documents, prune_at=prune_at) 11 File "C:\Users\AppData\Local\conda\conda\envs\anaconda\lib\site-packages\gensim\corpora\dictionary.py", line 119, in add_documents 12 self.doc2bow(document, allow_update=True) # ignore the result, here we only care about updating token ids 13 File "C:\Users\AppData\Local\conda\conda\envs\anaconda\lib\site-packages\gensim\corpora\dictionary.py", line 141, in doc2bow 14 raise TypeError("doc2bow expects an array of unicode tokens on input, not a single string") 15TypeError: doc2bow expects an array of unicode tokens on input, not a single string
doc_nltkというのは
['grab', 'briskly', 'slimmer', 'supervisor', 'crowded', … 以下略 …]
のような配列になっています
これは、このような一次元配列ではできないということですか?
一次元配列で処理を行うにはどうすればよいでしょうか
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/20 11:03
2017/11/21 02:37 編集
2017/11/21 09:29
2017/11/21 09:31
2017/11/22 00:35
2017/11/22 01:05