python 搜索引擎Whoosh中文文档和代码 以及jieba的使用
注意, 数据库的表最好别有下划线
中文文档链接:
https://mr-zhao.gitbooks.io/whoosh/content/%E5%A6%82%E4%BD%95%E7%B4%A2%E5%BC%95%E6%96%87%E6%A1%A3.html https://mr-zhao.gitbooks.io/whoosh/content/如何索引文档.html?q=
代码:
https://github.com/renfanzi/myWhoosh
jieba的使用案例 =====》版本3.5
from jieba.analyse import ChineseAnalyzer
import jieba analyzer = ChineseAnalyzer()
a = analyzer("我的好朋友是李明;我爱北京天安门;IBM和Microsoft; I have a dream. this is intetesting and interested me a lot") # 这样的是只过滤词,更加简洁,更方便
print([i.text for i in a]) seg_list = jieba.cut("我的好朋友是李明;我爱北京天安门;IBM和Microsoft; I have a dream. this is intetesting and interested me a lot",cut_all=False) # cut_all = False 就是连标点等都不过滤,完全切割cut
seg_list1 = jieba.cut("IBM和Microsoft; I have a dream. this is intetesting and interested me a lot",cut_all=True) # cut_all = False 就是过滤标点等
print([i for i in seg_list if i])
print([i for i in seg_list1 if i])
# 注意,其实也可以用join来拼接
结果:
Building prefix dict from the default dictionary ...
Loading model from cache /tmp/jieba.cache
Loading model cost 0.865 seconds.
Prefix dict has been built succesfully.
['我', '好', '朋友', '是', '李明', '我', '爱', '北京', '天安', '天安门', 'ibm', 'microsoft', 'dream', 'intetest', 'interest', 'me', 'lot']
['我', '的', '好', '朋友', '是', '李明', ';', '我', '爱', '北京', '天安门', ';', 'IBM', '和', 'Microsoft', ';', ' ', 'I', ' ', 'have', ' ', 'a', ' ', 'dream', '.', ' ', 'this', ' ', 'is', ' ', 'intetesting', ' ', 'and', ' ', 'interested', ' ', 'me', ' ', 'a', ' ', 'lot']
['IBM', '和', 'Microsoft', 'I', 'have', 'a', 'dream', 'this', 'is', 'intetesting', 'and', 'interested', 'me', 'a', 'lot']
python 搜索引擎Whoosh中文文档和代码 以及jieba的使用的更多相关文章
- 推荐Python、Django中文文档地址
协作翻译网:http://usyiyi.cn/ 老牌的Python中文社区:http://woodpecker.org.cn/ The Django Book2.0中文版:http://djangob ...
- 学习Python 新去处:Python 官方中文文档
Python 作为世界上最好用的语言,官方支持的文档一直没有中文.小伙伴们已经习惯了原汁原味的英文文档,但如果有官方中文文档,那么查阅或理解速度都会大大提升.本文将介绍隐藏在 Python 官网的中文 ...
- python使用jieba实现中文文档分词和去停用词
分词工具的选择: 现在对于中文分词,分词工具有很多种,比如说:jieba分词.thulac.SnowNLP等.在这篇文档中,笔者使用的jieba分词,并且基于python3环境,选择jieba分词的理 ...
- jQuery 3.1 API中文文档
jQuery 3.1 API中文文档 一.核心 1.1 核心函数 jQuery([selector,[context]]) 接收一个包含 CSS 选择器的字符串,然后用这个字符串去匹配一组元素. jQ ...
- Django 1.10中文文档—第一个Django应用Part1
在本教程中,我们将引导您完成一个投票应用程序的创建,它包含下面两部分: 一个可以进行投票和查看结果的公开站点: 一个可以进行增删改查的后台admin管理界面: 我们假设你已经安装了Django.您可以 ...
- Visual Studio Code中文文档
Visual Studio Code中文文档 Visual Studio Code是一个轻量级但是十分强大的源代码编辑器,重要的是它在Windows, OS X 和Linux操作系统的桌面上均可运行. ...
- Django 1.10中文文档-第一个应用Part2-模型和管理站点
本教程继续Part1.我们将设置数据库,创建您的第一个模型,并快速介绍Django的自动生成的管理网站. 数据库设置 现在,编辑mysite/settings.py.它是一个用模块级别变量表示Djan ...
- Django 1.10中文文档-执行查询
Django 1.10中文文档: https://github.com/jhao104/django-chinese-doc 只要创建好 数据模型, Django 会自动为生成一套数据库抽象的API, ...
- Keras官方中文文档:Keras安装和配置指南(Windows)
这里需要说明一下,笔者不建议在Windows环境下进行深度学习的研究,一方面是因为Windows所对应的框架搭建的依赖过多,社区设定不完全:另一方面,Linux系统下对显卡支持.内存释放以及存储空间调 ...
随机推荐
- error occurred during the file system check
fsck -c 然后一路:y reboot 问题解决!!!
- prometheus-dashboard-to-grafana
https://prometheus.io/docs/visualization/grafana/ https://www.digitalocean.com/community/tutorials/h ...
- JVM profiler tools
http://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html https://codeascraft.com/2015/05/12 ...
- ashx页面返回json字符串|jQuery 的ajax处理请求的纠结问题
纠结,整了半天的jquery的ajax请求数据. 遇到的问题: 1 ajax方法一直进入error方法里,进入到请求的.ashx页面.这个问题,我未找到是什么原因.反正我使用了一下的代码,就好了. $ ...
- 每日英语:How the College Bubble Will Pop
The American political class has long held that higher education is vital to individual and national ...
- 每日英语:How Often Do Gamblers Really Win?
The casino billboards lining America's roadways tantalize with the lure of riches. 'Easy Street. It' ...
- 【AD】实用组策略/脚本集合 (重大更新20160627)
文章原始出处 http://blog.51cto.com/xifanliang/1793576 http://bbs.51cto.com/thread-1170777-1.html 作者:xifaln ...
- Android开发(十)——像素单位dp、px、pt、sp的比较
dp(dip): device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA.HVGA和QVGA 推荐使用这个,不依赖 ...
- mybatis中的.xml文件总结——mybatis的动态sql
resultMap resultType可以指定pojo将查询结果映射为pojo,但需要pojo的属性名和sql查询的列名一致方可映射成功. 如果sql查询字段名和pojo的属性名不一致,可以通过re ...
- C++连接Mysql数据库操作
参考文章 http://www.cnblogs.com/justinzhang/archive/2011/09/23/2185963.html 写的很详细 http://blog.csdn.net/j ...