這段代碼是給我一個錯誤unhashable type: dict
任何人都可以給我解釋一下什麼是類型錯誤:unhashable類型:「字典」
negids = movie_reviews.fileids('neg')
def word_feats(words):
return dict([(word, True) for word in words])
negfeats = [(word_feats(movie_reviews.words(fileids=[f])), 'neg') for f in negids]
stopset = set(stopwords.words('english'))
def stopword_filtered_word_feats(words):
return dict([(word, True) for word in words if word not in stopset])
result=stopword_filtered_word_feats(negfeats)
RTD http://docs.python.org/2.7/library/stdtypes.html#mapping-types-dict – iMom0
這將會是有益的顯示錯誤報告,所以我們可以看到哪一行有問題... – drevicko