morfologik.fsa
Class FSA

java.lang.Object
  extended by morfologik.fsa.FSA
All Implemented Interfaces:
Iterable<ByteBuffer>
Direct Known Subclasses:
CFSA, FSA5

public abstract class FSA
extends Object
implements Iterable<ByteBuffer>

This is a top interface for walking Finite State Automata as described in Jan Daciuk's Incremental Construction of Finite-State Automata and Transducers, and Their Use in the Natural Language Processing (PhD thesis, Technical University of Gdansk).


Constructor Summary
FSA()
           
 
Method Summary
abstract  int getArc(int node, byte label)
          Returns the identifier of an arc leaving node and labeled with label.
abstract  byte getArcLabel(int arc)
          Return the label associated with a given arc.
abstract  int getEndNode(int arc)
          Return the end node pointed to by a given arc.
abstract  int getFirstArc(int node)
          Returns the identifier of the first arc leaving node or 0 if the node has no outgoing arcs.
abstract  Set<FSAFlags> getFlags()
          Returns a set of flags for this FSA instance.
static FSA getInstance(InputStream in)
          A factory for reading automata in any library-supported version.
abstract  int getNextArc(int arc)
          Returns the identifier of the next arc after arc and leaving node.
abstract  int getRootNode()
          Returns the identifier of the root node of this automaton.
 FSATraversalHelper getTraversalHelper()
          Returns an object which can be used to walk the edges of this finite state automaton and match arbitrary sequences against its states.
abstract  boolean isArcFinal(int arc)
          Returns true if the destination node at the end of this arc corresponds to an input sequence created when building this automaton.
abstract  boolean isArcTerminal(int arc)
          Returns true if this arc does not have a terminating node (@link getEndNode(int) will throw an exception).
 Iterator<ByteBuffer> iterator()
          Returns an iterator over all binary sequences starting from the initial FSA state and ending in final nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FSA

public FSA()
Method Detail

iterator

public Iterator<ByteBuffer> iterator()
Returns an iterator over all binary sequences starting from the initial FSA state and ending in final nodes. The returned iterator is a ByteBuffer that changes on each call to Iterator.next(), so if the content should be preserved, it must be copied somewhere else.

It is guaranteed that the returned byte buffer is backed by a byte array and that the content of the byte buffer starts at the array's index 0.

Specified by:
iterator in interface Iterable<ByteBuffer>

getTraversalHelper

public FSATraversalHelper getTraversalHelper()
Returns an object which can be used to walk the edges of this finite state automaton and match arbitrary sequences against its states.


getRootNode

public abstract int getRootNode()
Returns the identifier of the root node of this automaton. May return 0 if the start node is also the end node.


getFirstArc

public abstract int getFirstArc(int node)
Returns the identifier of the first arc leaving node or 0 if the node has no outgoing arcs.


getArc

public abstract int getArc(int node,
                           byte label)
Returns the identifier of an arc leaving node and labeled with label. An identifier equal to 0 means the node has no outgoing arc labeled label.


getNextArc

public abstract int getNextArc(int arc)
Returns the identifier of the next arc after arc and leaving node. Zero is returned if no more arcs are available for the node.


getEndNode

public abstract int getEndNode(int arc)
Return the end node pointed to by a given arc. Terminal arcs (those that point to a terminal state) have no end node representation and throw a runtime exception.


getArcLabel

public abstract byte getArcLabel(int arc)
Return the label associated with a given arc.


isArcFinal

public abstract boolean isArcFinal(int arc)
Returns true if the destination node at the end of this arc corresponds to an input sequence created when building this automaton.


isArcTerminal

public abstract boolean isArcTerminal(int arc)
Returns true if this arc does not have a terminating node (@link getEndNode(int) will throw an exception). Implies isArcFinal(int).


getFlags

public abstract Set<FSAFlags> getFlags()
Returns a set of flags for this FSA instance.


getInstance

public static FSA getInstance(InputStream in)
                       throws IOException
A factory for reading automata in any library-supported version.

Throws:
IOException


Copyright © 2010. All Rights Reserved.