Sautrela

edu.gtts.sautrela.wfsa.models
Class LMM

java.lang.Object
  extended by edu.gtts.sautrela.wfsa.models.LMM
All Implemented Interfaces:
NdWFSA<LMM.xState,Symbol,LMM.xTransition>, WFSA<LMM.xState,Symbol,LMM.xTransition>

public class LMM
extends java.lang.Object
implements NdWFSA<LMM.xState,Symbol,LMM.xTransition>

Author:
mpenagar

Nested Class Summary
 class LMM.LayerConnectionException
           
static class LMM.TopLayer
           
 class LMM.xState
           
 class LMM.xTransition
           
 
Nested classes/interfaces inherited from interface edu.gtts.sautrela.wfsa.WFSA
WFSA.Factory
 
Field Summary
static WFSA.Factory myFactory
           
 
Constructor Summary
LMM()
          Creates a new instance of LMM
 
Method Summary
 void addLayer(WFSASet wfsaset)
          Adds a new layer on the top of this LMM
 void addLayer(WFSASet wfsaset, double scale, double offset)
          Adds a new layer on the top of this LMM
 void addTopLayer(LMM.TopLayer type)
           
 void addTopLayer(LMM.TopLayer type, double scale, double offset)
           
 void addTopLayer(WFSA _wfsa)
           
 void addTopLayer(WFSA _wfsa, double scale, double offset)
           
 void checkBottomUp()
           
 void dumpTrainCounts()
          Dumps the trained data to any WFSA model at any layer.
 Alphabet<Symbol> getAlphabet()
          Returns the alphabet of the Model.
 double getFinProb(LMM.xState state)
          Returns the probability of being final
 LMM.xState getIniState()
          Returns the initial State
 java.lang.String getName()
          Returns the name of the Model.
static java.lang.String getPathInfo(Path<LMM.xState,LMM.xTransition> p)
           
 LMM.xTransition getRandomTrans(LMM.xState from)
          Returns a random transitions from a state
 LMM.xTransition[] getTrans(LMM.xState from)
          Returns all possible transitions from a state.
 LMM.xTransition[] getTrans(LMM.xState from, Symbol symbol)
          Returns all possible transitions for the given source state and symbol.
 void incrementTrainCount(LMM.xState state, double count)
          Increments the training counts of each model/state pair of the given LMMSate.
 void incrementTrainCount(LMM.xTransition t, double count)
          Increments the training counts of a given LMMTransition.
 void initTrainCounts(double initCount)
          Initializes the training counts of any WFSA model at any layer.
static void main(java.lang.String[] args)
          LMM - create Layered Markov Model from WFSASets.
 void setName(java.lang.String name)
          Sets the name of the LMM.
 java.lang.String toString()
          Returns a string representation of the object.
 java.lang.String toXML()
          Returns a XML representation of the WFSA
 
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

LMM

public LMM()
Creates a new instance of LMM

Method Detail

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

setName

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

Parameters:
name - the name of this LMM

addLayer

public void addLayer(WFSASet wfsaset)
              throws LMM.LayerConnectionException
Adds a new layer on the top of this LMM

Parameters:
wfsaset - the WFSASet that represents the layer to be added.
Throws:
LMM.LayerConnectionException

addLayer

public void addLayer(WFSASet wfsaset,
                     double scale,
                     double offset)
              throws LMM.LayerConnectionException
Adds a new layer on the top of this LMM

Parameters:
wfsaset - the WFSASet that represents the layer to be added.
Throws:
LMM.LayerConnectionException

addTopLayer

public void addTopLayer(WFSA _wfsa)
                 throws LMM.LayerConnectionException
Throws:
LMM.LayerConnectionException

addTopLayer

public void addTopLayer(WFSA _wfsa,
                        double scale,
                        double offset)
                 throws LMM.LayerConnectionException
Throws:
LMM.LayerConnectionException

checkBottomUp

public void checkBottomUp()
                   throws LMM.LayerConnectionException
Throws:
LMM.LayerConnectionException

addTopLayer

public void addTopLayer(LMM.TopLayer type)
                 throws LMM.LayerConnectionException
Throws:
LMM.LayerConnectionException

addTopLayer

public void addTopLayer(LMM.TopLayer type,
                        double scale,
                        double offset)
                 throws LMM.LayerConnectionException
Throws:
LMM.LayerConnectionException

getName

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

Specified by:
getName in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Returns:
The name of the Model

getAlphabet

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

Specified by:
getAlphabet in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Returns:
The Alphabet

getIniState

public LMM.xState getIniState()
Description copied from interface: WFSA
Returns the initial State

Specified by:
getIniState in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Returns:
The initial state

getFinProb

public double getFinProb(LMM.xState state)
Description copied from interface: WFSA
Returns the probability of being final

Specified by:
getFinProb in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Returns:
The probability of being final

getTrans

public LMM.xTransition[] getTrans(LMM.xState from)
Description copied from interface: WFSA
Returns all possible transitions from a state.

Specified by:
getTrans in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Parameters:
from - The source State
Returns:
an array containing all possible transitions from a state. If there is no transition, and empty array must be returned.

getRandomTrans

public LMM.xTransition getRandomTrans(LMM.xState from)
Description copied from interface: WFSA
Returns a random transitions from a state

Specified by:
getRandomTrans in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Parameters:
from - The source State
Returns:
a random transition

getTrans

public LMM.xTransition[] getTrans(LMM.xState from,
                                  Symbol symbol)
Description copied from interface: NdWFSA
Returns all possible transitions for the given source state and symbol. The array should be ordered in descending probability (the most probable transition is the first and the less probable is the last).

Specified by:
getTrans in interface NdWFSA<LMM.xState,Symbol,LMM.xTransition>
Parameters:
from - the source State
symbol - the observed symbol
Returns:
an array containing all possible transitions. If there is no transition, an empty array must be returned.

initTrainCounts

public void initTrainCounts(double initCount)
Initializes the training counts of any WFSA model at any layer.

Specified by:
initTrainCounts in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Parameters:
initCount - initial posterior probability count

incrementTrainCount

public void incrementTrainCount(LMM.xState state,
                                double count)
Increments the training counts of each model/state pair of the given LMMSate. These counts are related to the final probability of a State.

Specified by:
incrementTrainCount in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Parameters:
state - the final LMMSate
count - the training count.

incrementTrainCount

public void incrementTrainCount(LMM.xTransition t,
                                double count)
Increments the training counts of a given LMMTransition. The count contributes to all (final or internal) Transition-s that generated the MetaTransition

Specified by:
incrementTrainCount in interface WFSA<LMM.xState,Symbol,LMM.xTransition>
Parameters:
t - the Transition
count - the training count.

dumpTrainCounts

public void dumpTrainCounts()
Dumps the trained data to any WFSA model at any layer.

Specified by:
dumpTrainCounts in interface WFSA<LMM.xState,Symbol,LMM.xTransition>

toXML

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

Specified by:
toXML in interface WFSA<LMM.xState,Symbol,LMM.xTransition>

getPathInfo

public static java.lang.String getPathInfo(Path<LMM.xState,LMM.xTransition> p)

main

public static void main(java.lang.String[] args)
LMM - create Layered Markov Model from WFSASets.
      Syntax:  LMM  [-uncheck] [-d int] name  < -e | -s | wfsa > [a b] wfsaset [a b]  [wfsaset [a b]]...
 
        -uncheck avoids doing layer check.
        -d int   The index [0,n-1] of the Layer used for decoding (default to n-1, top-layer)
        name     The name of the resulting LMM
        -e       Equiprobable (see TopLayer.EQPROB).
        -s       Selector (see TopLayer.SELECTOR).
        wsfa     Use the given automaton as top Layer.
        a        Log scale applied to this layer probabilities.
        b        Log offset applied to this layer probabilities.
        wsfaset  Add the given automata as next Layer.
 

Parameters:
args - Command line arguments.

Sautrela