Class MultiTrie

  • Direct Known Subclasses:
    MultiTrie2

    public class MultiTrie
    extends Trie
    The MultiTrie is a Trie of Tries. It stores words and their associated patch commands. The MultiTrie handles patch commands individually (each command by itself).
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.egothor.stemmer.Trie

        Trie.StrEnum
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int BY  
      (package private) char EOM  
      (package private) java.lang.String EOM_NODE  
      (package private) java.util.List<Trie> tries  
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiTrie​(boolean forward)
      Constructor for the MultiTrie object
      MultiTrie​(java.io.DataInput is)
      Constructor for the MultiTrie object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.CharSequence key, java.lang.CharSequence cmd)
      Add an element to this structure consisting of the given key and patch command.
      java.lang.CharSequence getFully​(java.lang.CharSequence key)
      Return the element that is stored in a cell associated with the given key.
      java.lang.CharSequence getLastOnPath​(java.lang.CharSequence key)
      Return the element that is stored as last on a path belonging to the given key.
      void printInfo​(java.io.PrintStream out, java.lang.CharSequence prefix)
      Print the given prefix and the position(s) in the Trie where it appears.
      Trie reduce​(Reduce by)
      Remove empty rows from the given Trie and return the newly reduced Trie.
      void store​(java.io.DataOutput os)
      Write this data structure to the given output stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiTrie

        public MultiTrie​(java.io.DataInput is)
                  throws java.io.IOException
        Constructor for the MultiTrie object.
        Parameters:
        is - the input stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • MultiTrie

        public MultiTrie​(boolean forward)
        Constructor for the MultiTrie object
        Parameters:
        forward - set to true if the elements should be read left to right
    • Method Detail

      • getFully

        public java.lang.CharSequence getFully​(java.lang.CharSequence key)
        Return the element that is stored in a cell associated with the given key.
        Overrides:
        getFully in class Trie
        Parameters:
        key - the key to the cell holding the desired element
        Returns:
        the element
      • getLastOnPath

        public java.lang.CharSequence getLastOnPath​(java.lang.CharSequence key)
        Return the element that is stored as last on a path belonging to the given key.
        Overrides:
        getLastOnPath in class Trie
        Parameters:
        key - the key associated with the desired element
        Returns:
        the element that is stored as last on a path
      • store

        public void store​(java.io.DataOutput os)
                   throws java.io.IOException
        Write this data structure to the given output stream.
        Overrides:
        store in class Trie
        Parameters:
        os - the output stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • add

        public void add​(java.lang.CharSequence key,
                        java.lang.CharSequence cmd)
        Add an element to this structure consisting of the given key and patch command.

        This method will return without executing if the cmd parameter's length is 0.

        Overrides:
        add in class Trie
        Parameters:
        key - the key
        cmd - the patch command
      • reduce

        public Trie reduce​(Reduce by)
        Remove empty rows from the given Trie and return the newly reduced Trie.
        Overrides:
        reduce in class Trie
        Parameters:
        by - the Trie to reduce
        Returns:
        the newly reduced Trie
      • printInfo

        public void printInfo​(java.io.PrintStream out,
                              java.lang.CharSequence prefix)
        Print the given prefix and the position(s) in the Trie where it appears.
        Overrides:
        printInfo in class Trie
        Parameters:
        prefix - the desired prefix