类 AhoCorasickDoubleArrayTrie<V>

  • 所有已实现的接口:
    java.io.Serializable

    public class AhoCorasickDoubleArrayTrie<V>
    extends java.lang.Object
    implements java.io.Serializable
    An implementation of Aho Corasick algorithm based on Double Array Trie
    另请参阅:
    序列化表格
    • 字段详细资料

      • check

        protected int[] check
        check array of the Double Array Trie structure
      • base

        protected int[] base
        base array of the Double Array Trie structure
      • fail

        protected int[] fail
        fail table of the Aho Corasick automata
      • output

        protected int[][] output
        output table of the Aho Corasick automata
      • v

        protected V[] v
        outer value array
      • l

        protected int[] l
        the length of every key
      • size

        protected int size
        the size of base and check array
    • 构造器详细资料

      • AhoCorasickDoubleArrayTrie

        public AhoCorasickDoubleArrayTrie()
    • 方法详细资料

      • parseText

        public java.util.List<AhoCorasickDoubleArrayTrie.Hit<V>> parseText​(java.lang.CharSequence text)
        Parse text
        参数:
        text - The text
        返回:
        a list of outputs
      • parseText

        public void parseText​(java.lang.CharSequence text,
                              AhoCorasickDoubleArrayTrie.IHit<V> processor)
        Parse text
        参数:
        text - The text
        processor - A processor which handles the output
      • parseText

        public void parseText​(char[] text,
                              AhoCorasickDoubleArrayTrie.IHit<V> processor)
        Parse text
        参数:
        text - The text
        processor - A processor which handles the output
      • parseText

        public void parseText​(char[] text,
                              AhoCorasickDoubleArrayTrie.IHitFull<V> processor)
        Parse text
        参数:
        text - The text
        processor - A processor which handles the output
      • matches

        public boolean matches​(java.lang.String text)
        Checks that string contains at least one substring
        参数:
        text - source text to check
        返回:
        true if string contains at least one substring
      • findFirst

        public AhoCorasickDoubleArrayTrie.Hit<V> findFirst​(java.lang.String text)
        Search first match in string
        参数:
        text - source text to check
        返回:
        first match or null if there are no matches
      • save

        public void save​(java.io.ObjectOutputStream out)
                  throws java.io.IOException
        Save
        参数:
        out - An ObjectOutputStream object
        抛出:
        java.io.IOException - Some IOException
      • load

        public void load​(java.io.ObjectInputStream in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
        Load data from [ObjectInputStream]
        参数:
        in - An ObjectInputStream object
        抛出:
        java.io.IOException - If can't read the file from path
        java.lang.ClassNotFoundException - If the class doesn't exist or matched
      • get

        public V get​(java.lang.String key)
        Get value by a String key, just like a map.get() method
        参数:
        key - The key
        返回:
        value if exist otherwise it return null
      • set

        public boolean set​(java.lang.String key,
                           V value)
        Update a value corresponding to a key
        参数:
        key - the key
        value - the value
        返回:
        successful or not(failure if there is no key)
      • get

        public 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
        参数:
        index - The index
        返回:
        The value
      • transition

        protected int transition​(int current,
                                 char c)
        transition of a state
        参数:
        current - current
        c - c
        返回:
        int
      • transitionWithRoot

        protected int transitionWithRoot​(int nodePos,
                                         char c)
        transition of a state, if the state is root and it failed, then returns the root
        参数:
        nodePos - nodePos
        c - c
        返回:
        int
      • build

        public void build​(java.util.Map<java.lang.String,​V> map)
        Build a AhoCorasickDoubleArrayTrie from a map
        参数:
        map - a map containing key-value pairs
      • exactMatchSearch

        public int exactMatchSearch​(java.lang.String key)
        match exactly by a key
        参数:
        key - the key
        返回:
        the index of the key, you can use it as a perfect hash function
      • size

        public int size()
        返回:
        the size of the keywords