morfologik.fsa
Class FSATraversalHelper

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

public final class FSATraversalHelper
extends java.lang.Object

This class implements some common matching and scanning 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
 java.util.Iterator<java.nio.ByteBuffer> getAllSubsequences(int node)
          Returns an Iterator of all subsequences available from the given node to all reachable final states.
 FSAFinalStatesIterator getFinalStatesIterator()
          Returns a new iterator for walking along the final states of this FSA.
 FSAMatch matchSequence(byte[] sequence)
           
 FSAMatch matchSequence(byte[] sequence, int node)
           
 FSAMatch matchSequence(byte[] sequence, int start, int length, int node)
          Finds a matching path in the dictionary for a given sequence of labels from sequence and starting at node node.
 FSAMatch matchSequence(FSAMatch result, byte[] sequence, int start, int length, int node)
          Same as matchSequence(byte[], int, int, int), but allows passing a reusable FSAMatch object so that no intermediate garbage is produced.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAllSubsequences

public java.util.Iterator<java.nio.ByteBuffer> getAllSubsequences(int node)
Returns an Iterator of all subsequences available from the given node to all reachable final states.


getFinalStatesIterator

public FSAFinalStatesIterator getFinalStatesIterator()
Returns a new iterator for walking along the final states of this FSA. The iterator is initially set to walk along all final states reachable from the root node.


matchSequence

public FSAMatch matchSequence(FSAMatch result,
                              byte[] sequence,
                              int start,
                              int length,
                              int node)
Same as matchSequence(byte[], int, int, int), but allows passing a reusable FSAMatch object so that no intermediate garbage is produced.

Returns:
The same object as result, but with reset internal type and other fields.

matchSequence

public FSAMatch matchSequence(byte[] sequence,
                              int start,
                              int length,
                              int node)
Finds a matching path in the dictionary for a given sequence of labels from sequence and starting at node node.

Parameters:
sequence - An array of labels to follow in the FSA.
start - Starting index in sequence.
length - How many symbols to consider from sequence?
node - Start node identifier in the FSA.
See Also:
matchSequence(byte [], int)

matchSequence

public FSAMatch matchSequence(byte[] sequence,
                              int node)
See Also:
matchSequence(byte[], int, int, int)

matchSequence

public FSAMatch matchSequence(byte[] sequence)
See Also:
matchSequence(byte[], int, int, int)