python去掉停用词_Python - 删除停用词

本文介绍了如何在Python中使用nltk库去除英语文本中的停用词,包括下载停用词库、展示停用词列表,并通过示例展示从单词列表中移除停用词的过程。
摘要由CSDN通过智能技术生成

停用词是英语单词,对句子没有多大意义。在不牺牲句子含义的情况下,可以安全地忽略它们。例如,像,他,等等的单词已经在名为语料库的语料库中捕获了这些单词。我们首先将它下载到我们的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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值