struct.sequence
Class LinearSequenceModel

java.lang.Object
  extended by edu.umass.cs.mallet.base.fst.Transducer
      extended by struct.sequence.LinearSequenceModel
All Implemented Interfaces:
java.io.Serializable

public class LinearSequenceModel
extends edu.umass.cs.mallet.base.fst.Transducer

A linear model for sequences.

Version:
07/15/2006
Author:
Surya Prakash Bachoti
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.umass.cs.mallet.base.fst.Transducer
edu.umass.cs.mallet.base.fst.Transducer.BeamLattice, edu.umass.cs.mallet.base.fst.Transducer.Lattice, edu.umass.cs.mallet.base.fst.Transducer.State, edu.umass.cs.mallet.base.fst.Transducer.TransitionIterator, edu.umass.cs.mallet.base.fst.Transducer.ViterbiLattice, edu.umass.cs.mallet.base.fst.Transducer.ViterbiPath, edu.umass.cs.mallet.base.fst.Transducer.ViterbiPath_NBest, edu.umass.cs.mallet.base.fst.Transducer.ViterbiPathBeam, edu.umass.cs.mallet.base.fst.Transducer.ViterbiPathBeamB, edu.umass.cs.mallet.base.fst.Transducer.ViterbiPathBeamFB, edu.umass.cs.mallet.base.fst.Transducer.ViterbiPathBeamKL
 
Field Summary
private  edu.umass.cs.mallet.base.types.Alphabet dataAlphabet
           
private static java.util.logging.Logger logger
           
private  Predictor predictor
           
private static long serialVersionUID
           
private  edu.umass.cs.mallet.base.types.Alphabet tagAlphabet
           
 
Fields inherited from class edu.umass.cs.mallet.base.fst.Transducer
INFINITE_COST, inputPipe, outputPipe, ZERO_COST
 
Constructor Summary
LinearSequenceModel(InstanceListDataManager manager)
           
LinearSequenceModel(int numFeats, edu.umass.cs.mallet.base.types.Alphabet tagAlphabet, edu.umass.cs.mallet.base.types.Alphabet dataAlphabet)
          Constructor for objects of class LinearSequenceModel.
 
Method Summary
private  SequenceInstance[] convert(edu.umass.cs.mallet.base.types.InstanceList iList)
          Converts the InstanceList into an array of SequenceInstances
private  SLFeatureVector createFeatureVector(java.util.LinkedList[] predicates, java.lang.String[] tags, SLFeatureVector fv)
           
private  SLFeatureVector createFeatureVector(java.util.LinkedList predicates, java.lang.String next, SLFeatureVector fv)
           
private  SLFeatureVector createFeatureVector(java.util.LinkedList predicates, java.lang.String prev, java.lang.String next, SLFeatureVector fv)
           
private  SequenceInstance getInstance(edu.umass.cs.mallet.base.types.FeatureVectorSequence fvs)
          Converts a FeatureVectorSequence into a SequenceInstance.
private  java.util.LinkedList[] getPredicates(edu.umass.cs.mallet.base.types.FeatureVectorSequence fvs)
           
 edu.umass.cs.mallet.base.fst.Transducer.State getState(int index)
           
 void grow(edu.umass.cs.mallet.base.types.Alphabet dataAlphabet, edu.umass.cs.mallet.base.types.Alphabet tagAlphabet)
          Grows the model to prepare for training with new features.
 java.util.Iterator initialStateIterator()
           
 int numStates()
           
private  void readObject(java.io.ObjectInputStream stream)
           
 void train(edu.umass.cs.mallet.base.types.InstanceList train_iList, int numIter, OnlineUpdator updator)
          Trains the model.
 edu.umass.cs.mallet.base.types.Sequence transduce(edu.umass.cs.mallet.base.types.Sequence input)
          Converts the given sequence into another sequence according to this transducer.
private  void writeObject(java.io.ObjectOutputStream stream)
           
 
Methods inherited from class edu.umass.cs.mallet.base.fst.Transducer
averageTokenAccuracy, averageTokenAccuracy, canIterateAllTransitions, forwardBackward, forwardBackward, forwardBackward, forwardBackward, forwardBackward, forwardBackward, forwardBackward, forwardBackward, forwardBackwardBeam, forwardBackwardBeam, forwardBackwardBeam, forwardBackwardBeam, forwardBackwardBeam, forwardBackwardBeam, forwardBackwardBeam, forwardBackwardBeam, generatePath, getBeamWidth, getInputPipe, getNstatesExpl, getOutputPipe, getViterbiLattice, incIter, isGenerative, isTrainable, pipe, print, setBeamWidth, setCurIter, setKLeps, setRmin, setTrainable, setUseForwardBackwardBeam, stateIndexOfString, sumNegLogProb, train, viterbiPath_NBest, viterbiPath_NBest, viterbiPath, viterbiPath, viterbiPath, viterbiPathBeam, viterbiPathBeam, viterbiPathBeam, viterbiPathBeamB, viterbiPathBeamB, viterbiPathBeamB, viterbiPathBeamB, viterbiPathBeamFB, viterbiPathBeamFB, viterbiPathBeamFB, viterbiPathBeamFB, viterbiPathBeamKL, viterbiPathBeamKL, viterbiPathBeamKL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static java.util.logging.Logger logger

predictor

private Predictor predictor

tagAlphabet

private edu.umass.cs.mallet.base.types.Alphabet tagAlphabet

dataAlphabet

private edu.umass.cs.mallet.base.types.Alphabet dataAlphabet

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

LinearSequenceModel

public LinearSequenceModel(int numFeats,
                           edu.umass.cs.mallet.base.types.Alphabet tagAlphabet,
                           edu.umass.cs.mallet.base.types.Alphabet dataAlphabet)
Constructor for objects of class LinearSequenceModel.

Parameters:
numFeats - - the number of features
tagAlphabet - - the label alphabet
dataAlphabet - - the feature alphabet

LinearSequenceModel

public LinearSequenceModel(InstanceListDataManager manager)
Method Detail

numStates

public int numStates()
Specified by:
numStates in class edu.umass.cs.mallet.base.fst.Transducer

getState

public edu.umass.cs.mallet.base.fst.Transducer.State getState(int index)
Specified by:
getState in class edu.umass.cs.mallet.base.fst.Transducer

initialStateIterator

public java.util.Iterator initialStateIterator()
Specified by:
initialStateIterator in class edu.umass.cs.mallet.base.fst.Transducer

train

public void train(edu.umass.cs.mallet.base.types.InstanceList train_iList,
                  int numIter,
                  OnlineUpdator updator)
           throws java.io.IOException
Trains the model.

Parameters:
train_iList - - the training InstanceList
numIter - - the number of iterations
updator - - the OnlineUpdator
Throws:
java.io.IOException

transduce

public edu.umass.cs.mallet.base.types.Sequence transduce(edu.umass.cs.mallet.base.types.Sequence input)
Converts the given sequence into another sequence according to this transducer.

Overrides:
transduce in class edu.umass.cs.mallet.base.fst.Transducer
Parameters:
input - - Input sequence
Returns:
Sequence - output by this transudcer

getInstance

private SequenceInstance getInstance(edu.umass.cs.mallet.base.types.FeatureVectorSequence fvs)
Converts a FeatureVectorSequence into a SequenceInstance.


convert

private SequenceInstance[] convert(edu.umass.cs.mallet.base.types.InstanceList iList)
                            throws java.io.IOException
Converts the InstanceList into an array of SequenceInstances

Throws:
java.io.IOException

getPredicates

private java.util.LinkedList[] getPredicates(edu.umass.cs.mallet.base.types.FeatureVectorSequence fvs)

createFeatureVector

private SLFeatureVector createFeatureVector(java.util.LinkedList predicates,
                                            java.lang.String prev,
                                            java.lang.String next,
                                            SLFeatureVector fv)

createFeatureVector

private SLFeatureVector createFeatureVector(java.util.LinkedList predicates,
                                            java.lang.String next,
                                            SLFeatureVector fv)

createFeatureVector

private SLFeatureVector createFeatureVector(java.util.LinkedList[] predicates,
                                            java.lang.String[] tags,
                                            SLFeatureVector fv)

grow

public void grow(edu.umass.cs.mallet.base.types.Alphabet dataAlphabet,
                 edu.umass.cs.mallet.base.types.Alphabet tagAlphabet)
Grows the model to prepare for training with new features.

Parameters:
dataAlphabet - - the feature alphabet
tagAlphabet - - the label alphabet

writeObject

private void writeObject(java.io.ObjectOutputStream stream)
                  throws java.io.IOException
Throws:
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream stream)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright (C) 2006 University of Pennsylvania.