Package cc.mallet.fst

Class 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
    • Field Detail

      • 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()
      • 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()
      • 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.
      • 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)