E - The type of the label (usually String in our uses)public class CRFCliqueTree<E> extends java.lang.Object implements ListeningSequenceModel
| Constructor and Description |
|---|
CRFCliqueTree(FactorTable[] factorTables,
Index<E> classIndex,
E backgroundSymbol)
Initialize a clique tree.
|
| Modifier and Type | Method and Description |
|---|---|
int |
backgroundIndex() |
E |
backgroundSymbol() |
Index<E> |
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 <E> CRFCliqueTree<E> |
getCalibratedCliqueTree(double[] weights,
double wscale,
int[][] weightIndices,
int[][][] data,
java.util.List<Index<CRFLabel>> labelIndices,
int numClasses,
Index<E> classIndex,
E backgroundSymbol)
This function assumes a LinearCliquePotentialFunction is used for wrapping the weights
|
static <E> CRFCliqueTree<E> |
getCalibratedCliqueTree(int[][][] data,
java.util.List<Index<CRFLabel>> labelIndices,
int numClasses,
Index<E> classIndex,
E backgroundSymbol,
CliquePotentialFunction cliquePotentialFunc,
double[][][] featureVals) |
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.
|
FactorTable[] |
getFactorTables() |
int |
getNumClasses() |
int |
getNumValues() |
int[] |
getPossibleValues(int position)
Return the valid sequence labels (as integer indices) for a particular
position in the sequence.
|
int |
leftWindow()
How many label positions to the left influence the label assignment
at a particular position.
|
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 |
logProbStartPos() |
double[] |
logProbsToDoubleArr(int position) |
double[][] |
logProbTable() |
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) |
double[] |
probsToDoubleArr(int position) |
int |
rightWindow()
How many label positions to the right influence the label assignment
at a particular position.
|
double |
scoreOf(int[] sequence)
Returns the log probability of this sequence given the CRF.
|
double |
scoreOf(int[] sequence,
int pos)
Computes the score of the element at the given position 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() |
public CRFCliqueTree(FactorTable[] factorTables, Index<E> classIndex, E backgroundSymbol)
public FactorTable[] getFactorTables()
public int length()
length in interface SequenceModelpublic int leftWindow()
SequenceModelleftWindow in interface SequenceModelpublic int rightWindow()
SequenceModelrightWindow in interface SequenceModelpublic int[] getPossibleValues(int position)
SequenceModelgetPossibleValues in interface SequenceModelposition - The positionpublic double scoreOf(int[] sequence,
int pos)
SequenceModelscoreOf in interface SequenceModelsequence - The sequence containing the prediction and the rest of the
labels to condition onpos - The position of the element to give a score forpublic double[] scoresOf(int[] sequence,
int position)
scoresOf in interface SequenceModelsequence - the sequence containing the rest of the values to condition onposition - the position of the element to give a distribution forpublic double scoreOf(int[] sequence)
scoreOf in interface SequenceModelsequence - The sequence to compute a score forpublic int window()
public int getNumClasses()
public double totalMass()
public int backgroundIndex()
public E backgroundSymbol()
public double[][] logProbTable()
public double logProbStartPos()
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 double[] probsToDoubleArr(int position)
public double[] logProbsToDoubleArr(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 - Indices of labels in previous positionspublic double condLogProbGivenPrevious(int position,
E label,
E[] prevLabels)
public double condProbGivenPrevious(int position,
int label,
int[] prevLabels)
public Counter<E> condLogProbsGivenPrevious(int position, int[] prevlabels)
public double condLogProbGivenNext(int position,
int label,
int[] nextLabels)
public double condProbGivenNext(int position,
int label,
int[] nextLabels)
public static <E> CRFCliqueTree<E> getCalibratedCliqueTree(int[][][] data, java.util.List<Index<CRFLabel>> labelIndices, int numClasses, Index<E> classIndex, E backgroundSymbol, CliquePotentialFunction cliquePotentialFunc, double[][][] featureVals)
public static <E> CRFCliqueTree<E> getCalibratedCliqueTree(double[] weights, double wscale, int[][] weightIndices, int[][][] data, java.util.List<Index<CRFLabel>> labelIndices, int numClasses, Index<E> classIndex, E backgroundSymbol)
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 forpublic void updateSequenceElement(int[] sequence,
int pos,
int oldVal)
updateSequenceElement in interface SequenceListenerpublic void setInitialSequence(int[] sequence)
setInitialSequence in interface SequenceListenerpublic int getNumValues()