如何使用NLTK或Python删除停用词
展开全部
1.filtered_words = [w for w in word_list if not w in stopwords.words('english')]
2. 我想您有您想要删除停用词字(WORD_LIST)的列表。你可以这样做:filtered_word_list = word_list[:] #make a copy of the word_list
for word in word_list: # iterate over word_list
if word in stopwords.words('english'):
filtered_word_list.remove(word) # remove word from filtered_word_list if it is a stopword
3. 你也可以做一组差异,例如:list(set(nltk.regexp_tokenize(sentence, pattern, gaps=True)) - set(nltk.corpus.stopwords.words('english')))
2. 我想您有您想要删除停用词字(WORD_LIST)的列表。你可以这样做:filtered_word_list = word_list[:] #make a copy of the word_list
for word in word_list: # iterate over word_list
if word in stopwords.words('english'):
filtered_word_list.remove(word) # remove word from filtered_word_list if it is a stopword
3. 你也可以做一组差异,例如:list(set(nltk.regexp_tokenize(sentence, pattern, gaps=True)) - set(nltk.corpus.stopwords.words('english')))
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询