edu.stanford.nlp.sequences
Class FactoredSequenceModel

java.lang.Object
  extended by edu.stanford.nlp.sequences.FactoredSequenceModel
All Implemented Interfaces:
SequenceModel

public class FactoredSequenceModel
extends Object
implements SequenceModel

Author:
grenager Date: Dec 14, 2004 nmramesh Date: May 12, 2010

Constructor Summary
FactoredSequenceModel(SequenceModel[] models, double[] weights)
           
FactoredSequenceModel(SequenceModel model1, SequenceModel model2)
           
FactoredSequenceModel(SequenceModel model1, SequenceModel model2, double wt1, double wt2)
          using this constructor results in a weighted addition of the two models' scores.
 
Method Summary
 int[] getPossibleValues(int position)
          0...leftWindow-1 etc are null, leftWindow...length+leftWindow-1 are words, length+leftWindow...length+leftWindow+rightWindow-1 are null;
 int leftWindow()
          How many positions to the left a position is dependent on.
 int length()
           
 int rightWindow()
          How many positions to the right a position is dependent on.
 double scoreOf(int[] sequence)
          Computes the score assigned by this model to the provided sequence.
 double scoreOf(int[] sequence, int pos)
          Computes the unnormalized log conditional distribution over values of the element at position pos in the sequence, conditioned on the values of the elements in all other positions of the provided sequence.
 double[] scoresOf(int[] sequence, int pos)
          Computes the distribution over values of the element at position pos in the sequence, conditioned on the values of the elements in all other positions of the provided sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FactoredSequenceModel

public FactoredSequenceModel(SequenceModel model1,
                             SequenceModel model2,
                             double wt1,
                             double wt2)
using this constructor results in a weighted addition of the two models' scores.

Parameters:
model1 -
model2 -
wt1 - weight of model1
wt2 - weight of model2

FactoredSequenceModel

public FactoredSequenceModel(SequenceModel model1,
                             SequenceModel model2)

FactoredSequenceModel

public FactoredSequenceModel(SequenceModel[] models,
                             double[] weights)
Method Detail

scoresOf

public double[] scoresOf(int[] sequence,
                         int pos)
Computes the distribution over values of the element at position pos in the sequence, conditioned on the values of the elements in all other positions of the provided sequence.

Specified by:
scoresOf in interface SequenceModel
Parameters:
sequence - the sequence containing the rest of the values to condition on
pos - the position of the element to give a distribution for
Returns:
an array of type double, representing a probability distribution; must sum to 1.0

scoreOf

public double scoreOf(int[] sequence,
                      int pos)
Description copied from interface: SequenceModel
Computes the unnormalized log conditional distribution over values of the element at position pos in the sequence, conditioned on the values of the elements in all other positions of the provided sequence.

Specified by:
scoreOf in interface SequenceModel
Parameters:
sequence - the sequence containing the rest of the values to condition on
pos - the position of the element to give a distribution for
Returns:
the log score of the token at the specified position in the sequence

scoreOf

public double scoreOf(int[] sequence)
Computes the score assigned by this model to the provided sequence. Typically this will be a probability in log space (since the probabilities are small).

Specified by:
scoreOf in interface SequenceModel
Parameters:
sequence - the sequence to compute a score for
Returns:
the score for the sequence

length

public int length()
Specified by:
length in interface SequenceModel
Returns:
the length of the sequence

leftWindow

public int leftWindow()
Description copied from interface: SequenceModel
How many positions to the left a position is dependent on.

Specified by:
leftWindow in interface SequenceModel
Returns:
the size of the left window used by this sequence model

rightWindow

public int rightWindow()
Description copied from interface: SequenceModel
How many positions to the right a position is dependent on.

Specified by:
rightWindow in interface SequenceModel
Returns:
the size of the right window used by this sequence model

getPossibleValues

public int[] getPossibleValues(int position)
Description copied from interface: SequenceModel
0...leftWindow-1 etc are null, leftWindow...length+leftWindow-1 are words, length+leftWindow...length+leftWindow+rightWindow-1 are null;

Specified by:
getPossibleValues in interface SequenceModel
Parameters:
position - the position
Returns:
the set of possible int values at this position, as an int array


Stanford NLP Group