NLTK自带的词干提取器
来源:互联网 发布:乐视线刷软件 编辑:程序博客网 时间:2024/06/08 03:36
代码来自《Python自然语言处理》P116
(python2.7) appleyuchi@ubuntu:~/.virtualenvs/python2.7/bin$ pythonPython 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> raw="""DENNIS:Listen,strange women lying in ponds distributing swords is... is no basis for a system of goverment. Supreme executive power derives from... a mandate from the masses, not from some farcical aquatic ceremony.""">>> import nltk>>> tokens=nltk.word_tokenize(raw)>>> porter = nltk.PorterStemmer()>>> lancaster=nltk.LancasterStemmer()>>> [porter.stem(t) for t in tokens][u'denni', ':', 'listen', ',', u'strang', 'women', u'lie', 'in', u'pond', u'distribut', u'sword', 'is', '...', 'is', 'no', u'basi', 'for', 'a', 'system', 'of', u'gover', '.', u'suprem', u'execut', 'power', u'deriv', 'from', '...', 'a', u'mandat', 'from', 'the', u'mass', ',', 'not', 'from', 'some', u'farcic', u'aquat', u'ceremoni', '.']>>> [lancaster.stem(t) for t in tokens]['den', ':', 'list', ',', 'strange', 'wom', 'lying', 'in', 'pond', 'distribut', 'sword', 'is', '...', 'is', 'no', 'bas', 'for', 'a', 'system', 'of', 'gov', '.', 'suprem', 'execut', 'pow', 'der', 'from', '...', 'a', 'mand', 'from', 'the', 'mass', ',', 'not', 'from', 'som', 'farc', 'aqu', 'ceremony', '.']
上述代码中,raw是原始余料,最后几行是词干提取结果。
以上代码总共使用了两种词干提取器,分别是Porter和Lancaster
阅读全文
0 0
- NLTK自带的词干提取器
- nltk词干提取
- NLTK提取全文词干
- 词干提取器索引文本
- 英文分词+提取词干
- 英文单词词干提取算法
- Python NLTK提取有用的chunk
- Porter Algorithm ---------词干提取算法
- 词干提取和词形还原
- Porter Algorithm ---------词干提取算法
- 词干提取和词形还原
- android 图片剪裁 ,从android自带图库提取的
- 使用OPENCV自带的sift提取特征
- 扩展 vfp9 自带的对象浏览器提取枚举值
- 使用OPENCV自带的sift提取特征
- 为C# 设计的Snowball Stemmer---词干提取但不包含中文
- Python利用nltk的clean_html提取htm文件的内容
- 词干提取算法Porter Stemming Algorithm解读
- FATE
- 最适合初学者的 IntelliJ IDEA 教程 (2)- 最常见的显示设置和快捷键
- CentOS下通过yum安装nodejs等
- leetcode 3Sum
- python_20171122_python3.6.1 pd.read_csv()输入中文路径OSError: Initializing from file failed
- NLTK自带的词干提取器
- PC端的神器软件
- Python运维自动化开发之Fabric模块
- idea 创建 java web项目(图文)
- 使用request-promise验证url的可访问性
- 增删改查
- 32位Linux系统的虚拟地址映射 <二>
- 剑指offer每日一刷-2017年11月22日
- netty源码分析之-ChannelHandler与ChannelContext详解(7)