Sautrela

edu.gtts.sautrela.wfsa.models
Class DefaultDWFSA

java.lang.Object
  extended by edu.gtts.sautrela.wfsa.models.DefaultDWFSA
All Implemented Interfaces:
DWFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>, WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>

public class DefaultDWFSA
extends java.lang.Object
implements DWFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>

The default implementation of the DWFSA interface. All information about States, Symbols and Transitions are statically saved using HashTable-s.

Author:
Mikel Penagarikano

Nested Class Summary
static class DefaultDWFSA.InsertionMask
           
 
Nested classes/interfaces inherited from interface edu.gtts.sautrela.wfsa.WFSA
WFSA.Factory
 
Field Summary
static WFSA.Factory myFactory
           
 
Constructor Summary
DefaultDWFSA()
          Creates new instance of DefaultDWFSA.
 
Method Summary
 void dumpTrainCounts()
          Dumps the trained data to the model.
 Alphabet<Symbol> getAlphabet()
          Returns the alphabet of the Model.
 double getFinProb(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state)
          Returns the probability of being final
 edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State getIniState()
          Returns the initial State
 java.lang.String getName()
          Returns the name of the Model.
 DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol> getRandomTrans(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state)
          Returns a random transitions from a state
 Symbol getSymbolByName(java.lang.String name)
           
 DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>[] getTrans(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state)
          Returns all possible transitions from a state.
 DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol> getTrans(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state, Symbol symbol)
          Returns the transition for the given state and symbol
protected  void gotoStatic()
           
 void incrementTrainCount(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state, double count)
          Increments the training counts associated to a final state.
 void incrementTrainCount(DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol> t, double count)
          Increments the training counts associated to a Transition.
 void initTrainCounts(double initCount)
          Initializes the training counts.
static void main(java.lang.String[] args)
          DefaultDWFSA - create a WFSA from a transcription.
static DefaultDWFSA newFromTranscription(java.lang.String[] transcription)
          Creates a DefaultDWFSA given a transcription.
static DefaultDWFSA newFromTranscription(java.lang.String name, java.lang.String[] transcription, DefaultDWFSA.InsertionMask mask, java.lang.String insertionSymbol)
          Creates a DefaultDWFSA given a transcription and an insertion mask.
static DefaultDWFSA newFromTranscription(java.lang.String name, java.lang.String[] transcription, DefaultDWFSA.InsertionMask mask, java.lang.String insertionSymbol, Alphabet alphabet)
          Creates a DefaultDWFSA given a transcription,an insertion mask and an existing Alphabet.
 void setName(java.lang.String name)
          Sets the name of the DefaultDWFSA.
 java.lang.String toString()
          Returns a string representation of the object.
 java.lang.String toXML()
          Returns a XML representation of the DefaultDWFSA
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myFactory

public static final WFSA.Factory myFactory
Constructor Detail

DefaultDWFSA

public DefaultDWFSA()
Creates new instance of DefaultDWFSA.

Method Detail

gotoStatic

protected void gotoStatic()

setName

public void setName(java.lang.String name)
Sets the name of the DefaultDWFSA.

Parameters:
name - the name of this DefaultDWFSA

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the object

toXML

public java.lang.String toXML()
Returns a XML representation of the DefaultDWFSA

Specified by:
toXML in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Returns:
a String containing the XML representation

getName

public java.lang.String getName()
Description copied from interface: WFSA
Returns the name of the Model.

Specified by:
getName in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Returns:
The name of the Model

getSymbolByName

public Symbol getSymbolByName(java.lang.String name)

getAlphabet

public Alphabet<Symbol> getAlphabet()
Description copied from interface: WFSA
Returns the alphabet of the Model.

Specified by:
getAlphabet in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Returns:
The Alphabet

getIniState

public edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State getIniState()
Description copied from interface: WFSA
Returns the initial State

Specified by:
getIniState in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Returns:
The initial state

getTrans

public DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>[] getTrans(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state)
Description copied from interface: WFSA
Returns all possible transitions from a state.

Specified by:
getTrans in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Parameters:
state - The source State
Returns:
an array containing all possible transitions from a state. If there is no transition, and empty array must be returned.

getTrans

public DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol> getTrans(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state,
                                                                                           Symbol symbol)
Description copied from interface: DWFSA
Returns the transition for the given state and symbol

Specified by:
getTrans in interface DWFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Parameters:
state - the source State
symbol - the observed symbol
Returns:
the transition for the given state and symbol, or null if the transition does not exists

getFinProb

public double getFinProb(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state)
Description copied from interface: WFSA
Returns the probability of being final

Specified by:
getFinProb in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Returns:
The probability of being final

getRandomTrans

public DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol> getRandomTrans(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state)
Description copied from interface: WFSA
Returns a random transitions from a state

Specified by:
getRandomTrans in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Parameters:
state - The source State
Returns:
a random transition

initTrainCounts

public void initTrainCounts(double initCount)
Description copied from interface: WFSA
Initializes the training counts. Al previous counts are cleared and initCount is used as initial posterior probability count of the WFSA (MAP training). This count must be distributed among all the internal parameters according to their prior probabilities.

Specified by:
initTrainCounts in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Parameters:
initCount - initial posterior probability count

incrementTrainCount

public void incrementTrainCount(edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State state,
                                double count)
Description copied from interface: WFSA
Increments the training counts associated to a final state. These counts are related to the final probability of a State.

Specified by:
incrementTrainCount in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Parameters:
state - the final Sate
count - the training count.

incrementTrainCount

public void incrementTrainCount(DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol> t,
                                double count)
Description copied from interface: WFSA
Increments the training counts associated to a Transition. These counts are related to the probability of a Transition.

Specified by:
incrementTrainCount in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>
Parameters:
t - the Transition
count - the training count.

dumpTrainCounts

public void dumpTrainCounts()
Description copied from interface: WFSA
Dumps the trained data to the model.

Specified by:
dumpTrainCounts in interface WFSA<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol,DefaultTransition<edu.gtts.sautrela.wfsa.models.DefaultDWFSA.State,Symbol>>

newFromTranscription

public static DefaultDWFSA newFromTranscription(java.lang.String[] transcription)
Creates a DefaultDWFSA given a transcription. It is equivalent to

newFromTranscription("noname",tr,new InsertionMask(""),"");

Parameters:
transcription - an array of Strings.

newFromTranscription

public static DefaultDWFSA newFromTranscription(java.lang.String name,
                                                java.lang.String[] transcription,
                                                DefaultDWFSA.InsertionMask mask,
                                                java.lang.String insertionSymbol,
                                                Alphabet alphabet)
Creates a DefaultDWFSA given a transcription,an insertion mask and an existing Alphabet.

Parameters:
name - The name of the WFSA
transcription - an array of Strings. The strings should
mask - the InsertionMask to be used
insertionSymbol - the insertion symbol name
alphabet - the alphabet (could grow)

newFromTranscription

public static DefaultDWFSA newFromTranscription(java.lang.String name,
                                                java.lang.String[] transcription,
                                                DefaultDWFSA.InsertionMask mask,
                                                java.lang.String insertionSymbol)
Creates a DefaultDWFSA given a transcription and an insertion mask. It is equivalent to

newFromTranscription(name,transcription,mask,null);

Parameters:
name - The name of the WFSA
transcription - an array of Strings. The strings should
mask - the InsertionMask to be used
insertionSymbol - the insertion symbol name

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
DefaultDWFSA - create a WFSA from a transcription.
      Syntax:  DefaultDWFSA  [-lri symbol] name symbol [ symbol ... ]
 
        -ilr  symbol  Insertion of symbol is allowed (not forced) at the beginning (-l),
                      between (-i) and at the end (-r) of the transcription symbols.
        name          name for the DWFSA
        symbol        transcription symbol.
 

Parameters:
args - Command line arguments.
Throws:
java.lang.Exception

Sautrela