edu.northwestern.at.morphadorner.corpuslinguistics.postagger.smoothing.contextual

## Class AdditiveContextualSmoother

- java.lang.Object
- - edu.northwestern.at.utils.IsCloseableObject
  - - edu.northwestern.at.morphadorner.corpuslinguistics.postagger.smoothing.contextual.AbstractContextualSmoother
    - - edu.northwestern.at.morphadorner.corpuslinguistics.postagger.smoothing.contextual.AdditiveContextualSmoother

- All Implemented Interfaces:
    ContextualSmoother, UsesLogger
  Direct Known Subclasses:
    DefaultContextualSmoother

      public class AdditiveContextualSmoother
      extends AbstractContextualSmoother
      implements ContextualSmoother

  Additive contextual smoother.

  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.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected double` | `additiveAdjustmentValue` Additive adjustment value.

    - ### Fields inherited from class edu.northwestern.at.morphadorner.corpuslinguistics.postagger.smoothing.contextual.AbstractContextualSmoother

      `cachedContextualProbabilities, logger, partOfSpeechTagger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AdditiveContextualSmoother()` Create an additive contextual smoother.

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class edu.northwestern.at.morphadorner.corpuslinguistics.postagger.smoothing.contextual.AbstractContextualSmoother

      `cachedProbabilitiesCount, clearCachedProbabilities, getLogger, setLogger`

    - ### Methods inherited from class edu.northwestern.at.utils.IsCloseableObject

      `close`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface edu.northwestern.at.morphadorner.corpuslinguistics.postagger.smoothing.contextual.ContextualSmoother

      `cachedProbabilitiesCount, clearCachedProbabilities`

- - ### Field Detail

    - #### additiveAdjustmentValue

          protected double additiveAdjustmentValue

      Additive adjustment value. We use 0.001 by default.

  - ### Constructor Detail

    - #### AdditiveContextualSmoother

          public AdditiveContextualSmoother()

      Create an additive contextual smoother.

  - ### Method Detail

    - #### setPartOfSpeechTagger

          public void setPartOfSpeechTagger(PartOfSpeechTagger partOfSpeechTagger)

      Set the part of speech tagger for this smoother.
      Specified by:
        `setPartOfSpeechTagger` in interface `ContextualSmoother`
      Overrides:
        `setPartOfSpeechTagger` in class `AbstractContextualSmoother`
      Parameters:
        `partOfSpeechTagger` - Part of speech tagger for which this smoother provides probabilities.

    - #### getAdditiveAdjustmentValue

          public double getAdditiveAdjustmentValue()

      Get additive adjustment value.
      Returns:
        Additive adjustment value.

    - #### setAdditiveAdjustmentValue

          public void setAdditiveAdjustmentValue(double additiveAdjustmentValue)

      Set additive adjustment value.
      Parameters:
        `additiveAdjustmentValue` - Additive adjustment value.

    - #### contextualProbability

          public Probability contextualProbability(java.lang.String tag,
                                          java.lang.String previousTag)

      Compute contextual probability of a tag given the previous tag.
      Specified by:
        `contextualProbability` in interface `ContextualSmoother`
      Specified by:
        `contextualProbability` in class `AbstractContextualSmoother`
      Parameters:
        `previousTag` - The previous tag.
        `tag` - The current tag.
      Returns:
        The probability of the current tag given the previous tag, e.g, p( tag | previousTag ).

        We compute the contextual probability p( tag | previousTag ) using additive smoothing.

    - #### contextualProbability

          public Probability contextualProbability(java.lang.String tag,
                                          java.lang.String previousTag,
                                          java.lang.String previousPreviousTag)

      Compute contextual probability of a tag given the previous tags.
      Specified by:
        `contextualProbability` in interface `ContextualSmoother`
      Parameters:
        `tag` - The current tag.
        `previousTag` - The previous tag.
        `previousPreviousTag` - The previous tag of the previous tag.
      Returns:
        The probability of the current tag given the previous two tags, e.g, p( tag | prevTag , prevPrevTag ).

        We compute the contextual probability p( tag | previousTag ) using additive smoothing.

    - #### toString

          public java.lang.String toString()

      Description of this smoother for display.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        Description of this smoother.