好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

使用redis实现trie结构

使用redis实现trie结构

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.

查看更多关于使用redis实现trie结构的详细内容...

  阅读:62次