python删除停用词_删除停用词

本文介绍了Python中如何删除停用词,停用词在句子中意义不大,可以安全忽略。通过nltk库下载停用词,并展示了从单词列表中移除停用词的示例。
摘要由CSDN通过智能技术生成

停用词是英语单词,对句子没有多大意义。 在不牺牲句子含义的情况下,可以安全地忽略它们。 例如,the, he, have等等的单词已经在名为语料库的语料库中捕获了这些单词。 我们首先将它下载到python环境中。如下代码 -

import nltk

nltk.download('stopwords')

它将下载带有英语停用词的文件。

验证停用词

from nltk.corpus import stopwords

stopwords.words('english')

print stopwords.words() [620:680]

当运行上面的程序时,得到以下输出 -

[u'your', u'yours', u'yourself', u'yourselves', u'he', u'him', u'his', u'himself', u'she',

u"she's", u'her', u'hers', u'herself', u'it', u"it's", u'its', u'itself', u'they', u'them',

u'their', u'theirs', u'themselves', u'what', u'which', u'who', u'whom', u'this',

u'that', u"that'll", u'these', u'those', u

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值