浙江省高等学校教师教育理论培训

微信搜索“教师资格证岗前培训”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

http://jedp.posterous.com/auto-complete-with-redis-and-python

Auto-complete with Redis and Python

Salvatore Sanfilippo is always sharing cool things to do with redis. As with all things redis, it never ceases to amaze how much you can do with so little code. Thanks, Salvatore.

He posted this gist which implements an autocompleter in redis using ordered sets to represent trie data.

j4mie promptly translated the same into Python.

I’ve branched j4mie’s version and made it work for multi-word phrases. There’s a github gist here.

In his comments, j4mie extends the invitation to make his version more Pythonic. I’ve tried to do so in my fork. I hope I haven’t damaged too much in the process. I also put a command-line wrapper around it, so you can run it from the shell and play with redis interactively.

posted on 2011-12-11 11:30  lexus  阅读(368)  评论(0编辑  收藏  举报