nltk(自然语言)相关的知识

更详细情况参考:http://python.jobbole.com/88874/

在使用nltk之前,要通过运行以下代码来安装相关需要的NLTK扩展包,在直接面板安装。在这里插入图片描述

from nltk.tokenize import word_tokenize, sent_tokenize。

word_tokenize(str),从提供的本中分离出包含每个句子列表。
sent_tokenize(str),从提供的句子中分离出包含每个单词的列表。

from nltk.corpus import stopwords

stopwords.words(‘english’),其实就是得到一个内置停用词的列表,如下:

class 'list'> ['the', 'because', 'ma', 'hadn', 'of', 'i', 'both', 'm', 'how', 'between', 'down', "doesn't", 'under', 'that', 'have', 'or', 'by', 'your', 'other', 'about', 'will', 'to', 'he', 'now', 'wouldn', 'while', 'nor', "shan't", 'o', 'with', 'doesn', 'can', 'has', "you'd", 'any', "don't", 'ain', 're', 'themselves', 'herself', 'needn', 'over', 'here', 'from', "couldn't", "needn't", 'yours', 'for', 'such', 'there', 'his', 'me', 'itself', 'below', 'hers', 'be', 'her', 'not', 'as', 'no', 'yourselves', 'mightn', 'myself', 'why', 'couldn', 'again', 'won', 'after', 'same', "that'll", 's', 'at', "hasn't", 'were', 'am', "didn't", 'some', 'too', 'we', 'just', 'you', 'd', 'its', 'on', 'whom', "mustn't", 'she', 'this', 'an', 'most', 'own', 'into', 'shan', 'hasn', "shouldn't", "wouldn't", 'ours', 'haven', 'and', "you'll", 'until', 'through', 'during', 'up', 'do', 'then', "aren't", "you've", 'off', 'when', 'does', 'are', 've', "mightn't", 'mustn', 'having', 'out', 'if', 'wasn', 'theirs', 'they', 'against', "won't", 'which', 'only', "you're", 'was', "should've", 'once', 'doing', 'been', 'their', 'is', 'before', 'being', 'aren', 'himself', 'few', 'y', "hadn't", 'don', 'so', 'those', 'above', 'a', "wasn't", "haven't", 'isn', "isn't", 'weren', 'did', 'yourself', 'in', 'than', 'very', "it's", 'these', 'had', "weren't", 'who', 'our', 'll', 't', 'but', 'didn', 'all', 'my', 'them', 'what', 'ourselves', 'should', 'each', 'where', 'him', 'it', "she's", 'more', 'further', 'shouldn']

也可以照自己特定需要,自己做一个这样的列表。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值