DoubleArrayTrie(DAT)支持用C++实现Python的前缀搜索和精确搜索和多模式匹配
pydat的Python项目详细描述
##双数组
doubleArrayTrie(DAT)支持前缀搜索&;精确搜索&;C++实现的Python多模式匹配
###有什么不同
现在支持贪婪搜索:
函数search只返回最长的子序列(贪婪搜索)
函数
word: she sher shers he to_search: shers
search: {‘entities’: [{‘begin’: 0, ‘end’: 5, ‘entity’: ‘shers’}]}
maximum_search: {‘entities’: [{‘begin’: 0, ‘end’: 3, ‘entity’: ‘she’}, {‘begin’: 0, ‘end’: 4, ‘entity’: ‘sher’}, {‘begin’: 0, ‘end’: 5, ‘entity’: ‘shers’}, {‘begin’: 1, ‘end’: 3, ‘entity’: ‘he’}]}
α+C++
#include “double_array_trie.h”
DoubleArrayTrie dat; // load from file dat.load_file(“test.txt”) // or add word dat.add_word(“he”) dat.add_word(“she”) // make base & check dat.make() // greedy_search vector<string> index_s = dat.search(“ushers”) // maximum_search vector<string> index_s = dat.maximum_search(“ushers”)
###Python
# install pip install pydat
# use dat = pydat.Dat() dat.load_file(“test.txt”) dat.add_word(“he”) dat.make() # search dat.search(“ushers”) # greedy_search dat.maximum_search(“ushers”)
###关于数据 啊![](https://linux.thai.net/~thep/datrie/double.gif)
定义 检查[base[s]+c]=s 基[s]+c=t
引用:[双数组trie的实现](https://linux.thai.net/~thep/datrie/datrie.html#Double)
###更新日志
####2018年9月19日 -优化算法
####2018年8月29日 -支持贪婪搜索
####2018年8月8日 -支持python3