- 博客(8)
- 资源 (1)
- 收藏
- 关注
原创 第1、2章 分词、词干提取
把文章分为句子para = "Hello World. It's good to see you. Thanks for buying this book."from nltk.tokenize import sent_tokenizesent_tokenize(para)把句子分为单词from nltk.tokenize import word_tokeniz
2015-09-21 00:16:46 1501
原创 第六章 文本分类
def gender_features(word):return {'last_letter':word[-1]}定义一个性别特征,通过尾字母进行判断names = ([(name, 'male') for name in names.words('male.txt')] + [(name, 'female') for name in names.words('fem
2015-09-12 18:35:40 541
原创 第五章 分类和词性标注
import nltktext = nltk.word_tokenize("And now for something completely different")a=nltk.pos_tag(text)分词后进行词性标注,CC是连词,RB是副词,IN是介词,NN是名词,JJ是形容词,可以使用nltk.help.upenn_tagset('RB')查询缩写字
2015-09-07 15:34:36 982
原创 第四章 编写结构化程序
遍历的几种方法:for item in s 遍历s 中的元素for item in sorted(s) 按顺序遍历s 中的元素for item in set(s) 遍历s 中的无重复的元素for item in reversed(s) 按逆序遍历s 中的元素for item in set(s).difference(t) 遍历在集合s 中不在集合t 的元素for item
2015-09-02 16:39:27 464
原创 第三章 原料加工
raw.find("PART I")raw.rfind("End of Project Gutenberg's Crime")通过find和rfind标记文章的开始和末尾将要处理的文本拷贝到python文件夹下后,f=open("2008.txt")raw=f.read()words=raw.split()len(words)转化为单词逐
2015-08-29 16:37:26 482
原创 第二章 获取文本语料和词汇资源
nltk.corpus.gutenberg.fileids()加载自带的书籍emma = nltk.corpus.gutenberg.words('austen-emma.txt')读取其中一本书,注意此时还无法进行处理emma=nltk.Text(emma)将书转化为单词资源或者from nltk.corpus import gutenberggutenb
2015-08-27 20:10:13 516
原创 第一章 Python and NLTK
*搜索文本import nltk 引入包nltk.download下载所需文档from nltk.book import *输入全部文档text1.concordance("monwtrous")关键字查询text1.similar("monstrous")类似词语查询text4.dispersion_plot(["citizens",
2015-08-24 16:21:40 673
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人