python中文分词库结巴使用示例
2017-01-17 21:09
447 查看
结巴是开源库,中文分词,使用简单,可以添加用户字典
https://github.com/fxsjy/jieba
使用示例
https://github.com/fxsjy/jieba
使用示例
from xml.etree import ElementTree import re import jieba import jieba.posseg as pseg jieba.load_userdict("dict.txt") #读root root = ElementTree.parse(r"爬虫.xml") persons = root.findall("person") #写root root = ElementTree.Element("documents") for person in persons: name = person.find("name") dis = person.find("dis") #s删除作品名 text = re.sub(r'《.*》', '', str(dis.text)) words = pseg.cut(text) try: for w in words: if len(w.word) == 1: continue #nr为人名标志 if str(w.flag) == "nr": print(w.word) except: pass
相关文章推荐
- Python结巴中文分词工具使用过程中遇到的问题及解决方法
- Python使用中文正则表达式匹配指定中文字符串的方法示例
- 结巴中文分词使用学习(python)
- 使用python 的结巴(jieba)库进行中文分词
- python中文分词,使用结巴分词对python进行分词
- Python 中文分词工具 ——结巴分词的使用方法总结
- PYTHON 结巴中文分词工具的基础使用
- python使用jieba实现中文分词去停用词方法示例
- python使用reportlab画图示例(含中文汉字)
- python中文分词,使用结巴分词对python进行分词(实例讲解)
- python中文分词,使用结巴分词对python进行分词
- python使用reportlab画图示例(含中文汉字)
- Python 中文分词工具 ——结巴分词的使用方法总结
- 结巴分词 0.14 版发布,Python 中文分词库
- python中使用中文问题
- 使用minidom来处理XML的示例(Python 学习)(转载)
- zz使用 Python 分离中文与英文的混合字串
- Python中使用中文的方法
- Python中使用中文的方法
- 使用python查询中文汉字的Unicode