morfologik.fsa.core
Class FSATraversalHelper

java.lang.Object
  extended by morfologik.fsa.core.FSATraversalHelper

public class FSATraversalHelper
extends java.lang.Object

This class implements some common match/ traverse/ find operations on a generic FSA.

Optimized implementations may be provided my specific versions of FSA, therefore objects of this class should be instantiated via FSA.getTraversalHelper().


Method Summary
 FSAFinalStatesIterator getAllSubsequences(FSA.Node node)
          Returns an Iterator of all subsequences available from the given node to all reachable final states.
 FSAMatch matchSequence(byte[] sequence, FSA.Node node)
          Finds a matching path in the dictionary for a given sequence of labels, starting from some internal dictionary's node.
 FSAMatch matchSequence(byte[] sequence, FSA fsa)
          Finds a matching path in the dictionary for a given sequence of labels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAllSubsequences

public FSAFinalStatesIterator getAllSubsequences(FSA.Node node)
Returns an Iterator of all subsequences available from the given node to all reachable final states.


matchSequence

public FSAMatch matchSequence(byte[] sequence,
                              FSA fsa)
Finds a matching path in the dictionary for a given sequence of labels. Several return values are possible:
  1. FSAMatch.EXACT_MATCH - The sequence ends exactly on the final node. A match has been found.
  2. FSAMatch.PREFIX_FOUND - The sequence ends on an intermediate automaton node. The sequence is therefore a prefix of at least one other sequence stored in the dictionary. The result Match will contain an index of the first character in the input sequence not present in the dictionary and a pointer to the FSA.Node where mismatch occurred.
  3. FSAMatch.PREMATURE_PATH_END_FOUND - Dictionary's path ends before the sequence. It means a prefix of the input sequence is stored in the dictionary. (i.e. an empty sequence is a prefix of all other sequences). The result Match will contain an index of the first character not present in the dictionary.
  4. FSAMatch.PREMATURE_WORD_END_FOUND - The input sequence ends on an intermediate automaton node. This is a special case of FSAMatch.PREFIX_FOUND. A Node where the mismatch (lack of input sequence's characters) occurred is returned in Match.


matchSequence

public FSAMatch matchSequence(byte[] sequence,
                              FSA.Node node)
Finds a matching path in the dictionary for a given sequence of labels, starting from some internal dictionary's node.

See Also:
matchSequence(byte [], FSA.Node)