Package cc.mallet.fst
Class MaxLatticeDefault
- java.lang.Object
-
- cc.mallet.fst.MaxLatticeDefault
-
- All Implemented Interfaces:
MaxLattice
public class MaxLatticeDefault extends java.lang.Object implements MaxLattice
Default, full dynamic programming version of the Viterbi "Max-(Product)-Lattice" algorithm.- Author:
- Fernando Pereira, Andrew McCallum
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MaxLatticeDefault.Factory
-
Constructor Summary
Constructors Constructor Description MaxLatticeDefault(Transducer t, Sequence inputSequence)
MaxLatticeDefault(Transducer t, Sequence inputSequence, Sequence outputSequence)
MaxLatticeDefault(Transducer t, Sequence inputSequence, Sequence outputSequence, int maxCaches)
Initiate Viterbi decoding of the inputSequence, contrained to match non-null parts of the outputSequence.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SequencePairAlignment<java.lang.Object,java.lang.Object>
bestOutputAlignment()
java.util.List<SequencePairAlignment<java.lang.Object,java.lang.Object>>
bestOutputAlignments(int n)
Sequence<java.lang.Object>
bestOutputSequence()
java.util.List<Sequence<java.lang.Object>>
bestOutputSequences(int n)
SequencePairAlignment<java.lang.Object,Transducer.State>
bestStateAlignment()
java.util.List<SequencePairAlignment<java.lang.Object,Transducer.State>>
bestStateAlignments(int n)
Perform the backward pass of Viterbi, returning the n-best sequences of States.Sequence<Transducer.State>
bestStateSequence()
java.util.List<Sequence<Transducer.State>>
bestStateSequences(int n)
java.util.List<SequencePairAlignment<java.lang.Object,cc.mallet.fst.MaxLatticeDefault.ViterbiNode>>
bestViterbiNodeSequences(int n)
Perform the backward pass of Viterbi, returning the n-best sequences of ViterbiNodes.double
bestWeight()
double
elementwiseAccuracy(Sequence referenceOutput)
double
getDelta(int ip, int stateIndex)
Sequence
getInput()
Sequence
getProvidedOutput()
Transducer
getTransducer()
protected cc.mallet.fst.MaxLatticeDefault.ViterbiNode
getViterbiNode(int ip, int stateIndex)
void
incrementTransducer(Transducer.Incrementor incrementor)
Increment states and transitions with a count of 1.0 along the best state sequence.double
tokenAccuracy(Sequence referenceOutput, java.io.PrintWriter out)
-
-
-
Constructor Detail
-
MaxLatticeDefault
public MaxLatticeDefault(Transducer t, Sequence inputSequence)
-
MaxLatticeDefault
public MaxLatticeDefault(Transducer t, Sequence inputSequence, Sequence outputSequence)
-
MaxLatticeDefault
public MaxLatticeDefault(Transducer t, Sequence inputSequence, Sequence outputSequence, int maxCaches)
Initiate Viterbi decoding of the inputSequence, contrained to match non-null parts of the outputSequence. maxCaches indicates how much state information to memoize in n-best decoding.
-
-
Method Detail
-
getTransducer
public Transducer getTransducer()
- Specified by:
getTransducer
in interfaceMaxLattice
-
getInput
public Sequence getInput()
-
getProvidedOutput
public Sequence getProvidedOutput()
-
getViterbiNode
protected cc.mallet.fst.MaxLatticeDefault.ViterbiNode getViterbiNode(int ip, int stateIndex)
-
getDelta
public double getDelta(int ip, int stateIndex)
- Specified by:
getDelta
in interfaceMaxLattice
-
bestViterbiNodeSequences
public java.util.List<SequencePairAlignment<java.lang.Object,cc.mallet.fst.MaxLatticeDefault.ViterbiNode>> bestViterbiNodeSequences(int n)
Perform the backward pass of Viterbi, returning the n-best sequences of ViterbiNodes. Each ViterbiNode contains the state, output symbol, and other information. Note that the length of each ViterbiNode Sequence is inputLength+1, because the first element of the sequence is the start state, and the first input/output symbols occur on the transition from a start-state to the next state. These first input/output symbols are stored in the second ViterbiNode in the sequence. The last ViterbiNode in the sequence corresponds to the final state and has the last input/output symbols.
-
bestStateAlignments
public java.util.List<SequencePairAlignment<java.lang.Object,Transducer.State>> bestStateAlignments(int n)
Perform the backward pass of Viterbi, returning the n-best sequences of States. Note that the length of each State Sequence is inputLength+1, because the first element of the sequence is the start state, and the first input/output symbols occur on the transition from a start state to the next state. The last State in the sequence corresponds to the final state.
-
bestStateAlignment
public SequencePairAlignment<java.lang.Object,Transducer.State> bestStateAlignment()
-
bestStateSequences
public java.util.List<Sequence<Transducer.State>> bestStateSequences(int n)
- Specified by:
bestStateSequences
in interfaceMaxLattice
-
bestStateSequence
public Sequence<Transducer.State> bestStateSequence()
- Specified by:
bestStateSequence
in interfaceMaxLattice
-
bestOutputAlignments
public java.util.List<SequencePairAlignment<java.lang.Object,java.lang.Object>> bestOutputAlignments(int n)
-
bestOutputAlignment
public SequencePairAlignment<java.lang.Object,java.lang.Object> bestOutputAlignment()
-
bestOutputSequences
public java.util.List<Sequence<java.lang.Object>> bestOutputSequences(int n)
- Specified by:
bestOutputSequences
in interfaceMaxLattice
-
bestOutputSequence
public Sequence<java.lang.Object> bestOutputSequence()
- Specified by:
bestOutputSequence
in interfaceMaxLattice
-
bestWeight
public double bestWeight()
-
incrementTransducer
public void incrementTransducer(Transducer.Incrementor incrementor)
Increment states and transitions with a count of 1.0 along the best state sequence. This provides for a so-called "Viterbi training" approximation.
-
elementwiseAccuracy
public double elementwiseAccuracy(Sequence referenceOutput)
- Specified by:
elementwiseAccuracy
in interfaceMaxLattice
-
tokenAccuracy
public double tokenAccuracy(Sequence referenceOutput, java.io.PrintWriter out)
-
-