Class AhoCorasickOptimized


  • public class AhoCorasickOptimized
    extends java.lang.Object
    TAKEN FROM: https://github.com/lagodiuk/aho-corasick-optimized/blob/master/src/main/java/com/lahodiuk/ahocorasick/AhoCorasickOptimized.java Implementation of the Aho-Corasick string matching algorithm, described in the paper "Efficient String Matching: An Aid to Bibliographic Search", written by Alfred V. Aho and Margaret J. Corasick, Bell Laboratories, 1975 This implementation takes into account the specificities of the HotSpot JVM, and supposed to be the Garbage Collector friendly. The automaton is based only on the primitive data types in order to avoid Autoboxing and Unboxing conversions.
    Author:
    of the implementation is Yurii Lahodiuk (yura.lagodiuk@gmail.com), 2017-11-11: Erik Faessler from the JULIE Lab added the method isEntryPrefix(String).
    • Constructor Detail

      • AhoCorasickOptimized

        public AhoCorasickOptimized​(java.lang.String... patterns)
      • AhoCorasickOptimized

        public AhoCorasickOptimized​(java.util.List<java.lang.String> patterns)
    • Method Detail

      • adjustFailureTransitionsSize

        public void adjustFailureTransitionsSize​(int actualStatesCount)
      • adjustOutputTableSize

        public void adjustOutputTableSize​(int actualStatesCount)
      • adjustTransitionsTableSize

        public void adjustTransitionsTableSize​(int actualStatesCount)
      • isEntryPrefix

        public final boolean isEntryPrefix​(java.lang.String text)
        Added by Erik Faessler, 2017-11-11: This method does not find dictionary entries in the given string but just checks if the given string is a strict prefix of at least one dictionary entry. That is, the method returns false for strings that are completely contained in the dictionary and not a prefix of another entry.
        Parameters:
        text -
        Returns:
      • generateGraphvizAutomatonRepresentation

        public java.lang.String generateGraphvizAutomatonRepresentation​(boolean displayEdgesToInitialState)