Python 向nltk.corpus.stopwords.words(';english';)列表追加额外的stopwords或将其作为集合更新将返回非类型对象
我尝试将nltk中的stopwords追加到其中(作为列表和集合)。但是,它返回一个非类型对象。我采用了以下方法:Python 向nltk.corpus.stopwords.words(';english';)列表追加额外的stopwords或将其作为集合更新将返回非类型对象,python,python-3.x,Python,Python 3.x,我尝试将nltk中的stopwords追加到其中(作为列表和集合)。但是,它返回一个非类型对象。我采用了以下方法: 扩展列表: stopword=列表(stopwords.words('english')) stopword=stopword.extend(['maggi','maggie','#maggi','#maggie'])) 打印(停止字) 没有 更新集合 stopword=set(stopwords.words('english')) stopword=stopword.updat
from nltk.corpus import stopwords
stopword = list(stopwords.words('english'))
l = ['maggi','maggie','#maggi','#maggie']
stopword = stopword + l
print(stopword)
我添加了
list
命令只是为了更好地衡量,因为上面的方法不起作用stopword=stopword.extend('maggi','maggie','#maggi','#maggie'))
仍将None
(扩展函数返回的结果)分配给stopword
我的坏。。。因此,在使用list.extend()的地方,我们可以创建另一个列表并将其添加到stopword中,该列表不提供任何类型的输出。我已相应地编辑了我的答案。