autocomplete-redis
============
autocomplete-redis is a quora like automatic autocompletion based on redis.
Installation
---------
* install pip (if you haven't yet) `easy_install pip`
* install pymmseg (support for Chinese Characters): `pip install pymmseg`
* install autocomplete-redis: `pip install -e git+https://github.com/fengli/autocomplete-redis.git#egg=autocomplete-dev`
Quick start
----------
* Assume you have few items to index.
```python
items=[{"uid":'1', "score":9, "term": u"hello world, that's great"},
{"uid":'2', "score":10, "term": u"what the hell or yell"},
{"uid":'3', "score":8.5, "term":u"World is like a box of chocolate"},
]
```
The code for build the index and search is simple:
```python
from autocomplete import Autocomplete
#build index
au = Autocomplete ("scope")
for item in items:
au.add_item (item)
#search
restuls = au.search_query (u'hel')
print results
[{'term': 'what the hell or yell', 'score': 10, 'uid': '2'}, {'term': "hello world, that's great", 'score': 9, 'uid': '1'}]
```
API
---------------
* Convention: the item you pass to `autocomplete` should have at least `"uid"` and `"term"`, `"score"` is optional, but it's important if you want to return based on ranking. And you could have other fields as you like.
```python
{"uid":'1', "score":9, "term": u"hello world, that's great", 'meta':"1992"}
```
* `uid`: the unique identifier for your item
* `score`: the returned items sorted by this value.
* `term`: the string to be indexed.
* `def __init__ (self, scope, redisaddr="localhost", limits=5, cached=True)`
* scope: Scope allows you to index multiple independent indexes.
* redisaddr: your redis address
* limits: How many results you want to get.
* cached: Cache multiple keys combination?
* `def del_index (self)`
Delete all the indexes. Warning: all data will be deleted.
* `def add_item (self,item)`
Add item to index.
* `def del_item (self,item)`
Delete item from index.
* `def update_item (self, item)`
Update item indexed with item['uid'] with the new version.
* `def search_query (self,prefix)`
Search in database for all items that `item['term']` included `PREFIX`
Bring to you by:
----------------
* http://readpi.com
没有合适的资源?快使用搜索试试~ 我知道了~
autocomplete-redis 是一个基于 redis 的类似 quora 的自动完成功能 .zip
共11个文件
py:5个
txt:2个
gitignore:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 37 浏览量
2024-12-03
08:49:47
上传
评论
收藏 6KB ZIP 举报
温馨提示
autocomplete-redis 是一个基于 redis 的类似 quora 的自动完成功能。自动完成 redisautocomplete-redis 是一个基于 redis 的类似 quora 的自动完成功能。安装安装 pip(如果还没有)easy_install pip安装pymmseg(支持中文)pip install pymmseg安装autocomplete-redispip install -e git+https://github.com/fengli/autocomplete-redis.git#egg=autocomplete-dev快速启动假设您只有少数项目需要索引。items=[{"uid":'1', "score":9, "term": u"hello world, that's great"}, {"uid":'2', "score":10, "term": u"what the hell or yell"}, {"uid":'3', "score":8.5, "term":u"World is l
资源推荐
资源详情
资源评论
收起资源包目录
autocomplete-redis 是一个基于 redis 的类似 quora 的自动完成功能。.zip (11个子文件)
setup.py 772B
标签.txt 5B
MIT.LICENSE 1KB
autocomplete
utils.py 672B
__init__.py 44B
index.py 3KB
资源内容.txt 667B
test
input.json 197B
test.py 2KB
.gitignore 232B
README.md 2KB
共 11 条
- 1
资源评论
赵闪闪168
- 粉丝: 1658
- 资源: 5391
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- wasm插件源码-jpg图片转pdf格式,结合domtoimage,实现前端转pdf
- base(1).apk.1
- K618977005_2012-12-6_beforeP_000.txt.PRM
- 秋招信息获取与处理基础教程
- 程序员面试笔试面经技巧基础教程
- Python实例-21个自动办公源码-数据处理技术+Excel+自动化脚本+资源管理
- 全球前8GDP数据图(python动态柱状图)
- 汽车检测7-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 检测高压线电线-YOLO(v5至v9)、COCO、Darknet、VOC数据集合集.rar
- 检测行路中的人脸-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、VOC数据集合集.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功