public class TestSentence extends java.lang.Object implements SequenceModel
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DBG |
protected java.lang.String |
encoding |
protected java.lang.String[] |
finalTags |
protected static int |
kBestSize |
protected MaxentTagger |
maxentTagger |
protected int |
minWordsLockTags |
protected static java.lang.String |
naTag |
protected java.util.List<HasWord> |
origWords |
protected PairsHolder |
pairs |
protected java.util.List<java.lang.String> |
sent |
protected int |
size |
protected java.lang.String |
tagSeparator |
protected boolean |
VERBOSE |
Constructor and Description |
---|
TestSentence(MaxentTagger maxentTagger) |
Modifier and Type | Method and Description |
---|---|
protected void |
calculateProbs(double[][][] probabilities)
calculateProbs puts log probs of taggings in the probabilities array.
|
protected double[] |
getHistories(java.lang.String[] tags,
History h)
This computes scores of tags at a position in a sentence (the so called "History").
|
int[] |
getPossibleValues(int pos)
Return the valid sequence labels (as integer indices) for a particular
position in the sequence.
|
protected void |
init() |
int |
leftWindow()
How many label positions to the left influence the label assignment
at a particular position.
|
int |
length() |
protected void |
revert(int prevSize) |
int |
rightWindow()
How many label positions to the right influence the label assignment
at a particular position.
|
double |
scoreOf(int[] sequence)
Computes the score assigned by this model to the whole sequence.
|
double |
scoreOf(int[] tags,
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[] tags,
int pos)
Computes the scores of labels for the element at the given position in
the sequence, conditioned on the values of the labels at all other
positions of the provided sequence.
|
void |
setCorrectTags(java.util.List<? extends HasTag> sentence) |
protected java.lang.String[] |
stringTagsAt(int pos) |
java.util.ArrayList<TaggedWord> |
tagSentence(java.util.List<? extends HasWord> s,
boolean reuseTags)
Tags the sentence s by running maxent model.
|
protected void |
updateConfusionMatrix(java.lang.String[] finalTags,
ConfusionMatrix<java.lang.String> confusionMatrix)
Update a confusion matrix with the errors from this sentence.
|
protected void |
writeTagsAndErrors(java.lang.String[] finalTags,
PrintFile pf,
boolean verboseResults)
Write the tagging and note any errors (if pf != null) and accumulate
global statistics.
|
protected final boolean VERBOSE
protected static final java.lang.String naTag
protected static final boolean DBG
protected static final int kBestSize
protected final java.lang.String tagSeparator
protected final java.lang.String encoding
protected final int minWordsLockTags
protected final PairsHolder pairs
protected java.util.List<java.lang.String> sent
protected java.util.List<HasWord> origWords
protected int size
protected java.lang.String[] finalTags
protected final MaxentTagger maxentTagger
public TestSentence(MaxentTagger maxentTagger)
public void setCorrectTags(java.util.List<? extends HasTag> sentence)
public java.util.ArrayList<TaggedWord> tagSentence(java.util.List<? extends HasWord> s, boolean reuseTags)
s
- Input sentence (List). This isn't changed.protected void revert(int prevSize)
protected void init()
protected void calculateProbs(double[][][] probabilities)
probabilities
- Array with indices sent size, k best size, numTagsprotected void writeTagsAndErrors(java.lang.String[] finalTags, PrintFile pf, boolean verboseResults)
finalTags
- Chosen tags for sentencepf
- File to write tagged output to (can be null, then no output;
at present it is non-null iff the debug property is set)protected void updateConfusionMatrix(java.lang.String[] finalTags, ConfusionMatrix<java.lang.String> confusionMatrix)
finalTags
- Chosen tags for sentenceconfusionMatrix
- Confusion matrix to write toprotected double[] getHistories(java.lang.String[] tags, History h)
tags
- h
- 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 pos)
SequenceModel
getPossibleValues
in interface SequenceModel
pos
- The positionpublic double scoreOf(int[] tags, int pos)
SequenceModel
scoreOf
in interface SequenceModel
tags
- 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 scoreOf(int[] sequence)
SequenceModel
scoreOf
in interface SequenceModel
sequence
- The sequence of labels to compute a score forpublic double[] scoresOf(int[] tags, int pos)
SequenceModel
scoresOf
in interface SequenceModel
tags
- The sequence containing the rest of the values to condition onpos
- The position of the element to give a distribution forprotected java.lang.String[] stringTagsAt(int pos)