gate.fsm
Class FSM

java.lang.Object
  extended bygate.fsm.FSM
All Implemented Interfaces:
JapeConstants, Serializable

public class FSM
extends Object
implements JapeConstants

This class implements a standard Finite State Machine. It is used for both deterministic and non-deterministic machines.

See Also:
Serialized Form

Field Summary
private  Collection allStates
          The set of states for this FSM
(package private)  int bpeId
           
private static boolean DEBUG
          Debug flag
private  Set dStates
           
private  State initialState
          The initial state of this FSM.
private  Map newStates
           
 HashMap ruleHash
           
private  String transducerName
           
 
Fields inherited from interface gate.jape.JapeConstants
APPELT_STYLE, BRILL_STYLE, DEFAULT_PRIORITY, FIRST_STYLE, INDENT_PADDING, KLEENE_PLUS, KLEENE_QUERY, KLEENE_STAR, MULTI_SPAN_BINDING, NO_BINDING, NO_KLEENE_OP, ONCE_STYLE, SINGLE_SPAN_BINDING
 
Constructor Summary
FSM(Rule rule)
          Builds a FSM starting from a rule.
FSM(SinglePhaseTransducer spt)
          Builds a standalone FSM starting from a single phase transducer.
 
Method Summary
private  State convertComplexPE(State startState, ComplexPatternElement cpe, LinkedList labels)
          Receives a state to start from and a complex pattern element.
private  String currentBasicBinding(BasicPatternElement bpe)
           
private  String currentBinding(ComplexPatternElement cpe, int indent)
           
private  String currentLHSBinding(LeftHandSide lhs)
           
 void eliminateVoidTransitions()
          Converts this FSM from a non-deterministic to a deterministic one by eliminating all the unrestricted transitions.
 String getGML()
          Returns a GML (Graph Modelling Language) representation of the transition graph of this FSM.
 State getInitialState()
          Gets the initial state of this FSM
private  AbstractSet lambdaClosure(AbstractSet s)
           
 String toString()
          Returns a textual description of this FSM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

See Also:
Constant Field Values

initialState

private State initialState
The initial state of this FSM.


allStates

private transient Collection allStates
The set of states for this FSM


newStates

private transient Map newStates

dStates

private transient Set dStates

transducerName

private String transducerName

bpeId

int bpeId

ruleHash

public HashMap ruleHash
Constructor Detail

FSM

public FSM(SinglePhaseTransducer spt)
Builds a standalone FSM starting from a single phase transducer.

Parameters:
spt - the single phase transducer to be used for building this FSM.

FSM

public FSM(Rule rule)
Builds a FSM starting from a rule. This FSM is actually a part of a larger one (usually the one that is built based on the single phase transducer that contains the rule). built by this constructor.

Parameters:
rule - the rule to be used for the building process.
Method Detail

getInitialState

public State getInitialState()
Gets the initial state of this FSM

Returns:
an object of type gate.fsm.State representing the initial state.

convertComplexPE

private State convertComplexPE(State startState,
                               ComplexPatternElement cpe,
                               LinkedList labels)
Receives a state to start from and a complex pattern element. Parses the complex pattern element and creates all the necessary states and transitions for accepting annotations described by the given PE.

Parameters:
startState - the state to start from
cpe - the pattern to be recognized
labels - the bindings name for all the annotation accepted along the way. This is actually a list of Strings. It is necessary to use a list because of the recursive definition of ComplexPatternElement.
Returns:
the final state reached after accepting a sequence of annotations as described in the pattern

eliminateVoidTransitions

public void eliminateVoidTransitions()
Converts this FSM from a non-deterministic to a deterministic one by eliminating all the unrestricted transitions.


lambdaClosure

private AbstractSet lambdaClosure(AbstractSet s)

getGML

public String getGML()
Returns a GML (Graph Modelling Language) representation of the transition graph of this FSM.


toString

public String toString()
Returns a textual description of this FSM.


currentBinding

private String currentBinding(ComplexPatternElement cpe,
                              int indent)

currentBasicBinding

private String currentBasicBinding(BasicPatternElement bpe)

currentLHSBinding

private String currentLHSBinding(LeftHandSide lhs)