用cython实现cedar的python绑定

pycedar的Python项目详细描述


松柏

versionpythonlicense

使用cython的python绑定cedar(高效可更新双数组trie的实现)

cedarhttp://www.tkl.iis.u-tokyo.ac.jp/~ynaga/cedar/

的官方URL

安装

从pypi release安装

$ pip install --user pycedar

从github master安装

$ pip install --user https://github.com/akivajp/pycedar/archive/master.zip

用法

使用基于双数组trie

的类似python的dict类
>>>importpycedar>>>d=pycedar.dict()>>>print(len(d))0>>>print(bool(d))False>>>print(list(d))[]>>>d['nineteen']=19>>>d.set('twenty',20)>>>d['twenty one']=21>>>d['twenty two']=22>>>d['twenty three']=23>>>d['twenty four']=24>>>print(len(d))6>>>print(bool(d))True>>>print(list(d))['nineteen','twenty','twenty four','twenty one','twenty three','twenty two']>>>print(list(d.keys()))['nineteen','twenty','twenty four','twenty one','twenty three','twenty two']>>>print(list(d.values()))[19,20,24,21,23,22]>>>print(list(d.items()))[('nineteen',19),('twenty',20),('twenty four',24),('twenty one',21),('twenty three',23),('twenty two',22)]>>>print(d['twenty four'])24>>>print('twenty four'ind)True>>>deld['twenty four']>>>print('twenty four'ind)False>>>try:>>>print(d['twenty four'])>>>exceptExceptionase:>>>print(repr(e))KeyError('twenty four',)>>>print(d.get('twenty three'))23>>>print(d.get('twenty four'))-1>>>print(d.get('twenty four',None))None>>>print(list(d.find('')))[('nineteen',19),('twenty',20),('twenty one',21),('twenty three',23),('twenty two',22)]>>>print(list(d.find('tw')))[('twenty',20),('twenty one',21),('twenty three',23),('twenty two',22)]>>>print(list(d.find('twenty t')))[('twenty three',23),('twenty two',22)]>>>print(list(d.find_keys('twenty')))['twenty','twenty one','twenty three','twenty two']>>>print(list(d.find_values('twenty')))[20,21,23,22]>>>n=d.get_node('twenty')>>>print(n)'twenty'>>>print(repr(n))pycedar.node(trie=<pycedar.str_trieobjectat0x7fffe2394b80>,id=260,length=6,root=0)>>>print(n.key())twenty>>>print(n.value())20>>>print([n.key()forninn.find_nodes(' t')])[' three',' two']>>>n=d.get_node('twenty ')>>>print(n)None>>>d.save('test.dat')>>>d2=pycedar.dict()>>>print(d2.setdefault('eighteen',18))18>>>print(list(d2.items()))[('eighteen',18)]>>>d2.load('test.dat')>>>print(list(d2.items()))[('nineteen',19),('twenty',20),('twenty one',21),('twenty three',23),('twenty two',22)]>>>print(d2.setdefault('eighteen',18))18>>>print(list(d2.items()))[('eighteen',18),('nineteen',19),('twenty',20),('twenty one',21),('twenty three',23),('twenty two',22)]

使用更原始的数据结构

(待定)

待办事项

  • 课程文件:
    • 基准线
    • str_trie
    • 字节重试
    • Unicode_-trie
    • 节点

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android同步不同页面上的按钮   java评测每个类收集的垃圾对象实例数   java(Spring MVC+Hibernate 4+Test 4)自动连线DAO返回NULL   java Android编辑文本和虚拟键盘   java Selenium与BrowserMobProxy   JAVAlang.NoClassDefFoundError:com/sun/jersey/spi/inject/Errors$关闭原因?   java为什么在我成功登录后仍然会出现“不正确的帐户或密码或用户类型”   安卓应用程序在重新启动java时崩溃。网UnknownHostException:无法解析主机   多线程在Java中同步共享静态对象的正确方法是什么?   未调用自定义注释的java类验证(约束类)   java如何将指定目录的存档文件放入所需位置?   java如何识别Selenium中的每个编辑文本字段,如果它们的Xpath都相同   使用gwtmockito/mockito的java简单单选按钮单元测试?