Package cc.mallet.fst
Class Transducer
- java.lang.Object
-
- 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 toclassify.Classifier
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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
Fields Modifier and Type Field Description 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 alsoprotected 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
Constructors Constructor Description Transducer()
Initializes default sum-product and max-product inference engines.Transducer(Pipe inputPipe, Pipe outputPipe)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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.
-
-
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)
-
-