cc.mallet.fst
Class Transducer

java.lang.Object
  extended by cc.mallet.fst.Transducer
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CRF, FeatureTransducer, HMM, PRAuxiliaryModel

public abstract class Transducer
extends java.lang.Object
implements java.io.Serializable

A base class for all sequence models, analogous to classify.Classifier.

See Also:
Serialized Form

Nested Class Summary
static interface Transducer.Incrementor
          Methods to be called by inference methods to indicate partial counts of sufficient statistics.
static class Transducer.State
          An abstract class used to represent the states of the transducer.
static class Transducer.TransitionIterator
          An abstract class to iterate over the states of the transducer.
 
Field Summary
static double CERTAIN_WEIGHT
           
static double IMPOSSIBLE_WEIGHT
           
protected  Pipe inputPipe
          A pipe that should produce a Sequence in the "data" slot, (and possibly one in the "target" slot also
protected  Pipe outputPipe
          A pipe that should expect the Transducer's output sequence in the "target" slot, and should produce something printable in the "source" slot that indicates the results of transduction.
 
Constructor Summary
Transducer()
          Initializes default sum-product and max-product inference engines.
Transducer(Pipe inputPipe, Pipe outputPipe)
           
 
Method Summary
 double averageTokenAccuracy(InstanceList ilist)
          Runs inference across all the instances and returns the average token accuracy.
 boolean canIterateAllTransitions()
          Some transducers are "generative", meaning that you can get a sequence out of them without giving them an input sequence.
 SequencePairAlignment generatePath()
           
 Pipe getInputPipe()
           
 MaxLatticeFactory getMaxLatticeFactory()
           
 Pipe getOutputPipe()
           
abstract  Transducer.State getState(int index)
           
 SumLatticeFactory getSumLatticeFactory()
           
abstract  java.util.Iterator initialStateIterator()
           
 boolean isGenerative()
          If true, this is a "generative transducer".
 Instance label(Instance instance)
          Take input sequence from instance.data and put the output sequence in instance.target.
static double less_efficient_sumLogProb(double a, double b)
           
static double no_longer_needed_sumNegLogProb(double a, double b)
           
abstract  int numStates()
           
 void print()
           
 void setMaxLatticeFactory(MaxLatticeFactory vf)
           
 void setSumLatticeFactory(SumLatticeFactory fbf)
           
 int stateIndexOfString(java.lang.String s)
          Returns the index of the input state name, returns -1 if name not found.
static double sumLogProb(double a, double b)
          Returns Math.log(Math.exp(a) + Math.exp(b)).
 Instance transduce(Instance instance)
          Take input sequence from instance.data and put the output sequence in instance.data.
 Sequence transduce(Sequence input)
          Converts the given sequence into another sequence according to this transducer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CERTAIN_WEIGHT

public static final double CERTAIN_WEIGHT
See Also:
Constant Field Values

IMPOSSIBLE_WEIGHT

public static final double IMPOSSIBLE_WEIGHT
See Also:
Constant Field Values

inputPipe

protected Pipe inputPipe
A pipe that should produce a Sequence in the "data" slot, (and possibly one in the "target" slot also


outputPipe

protected Pipe outputPipe
A pipe that should expect the Transducer's output sequence in the "target" slot, and should produce something printable in the "source" slot that indicates the results of transduction.

Constructor Detail

Transducer

public Transducer()
Initializes default sum-product and max-product inference engines.


Transducer

public Transducer(Pipe inputPipe,
                  Pipe outputPipe)
Method Detail

getInputPipe

public Pipe getInputPipe()

getOutputPipe

public Pipe getOutputPipe()

setSumLatticeFactory

public void setSumLatticeFactory(SumLatticeFactory fbf)

setMaxLatticeFactory

public void setMaxLatticeFactory(MaxLatticeFactory vf)

getSumLatticeFactory

public SumLatticeFactory getSumLatticeFactory()

getMaxLatticeFactory

public MaxLatticeFactory getMaxLatticeFactory()

label

public Instance label(Instance instance)
Take input sequence from instance.data and put the output sequence in instance.target. Like transduce(Instance), but put best output sequence into instance.target rather than instance.data.


transduce

public Instance transduce(Instance instance)
Take input sequence from instance.data and put the output sequence in instance.data.


transduce

public Sequence transduce(Sequence input)
Converts the given sequence into another sequence according to this transducer. For exmaple, probabilistic transducer may do something like Viterbi here. Subclasses of transducer may specify that they only accept special kinds of sequence.

Parameters:
input - Input sequence
Returns:
Sequence output by this transudcer

numStates

public abstract int numStates()

getState

public abstract Transducer.State getState(int index)

initialStateIterator

public abstract java.util.Iterator initialStateIterator()

canIterateAllTransitions

public boolean canIterateAllTransitions()
Some transducers are "generative", meaning that you can get a sequence out of them without giving them an input sequence. In this case State.transitionIterator() should return all available transitions, but attempts to obtain the input and weight fields may throw an exception.


isGenerative

public boolean isGenerative()
If true, this is a "generative transducer". In this case State.transitionIterator() should return transitions that have valid input and cost fields. True returned here should imply that canIterateAllTransitions() is true.


averageTokenAccuracy

public double averageTokenAccuracy(InstanceList ilist)
Runs inference across all the instances and returns the average token accuracy.


generatePath

public SequencePairAlignment generatePath()

stateIndexOfString

public int stateIndexOfString(java.lang.String s)
Returns the index of the input state name, returns -1 if name not found.


print

public void print()

no_longer_needed_sumNegLogProb

public static double no_longer_needed_sumNegLogProb(double a,
                                                    double b)

sumLogProb

public static double sumLogProb(double a,
                                double b)
Returns Math.log(Math.exp(a) + Math.exp(b)).

a, b represent weights.


less_efficient_sumLogProb

public static double less_efficient_sumLogProb(double a,
                                               double b)