python中的stopwords_如何从python的常用词列表中删除stopwords

如果您想要一套完整的停止语,可以使用nltk中提供的列表,如下所示:from nltk.corpus import stopwords

stop_words = stopwords.words('english')

sentence = [('the', 2112), ('and', 1914), ('to', 1505), ('of', 1086), ('a', 986), ('you', 912),

('in', 754), ('with', 549), ('is', 536), ('for', 473), ('it', 461), ('book', 427),

('how', 368), ('that', 347), ('as', 304), ('on', 301), ('this', 290), ('java', 289),

('s', 267), ('your', 263), ('applications', 248), ('web', 231), ('can', 219),

('new', 218), ('an', 206), ('are', 197), ('will', 187), ('from', 185), ('use', 185), ('ll', 183),

('development', 182), ('code', 180), ('by', 177), ('programming', 172), ('application', 170), ('or', 169),

('action', 163), ('developers', 150), ('features', 141), ('examples', 139), ('learn', 135), ('using', 132),

('be', 132), ('data', 131), ('more', 118), ('like', 115), ('build', 110), ('into', 109), ('net', 106), ('language', 105)]

sentence = [(word, count) for word, count in sentence if word not in stop_words]

print sentence

这将使您sentence为:

^{pr2}$

您可以使用pip install nltk来获取库。然后,您可能需要先安装停止字,如下所示:import nltk

nltk.download()

这将显示一个下载实用程序,允许您按如下方式获取停止字:

E4tKa.gif

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值