public class AdditiveContextualSmoother extends AbstractContextualSmoother implements ContextualSmoother
A contextual smoother which adds a small positive value to each (word, tag) count to avoid zero probabilities. When the value added is 1, this is Laplace smoothing. When the value added is 0.5, this is Lidstone smoothing.
This implementation uses 0.001 as the additive adjustment value. This seems to work well when there is lots of training data.
Modifier and Type | Field and Description |
---|---|
protected double |
additiveAdjustmentValue
Additive adjustment value.
|
cachedContextualProbabilities, logger, partOfSpeechTagger
Constructor and Description |
---|
AdditiveContextualSmoother()
Create an additive contextual smoother.
|
Modifier and Type | Method and Description |
---|---|
Probability |
contextualProbability(java.lang.String tag,
java.lang.String previousTag)
Compute contextual probability of a tag given the previous tag.
|
Probability |
contextualProbability(java.lang.String tag,
java.lang.String previousTag,
java.lang.String previousPreviousTag)
Compute contextual probability of a tag given the previous tags.
|
double |
getAdditiveAdjustmentValue()
Get additive adjustment value.
|
void |
setAdditiveAdjustmentValue(double additiveAdjustmentValue)
Set additive adjustment value.
|
void |
setPartOfSpeechTagger(PartOfSpeechTagger partOfSpeechTagger)
Set the part of speech tagger for this smoother.
|
java.lang.String |
toString()
Description of this smoother for display.
|
cachedProbabilitiesCount, clearCachedProbabilities, getLogger, setLogger
close
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
cachedProbabilitiesCount, clearCachedProbabilities
protected double additiveAdjustmentValue
public AdditiveContextualSmoother()
public void setPartOfSpeechTagger(PartOfSpeechTagger partOfSpeechTagger)
setPartOfSpeechTagger
in interface ContextualSmoother
setPartOfSpeechTagger
in class AbstractContextualSmoother
partOfSpeechTagger
- Part of speech tagger for which
this smoother provides probabilities.public double getAdditiveAdjustmentValue()
public void setAdditiveAdjustmentValue(double additiveAdjustmentValue)
additiveAdjustmentValue
- Additive adjustment value.public Probability contextualProbability(java.lang.String tag, java.lang.String previousTag)
contextualProbability
in interface ContextualSmoother
contextualProbability
in class AbstractContextualSmoother
previousTag
- The previous tag.tag
- The current tag.We compute the contextual probability p( tag | previousTag ) using additive smoothing.
public Probability contextualProbability(java.lang.String tag, java.lang.String previousTag, java.lang.String previousPreviousTag)
contextualProbability
in interface ContextualSmoother
tag
- The current tag.previousTag
- The previous tag.previousPreviousTag
- The previous tag of the previous tag.We compute the contextual probability p( tag | previousTag ) using additive smoothing.
public java.lang.String toString()
toString
in class java.lang.Object