edu.stanford.nlp.ie
Class UniformPrior<IN extends CoreMap>

java.lang.Object
  extended by edu.stanford.nlp.ie.UniformPrior<IN>
All Implemented Interfaces:
SequenceListener, SequenceModel

public class UniformPrior<IN extends CoreMap>
extends Object
implements SequenceModel, SequenceListener

Uniform prior to be used for generic Gibbs inference in the ie.crf.CRFClassifier

Author:
Mihai

Field Summary
protected  int backgroundSymbol
           
protected  Index<String> classIndex
           
protected  List<IN> doc
           
protected  int numClasses
           
protected  int[] possibleValues
           
protected  int[] sequence
           
 
Constructor Summary
UniformPrior(String backgroundSymbol, Index<String> classIndex, List<IN> doc)
           
 
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 whole sequence.
 double scoreOf(int[] sequence, int position)
          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 position)
          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.
 void setInitialSequence(int[] sequence)
          Informs this sequence listener that the value of the whole sequence is initialized to sequence
 void updateSequenceElement(int[] sequence, int pos, int oldVal)
          Informs this sequence listener that the value of the element at position pos has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sequence

protected int[] sequence

backgroundSymbol

protected int backgroundSymbol

numClasses

protected int numClasses

possibleValues

protected int[] possibleValues

classIndex

protected Index<String> classIndex

doc

protected List<IN extends CoreMap> doc
Constructor Detail

UniformPrior

public UniformPrior(String backgroundSymbol,
                    Index<String> classIndex,
                    List<IN> doc)
Method Detail

scoreOf

public double scoreOf(int[] sequence)
Description copied from interface: SequenceModel
Computes the score assigned by this model to the whole sequence. Typically this will be an unnormalized 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

scoresOf

public double[] scoresOf(int[] sequence,
                         int position)
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:
scoresOf in interface SequenceModel
Parameters:
sequence - the sequence containing the rest of the values to condition on
position - the position of the element to give a distribution for
Returns:
the scores of the possible tokens at the specified position in the sequence

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

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

length

public int length()
Specified by:
length in interface SequenceModel
Returns:
the length of the sequences modeled by this SequenceModel

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

scoreOf

public double scoreOf(int[] sequence,
                      int position)
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
position - the position of the element to give a distribution for
Returns:
the log score of the token at the specified position in the sequence

setInitialSequence

public void setInitialSequence(int[] sequence)
Description copied from interface: SequenceListener
Informs this sequence listener that the value of the whole sequence is initialized to sequence

Specified by:
setInitialSequence in interface SequenceListener

updateSequenceElement

public void updateSequenceElement(int[] sequence,
                                  int pos,
                                  int oldVal)
Description copied from interface: SequenceListener
Informs this sequence listener that the value of the element at position pos has changed. This allows this sequence model to update its internal model if desired.

Specified by:
updateSequenceElement in interface SequenceListener


Stanford NLP Group