【发布时间】:2019-01-17 10:27:59
【问题描述】:
我一直在尝试使用 python 3 代码删除停用词,但我的代码似乎不起作用,我想知道如何从以下列表中删除停用词。示例结构如下:
from nltk.corpus import stopwords
word_split1=[['amazon','brand','-
','solimo','premium','almonds',',','250g','by','solimo'],
['hersheys','cocoa', 'powder', ',', '225g', 'by', 'hersheys'],
['jbl','t450bt','extra','bass','wireless','on-
ear','headphones','with','mic','white','by','jbl','and']]
我正在尝试删除停用词并尝试以下是我的代码,如果有人可以帮助我纠正问题,我将不胜感激。这是下面的代码
stop_words = set(stopwords.words('english'))
filtered_words=[]
for i in word_split1:
if i not in stop_words:
filtered_words.append(i)
我得到错误:
Traceback (most recent call last):
File "<ipython-input-451-747407cf6734>", line 3, in <module>
if i not in stop_words:
TypeError: unhashable type: 'list'
【问题讨论】:
标签: python-3.x nlp stanford-nlp opennlp