public class AhoCorasickDoubleArrayTrie<V> extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
AhoCorasickDoubleArrayTrie.Hit<V>
一个命中结果
|
static interface |
AhoCorasickDoubleArrayTrie.IHit<V>
命中一个模式串的处理方法
|
static interface |
AhoCorasickDoubleArrayTrie.IHitFull<V> |
| Modifier and Type | Field and Description |
|---|---|
protected int[] |
base
双数组之base
|
protected int[] |
check
双数组值check
|
protected int[] |
l
每个key的长度
|
protected int |
size
base 和 check 的大小
|
protected V[] |
v
保存value
|
| Constructor and Description |
|---|
AhoCorasickDoubleArrayTrie() |
AhoCorasickDoubleArrayTrie(TreeMap<String,V> dictionary)
由一个词典创建
|
| Modifier and Type | Method and Description |
|---|---|
void |
build(TreeMap<String,V> map)
由一个排序好的map创建
|
int |
exactMatchSearch(String key)
精确匹配
|
V |
get(int index)
从值数组中提取下标为index的值
注意为了效率,此处不进行参数校验 |
V |
get(String key)
获取值
|
boolean |
load(ByteArray byteArray,
V[] value)
载入
|
void |
load(ObjectInputStream in,
V[] value)
载入
|
void |
parseText(char[] text,
AhoCorasickDoubleArrayTrie.IHit<V> processor)
处理文本
|
void |
parseText(char[] text,
AhoCorasickDoubleArrayTrie.IHitFull<V> processor)
处理文本
|
List<AhoCorasickDoubleArrayTrie.Hit<V>> |
parseText(String text)
匹配母文本
|
void |
parseText(String text,
AhoCorasickDoubleArrayTrie.IHit<V> processor)
处理文本
|
void |
save(DataOutputStream out)
持久化
|
void |
save(ObjectOutputStream out)
持久化
|
boolean |
set(String key,
V value)
更新某个键对应的值
|
int |
size()
大小,即包含多少个模式串
|
protected int |
transition(int current,
char c)
转移状态
|
protected int |
transitionWithRoot(int nodePos,
char c)
c转移,如果是根节点则返回自己
|
protected int[] check
protected int[] base
protected V[] v
protected int[] l
protected int size
public List<AhoCorasickDoubleArrayTrie.Hit<V>> parseText(String text)
text - 一些文本public void parseText(String text, AhoCorasickDoubleArrayTrie.IHit<V> processor)
text - 文本processor - 处理器public void parseText(char[] text,
AhoCorasickDoubleArrayTrie.IHit<V> processor)
text - processor - public void parseText(char[] text,
AhoCorasickDoubleArrayTrie.IHitFull<V> processor)
text - processor - public void save(DataOutputStream out) throws Exception
out - 一个DataOutputStreamException - 可能的IO异常等public void save(ObjectOutputStream out) throws IOException
out - 一个ObjectOutputStreamIOException - 可能的IO异常public void load(ObjectInputStream in, V[] value) throws IOException, ClassNotFoundException
in - 一个ObjectInputStreamvalue - 值(持久化的时候并没有持久化值,现在需要额外提供)IOExceptionClassNotFoundExceptionpublic boolean load(ByteArray byteArray, V[] value)
byteArray - 一个字节数组value - 值数组public boolean set(String key, V value)
key - 键value - 值public V get(int index)
index - 下标protected int transition(int current,
char c)
current - c - protected int transitionWithRoot(int nodePos,
char c)
nodePos - c - public int exactMatchSearch(String key)
key - 键public int size()
Copyright © 2014–2021 码农场. All rights reserved.