最近javaeye的python板块实在是太不活跃了,发一个有意思的开源程序,给大家玩玩,这个程序代码是后缀树,一般用于autoComplete,还不知到的同学赶紧来看看吧 :)
开源地址:https://github.com/edisonlz/suffixTree_ch
o SuffixTree.SuffixTree -- The suffix tree structure. This is a
thin wrapper around strmat's stree data structure. This isn't a
complete wrapper yet; I need to find some time to complete this.
The wrapper appears to be good enough for simple stuff.
Methods of SuffixTree:
o SuffixTree(alphabet=STREE_ASCII)
Construct a new SuffixTree. By default, the alphabet
used by the SuffixTree is ASCII. Other choices include
STREE_DNA, STREE_RNA, and STREE_PROTEIN.
o add(string, id)
Adds a string to the suffix tree with an id.
o root()
Returns the root() SuffixNode of the tree.
o num_nodes():
Returns the total number of nodes held in the tree.
o match(string)
Given a string, traverse the suffix tree and return a
3-tuple (match_length, suffix_node, endpos)
o SuffixTree.SuffixNode (I need to fix the documentation here)
Methods of
num_children()
find_child(char ch)
children()
next()
parent()
suffix_link()
edgelen()
edgestr()
getch()
labellen()
labelstr()
ident()
num_leaves()
leaf(int leafnum)
o SuffixTree.SubstringDict -- An application of suffix trees toward
substring matching. An example might help:
>>> #coding=utf-8
>>> from SuffixTree import SubstringDict
>>> sd = SubstringDict()
>>> sd.__setitem__("我是python程序员",1)
>>> sd.__setitem__("我是ruby程序员",2)
>>> sd.__setitem__("我是javascript程序员",3)
>>> sd.__setitem__("我是android程序员",4)
>>> sd.__setitem__("我还是DBA",4)
>>> print sd[“我是”]
>>> print sd[“我还是”]
>>> sd = SubstringDict()
>>> sd["我是python程序员"] = 1
>>> sd["我是ruby程序员"] = 2
>>> sd["我是javascript程序员"] = 3
>>> sd["我是android程序员"] = 4
>>> sd["我还是DBA"] = 5
>>> print sd[“我还是”]
SubstringDict provides a mapping that allows for substrings of
keys. The keys do need to be strings though.
支持中文的方式是使用 base64,数据量回增加30%,对性能回有些损耗,但是,损耗不大
64 位 安装 :
ARCHFLAGS="-arch i386 -arch x86_64" python setup.py installPython SuffixTree (后缀树)中文
分享到:
相关推荐
资源分类:Python库 所属语言:Python 资源全名:wagtail_autocomplete-0.1.1-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
python库。 资源全名:autocomplete_trie-0.1.tar.gz
Autocomplete
jquery-autocomplete搜索框自动完成的中文文档,上手快,轻便,功能强大
我们开始研究玩具项目,以了解简单的LSTM模型可以很好地自动完成python代码。 通过在大多数文件中节省30%以上的击键,而在某些文件中节省近50%的击键,可以提供相当不错的结果。 我们通过做出一个(最佳)预测...
这个自动补全是autocomplete 优化的支持中文,数据库,图片+文字等等
autocomplete-plus-python-jedi软件包-基于Jedi的python Autocomplete Plus提供程序该软件包已被废弃,取而代之的是 !
jquery-autocomplete 可用
jquery.autocomplete.js 、jquery.autocomplete.css
资源来自pypi官网。 资源全名:labml_python_autocomplete-0.0.7.tar.gz
开始使用AutoComplete的时候就遇到了不支持中文的问题,网上写了一堆修改的方法,后来才发现,其实什么都不用该,只是在编码上没有控制好才出现了乱码。注意使用UTF-8的编码,因为JavaScript在传递中文参数的时候...
在autocomplete-python的安装屏幕中提供了更多信息。 有关发行说明,请参见。 Jedi驱动的发行说明如下。 有关使用Kite引擎的更多信息,请参见 。 该软件包需要的最新版本: pip install jedi 演示版 特征 适用...
用java实现autocomplete搜索功能,可以获取除输入框的其它动态参数,后台字符串拼接,返回json数据,格式如下: { query:'Li', suggestions:['Liberia', 'Libyan Arab Jamahiriya', 'Liechtenstein', 'Lithuania'...
asp.net仿百度的自动完成(autoComplete) 使用Jquery autocomplete.js插件来完成自动完成,可以从数据库中读取数据 ajax异步显示数据!云计算QQ研究群:96191559
Jquery autocomplete插件使用
资源分类:Python库 所属语言:Python 资源全名:fast-autocomplete-0.1.5.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
jquery.autocomplete-tree.js ======================= 带有树/分层导航的简单 jQuery 自动完成 鲍尔 bower install -S jquery.autocomplete-tree 新产品管理 npm install --save jquery.autocomplete-tree 样本...
jQuery Autocomplete自动完成demo,使用的是jquery.autocomplete.js 2017的版本。
利用autocomplete实现输入某个汉字或者某个字母时,自动提示输入内容