python27使用jieba分词,去除停用词
2017-03-05 20:55
465 查看
# -*- coding: utf-8 -*- import jieba import jieba.analyse import sys import codecs reload(sys) sys.setdefaultencoding('utf-8') #使用其他编码读取停用词表 #stoplist = codecs.open('../../file/stopword.txt','r',encoding='utf8').readlines() #stoplist = set(w.strip() for w in stoplist) #停用词文件是utf8编码 stoplist = {}.fromkeys([ line.strip() for line in open("../../file/stopword.txt") ]) #经过分词得到的应该是unicode编码,先将其转成utf8编码 segs = jieba.cut('北京附近的租房', cut_all=False) segs = [word.encode('utf-8') for word in list(segs)] segs = [word for word in list(segs) if word not in stoplist] for seg in segs: print seg
相关文章推荐
- python使用jieba实现中文分词去停用词方法示例
- 使用Python+jieba和java+庖丁分词在Spark集群上进行中文分词统计
- python中的jieba分词使用手册
- python中的jieba分词使用手册
- 使用python 的结巴(jieba)库进行中文分词
- 基于Python结巴分词(调用自定义词库已经去除停用词)
- 中文分词:python-jieba-安装及使用样例
- python结巴分词、jieba加载停用词表
- 使用Python+jieba和java+庖丁分词在Spark集群上进行中文分词统计
- [置顶] 【python 走进NLP】 NLP 使用jieba分词处理文本
- jieba 分词 centos 安装,python使用
- [python] 使用Jieba工具中文分词及文本聚类概念
- 使用jieba分词对中文文档进行分词|停用词去重
- python调用jieba(结巴)分词 加入自定义词典和去停用词功能
- 使用jieba进行数据预处理(分词,过滤停用词及标点,获取词频、关键词等)
- python调用jieba(结巴)分词 加入自定义词典和去停用词功能
- Python中文分词--jieba的基本使用
- Python中文分词_使用介绍(wordcloud+jieba)
- python-jieba分词的安装和使用
- python 去除停用词 结巴分词