public class AhoCorasickDoubleArrayTrie<V> extends Object implements Serializable
| 限定符和类型 | 类和说明 |
|---|---|
static class |
AhoCorasickDoubleArrayTrie.Hit<V>
A result output
|
static interface |
AhoCorasickDoubleArrayTrie.IHit<V>
Processor handles the output when hit a keyword
|
static interface |
AhoCorasickDoubleArrayTrie.IHitCancellable<V>
Callback that allows to cancel the search process.
|
static interface |
AhoCorasickDoubleArrayTrie.IHitFull<V>
Processor handles the output when hit a keyword, with more detail
|
| 限定符和类型 | 字段和说明 |
|---|---|
protected int[] |
base
base array of the Double Array Trie structure
|
protected int[] |
check
check array of the Double Array Trie structure
|
protected int[] |
fail
fail table of the Aho Corasick automata
|
protected int[] |
l
the length of every key
|
protected int[][] |
output
output table of the Aho Corasick automata
|
protected int |
size
the size of base and check array
|
protected V[] |
v
outer value array
|
| 构造器和说明 |
|---|
AhoCorasickDoubleArrayTrie() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
build(Map<String,V> map)
Build a AhoCorasickDoubleArrayTrie from a map
|
int |
exactMatchSearch(String key)
match exactly by a key
|
AhoCorasickDoubleArrayTrie.Hit<V> |
findFirst(String text)
Search first match in string
|
V |
get(int index)
Pick the value by index in value array
Notice that to be more efficiently, this method DO NOT check the parameter |
V |
get(String key)
Get value by a String key, just like a map.get() method
|
void |
load(ObjectInputStream in)
Load
|
boolean |
matches(String text)
Checks that string contains at least one substring
|
void |
parseText(char[] text,
AhoCorasickDoubleArrayTrie.IHit<V> processor)
Parse text
|
void |
parseText(char[] text,
AhoCorasickDoubleArrayTrie.IHitFull<V> processor)
Parse text
|
List<AhoCorasickDoubleArrayTrie.Hit<V>> |
parseText(String text)
Parse text
|
void |
parseText(String text,
AhoCorasickDoubleArrayTrie.IHit<V> processor)
Parse text
|
void |
parseText(String text,
AhoCorasickDoubleArrayTrie.IHitCancellable<V> processor)
Parse text
|
void |
save(ObjectOutputStream out)
Save
|
int |
size()
Get the size of the keywords
|
protected int |
transition(int current,
char c)
transition of a state
|
protected int |
transitionWithRoot(int nodePos,
char c)
transition of a state, if the state is root and it failed, then returns the root
|
protected int[] check
protected int[] base
protected int[] fail
protected int[][] output
protected V[] v
protected int[] l
protected int size
public List<AhoCorasickDoubleArrayTrie.Hit<V>> parseText(String text)
text - The textpublic void parseText(String text, AhoCorasickDoubleArrayTrie.IHit<V> processor)
text - The textprocessor - A processor which handles the outputpublic void parseText(String text, AhoCorasickDoubleArrayTrie.IHitCancellable<V> processor)
text - The textprocessor - A processor which handles the outputpublic void parseText(char[] text,
AhoCorasickDoubleArrayTrie.IHit<V> processor)
text - The textprocessor - A processor which handles the outputpublic void parseText(char[] text,
AhoCorasickDoubleArrayTrie.IHitFull<V> processor)
text - The textprocessor - A processor which handles the outputpublic boolean matches(String text)
text - source text to checktrue if string contains at least one substringpublic AhoCorasickDoubleArrayTrie.Hit<V> findFirst(String text)
text - source text to checknull if there are no matchespublic void save(ObjectOutputStream out) throws IOException
out - An ObjectOutputStream objectIOException - Some IOExceptionpublic void load(ObjectInputStream in) throws IOException, ClassNotFoundException
in - An ObjectInputStream objectIOExceptionClassNotFoundExceptionpublic V get(String key)
key - The keypublic V get(int index)
index - The indexprotected int transition(int current,
char c)
current - c - protected int transitionWithRoot(int nodePos,
char c)
nodePos - c - public void build(Map<String,V> map)
map - a map containing key-value pairspublic int exactMatchSearch(String key)
key - the keypublic int size()
Copyright © 2014–2018 码农场. All rights reserved.