Class SimpleFSA<T>
java.lang.Object
ca.phon.fsa.SimpleFSA<T>
- Direct Known Subclasses:
- PhonexFSA
A basic implementation of a fsa.  The
 input to the machine must be an array of
 type 
T.- 
Nested Class SummaryNested Classes
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddFinalState(String state) Add a final statevoidAdd a new state to the machine.voidaddTransition(FSATransition<T> transition) Add a new transitionprotected FSATransition<T> This method is called when the machine fails before end of input during delta.This method chooses which state the machine should move to given a machine state.Get the dot representation of the machine.String[]intgetGroupIndex(String groupName) Get index of named group.getGroupName(int groupIndex) Get the group name for the given index.Get a list of all named groupsintGet the number of groupsString[]getTransitionsForState(String state) Get the transitions for a paticular stategetTransitionsToState(String state) Get the transitions for a paticular statebooleanvoidprintDef()voidremoveFinalState(String state) Remove a final statevoidremoveState(String stateName) Remove a state (and all transitions to/from it)voidremoveTransition(FSATransition<T> transition) Remove a transitionrunWithTape(T[] tape) runWithTape(T[] tape, FSAState<T> machineState) runWithTape(T[] tape, FSAState<T> machineState, boolean forceReluctant) Run the machine with the given tapevoidsetGroupName(int groupIndex, String groupName) Set name of a group.voidsetInitialState(String initialState) voidsetNumberOfGroups(int numberOfGroups) Set the number of groupsvoid
- 
Constructor Details- 
SimpleFSApublic SimpleFSA()
 
- 
- 
Method Details- 
setNumberOfGroupspublic void setNumberOfGroups(int numberOfGroups) Set the number of groups- Parameters:
- numberOfGroups-
 
- 
getNumberOfGroupspublic int getNumberOfGroups()Get the number of groups- Returns:
- the number of groups
 
- 
getGroupNames
- 
getGroupIndexGet index of named group.- Returns:
- index of named group or -1 if not found
 
- 
getGroupNameGet the group name for the given index.- Parameters:
- groupIndex-
- Returns:
- the group name or nullif group is not named
 
- 
setGroupNameSet name of a group. Set during compile time.- Parameters:
- groupIndex-
- groupName-
 
- 
stripGroupspublic void stripGroups()
- 
addState
- 
removeStateRemove a state (and all transitions to/from it)- Parameters:
- stateName-
 
- 
addTransitionAdd a new transition- Parameters:
- transition-
 
- 
removeTransitionRemove a transition- Parameters:
- transition-
 
- 
getInitialState
- 
setInitialState
- 
addFinalStateAdd a final state
- 
removeFinalStateRemove a final state
- 
getTransitionsForStateGet the transitions for a paticular state- Parameters:
- state-
- Returns:
- the transitions for the state
 
- 
getTransitionsToStateGet the transitions for a paticular state- Parameters:
- state-
- Returns:
- the transitions for the state
 
- 
getTransitions
- 
runWithTape
- 
runWithTape
- 
runWithTape
- 
deltapublic FSATransition<T> delta(FSAState<T> machineState, Stack<SimpleFSA.DecisionTracker<T>> decisions) This method chooses which state the machine should move to given a machine state. If more than one choice is available they are added to the decision stack. Using backtrack will reset the machine tape index and return the next state the machine should move to using the next possible path choice.- Parameters:
- machineState-
- decisions-
- Returns:
- the next machine state.  If no transition can be followed,
 or we have reached the end of input nullis returned.
 
- 
backtrackprotected FSATransition<T> backtrack(FSAState<T> machineState, Stack<SimpleFSA.DecisionTracker<T>> decisions) This method is called when the machine fails before end of input during delta. The method resets to the last path decision and attempts to choose a new path through the machine. The machine tape index is reset by this method.- Parameters:
- machineState-
- decisions-
- Returns:
- the next state of the machine or nullif no path choices exist on the decision stack.
 
- 
getFinalStates
- 
getStates
- 
isFinalState
- 
printDefpublic void printDef()
- 
getDotTextGet the dot representation of the machine.
 
-