如何使用nltk或python删除停用词 [英] How to remove stop words using nltk or python

查看:318
本文介绍了如何使用nltk或python删除停用词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个数据集,我想从中删除停用词

So I have a dataset that I would like to remove stop words from using

stopwords.words('english')

我正在努力如何在代码中使用此代码来简单地删除这些单词.我已经有了这个数据集中的单词列表,我正在努力的部分是与此列表进行比较并删除停用词. 感谢您的帮助.

I'm struggling how to use this within my code to just simply take out these words. I have a list of the words from this dataset already, the part i'm struggling with is comparing to this list and removing the stop words. Any help is appreciated.

推荐答案

from nltk.corpus import stopwords
# ...
filtered_words = [word for word in word_list if word not in stopwords.words('english')]

这篇关于如何使用nltk或python删除停用词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆