|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.ie.crf.CRFCliqueTree<E>
E
- The type of the label (usually String in our uses)public class CRFCliqueTree<E>
Builds a CliqueTree (an array of FactorTable) and does message passing inference along it.
Field Summary | |
---|---|
protected Index<E> |
classIndex
|
protected FactorTable[] |
factorTables
|
protected int |
windowSize
|
protected double |
z
|
Constructor Summary | |
---|---|
CRFCliqueTree(FactorTable[] factorTables,
Index<E> classIndex,
E backgroundSymbol)
Initialize a clique tree |
Method Summary | ||
---|---|---|
int |
backgroundIndex()
|
|
E |
backgroundSymbol()
|
|
Index |
classIndex()
|
|
double |
condLogProbGivenNext(int position,
E label,
E[] nextLabels)
|
|
double |
condLogProbGivenNext(int position,
int label,
int[] nextLabels)
|
|
double |
condLogProbGivenPrevious(int position,
E label,
E[] prevLabels)
|
|
double |
condLogProbGivenPrevious(int position,
int label,
int[] prevLabels)
Gives the probability of a tag at a single position conditioned on a sequence of previous labels. |
|
Counter<E> |
condLogProbsGivenNext(int position,
E[] nextlabels)
|
|
Counter<E> |
condLogProbsGivenNext(int position,
int[] nextlabels)
|
|
Counter<E> |
condLogProbsGivenPrevious(int position,
E[] prevlabels)
|
|
Counter<E> |
condLogProbsGivenPrevious(int position,
int[] prevlabels)
|
|
double |
condProbGivenNext(int position,
E label,
E[] nextLabels)
|
|
double |
condProbGivenNext(int position,
int label,
int[] nextLabels)
|
|
double |
condProbGivenPrevious(int position,
E label,
E[] prevLabels)
|
|
double |
condProbGivenPrevious(int position,
int label,
int[] prevLabels)
|
|
static
|
getCalibratedCliqueTree(double[][] weights,
int[][][] data,
Index[] labelIndices,
int numClasses,
Index<E> classIndex,
E backgroundSymbol)
|
|
static
|
getCalibratedCliqueTree(double[] weights,
double wscale,
int[][] weightIndices,
int[][][] data,
Index[] labelIndices,
int numClasses,
Index<E> classIndex,
E backgroundSymbol)
|
|
double[] |
getConditionalDistribution(int[] sequence,
int position)
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. |
|
static FactorTable |
getFactorTable(double[][] weights,
int[][] data,
Index[] labelIndices,
int numClasses)
|
|
FactorTable[] |
getFactorTables()
|
|
int |
getNumClasses()
|
|
int |
getNumValues()
|
|
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()
|
|
double |
logProb(int position,
E label)
|
|
double |
logProb(int position,
E[] labels)
returns the log probability for the given labels, where the last label corresponds to the label at the specified position. |
|
double |
logProb(int position,
int label)
|
|
double |
logProb(int position,
int[] labels)
returns the log probability for the given labels (indexed using classIndex), where the last label corresponds to the label at the specified position. |
|
Counter<E> |
logProbs(int position)
|
|
GeneralizedCounter |
logProbs(int position,
int window)
|
|
double |
prob(int position,
E label)
|
|
double |
prob(int position,
E[] labels)
returns the probability for the given labels, where the last label corresponds to the label at the specified position. |
|
double |
prob(int position,
int label)
|
|
double |
prob(int position,
int[] labels)
Returns the probability for the given labels (indexed using classIndex), where the last label corresponds to the label at the specified position. |
|
Counter<E> |
probs(int position)
|
|
GeneralizedCounter |
probs(int position,
int window)
|
|
int |
rightWindow()
How many positions to the right a position is dependent on. |
|
double |
scoreOf(int[] sequence)
Returns the log probability of this sequence given the CRF. |
|
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 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 model that the value of the whole sequence is initialized to sequence |
|
double |
totalMass()
|
|
void |
updateSequenceElement(int[] sequence,
int pos,
int oldVal)
Informs this sequence model that the value of the element at position pos has changed. |
|
int |
window()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final FactorTable[] factorTables
protected final double z
protected final Index<E> classIndex
protected final int windowSize
Constructor Detail |
---|
public CRFCliqueTree(FactorTable[] factorTables, Index<E> classIndex, E backgroundSymbol)
Method Detail |
---|
public FactorTable[] getFactorTables()
public Index classIndex()
public int length()
length
in interface SequenceModel
public int leftWindow()
SequenceModel
leftWindow
in interface SequenceModel
public int rightWindow()
SequenceModel
rightWindow
in interface SequenceModel
public int[] getPossibleValues(int position)
SequenceModel
getPossibleValues
in interface SequenceModel
position
- the position
public double scoreOf(int[] sequence, int pos)
SequenceModel
scoreOf
in interface SequenceModel
sequence
- the sequence containing the rest of the values to condition onpos
- the position of the element to give a distribution for
public double[] scoresOf(int[] sequence, int position)
scoresOf
in interface SequenceModel
sequence
- the sequence containing the rest of the values to condition onposition
- the position of the element to give a distribution for
public double scoreOf(int[] sequence)
scoreOf
in interface SequenceModel
sequence
- the sequence to compute a score for
public int window()
public int getNumClasses()
public double totalMass()
public int backgroundIndex()
public E backgroundSymbol()
public double logProb(int position, int label)
public double prob(int position, int label)
public double logProb(int position, E label)
public double prob(int position, E label)
public Counter<E> probs(int position)
public Counter<E> logProbs(int position)
public double logProb(int position, int[] labels)
public double prob(int position, int[] labels)
public double logProb(int position, E[] labels)
public double prob(int position, E[] labels)
public GeneralizedCounter logProbs(int position, int window)
public GeneralizedCounter probs(int position, int window)
public double condLogProbGivenPrevious(int position, int label, int[] prevLabels)
position
- Index in sequencelabel
- Label of item at indexprevLabels
-
public double condLogProbGivenPrevious(int position, E label, E[] prevLabels)
public double condProbGivenPrevious(int position, int label, int[] prevLabels)
public double condProbGivenPrevious(int position, E label, E[] prevLabels)
public Counter<E> condLogProbsGivenPrevious(int position, int[] prevlabels)
public Counter<E> condLogProbsGivenPrevious(int position, E[] prevlabels)
public double condLogProbGivenNext(int position, int label, int[] nextLabels)
public double condLogProbGivenNext(int position, E label, E[] nextLabels)
public double condProbGivenNext(int position, int label, int[] nextLabels)
public double condProbGivenNext(int position, E label, E[] nextLabels)
public Counter<E> condLogProbsGivenNext(int position, int[] nextlabels)
public Counter<E> condLogProbsGivenNext(int position, E[] nextlabels)
public static <E> CRFCliqueTree<E> getCalibratedCliqueTree(double[][] weights, int[][][] data, Index[] labelIndices, int numClasses, Index<E> classIndex, E backgroundSymbol)
public static <E> CRFCliqueTree<E> getCalibratedCliqueTree(double[] weights, double wscale, int[][] weightIndices, int[][][] data, Index[] labelIndices, int numClasses, Index<E> classIndex, E backgroundSymbol)
public static FactorTable getFactorTable(double[][] weights, int[][] data, Index[] labelIndices, int numClasses)
public double[] getConditionalDistribution(int[] sequence, int position)
sequence
- the sequence containing the rest of the values to condition onposition
- the position of the element to give a distribution for
public void updateSequenceElement(int[] sequence, int pos, int oldVal)
updateSequenceElement
in interface SequenceListener
public void setInitialSequence(int[] sequence)
setInitialSequence
in interface SequenceListener
public int getNumValues()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |