edu.northwestern.at.morphadorner.corpuslinguistics.postagger.simplerulebased

## Class SimpleRuleBasedTagger

- java.lang.Object
- - edu.northwestern.at.utils.IsCloseableObject
  - - edu.northwestern.at.morphadorner.corpuslinguistics.postagger.AbstractPartOfSpeechTagger
    - - edu.northwestern.at.morphadorner.corpuslinguistics.postagger.unigram.UnigramTagger
      - - edu.northwestern.at.morphadorner.corpuslinguistics.postagger.simplerulebased.SimpleRuleBasedTagger

- All Implemented Interfaces:
    UsesLexicon, CanTagOneWord, PartOfSpeechRetagger, PartOfSpeechTagger, IsCloseable, UsesLogger

      public class SimpleRuleBasedTagger
      extends UnigramTagger
      implements PartOfSpeechTagger, PartOfSpeechRetagger

  Simple Rule-Based Part of Speech tagger.

  The simple rule-based part of speech tagger assigns the most commonly occurring part of speech to all words and then applies a small set of contextual rules to "fix up" the tagging. It's kind of a "Brill light."

  This simple tagger is useful when very fast tagging without high accuracy is useful, e.g., in sentence splitting.

- - ### Field Summary

    - ### Fields inherited from class edu.northwestern.at.morphadorner.corpuslinguistics.postagger.AbstractPartOfSpeechTagger

      `contextRules, contextualSmoother, dynamicLexicon, lexicalRules, lexicalSmoother, lexicon, logger, partOfSpeechGuesser, postTokenizer, retagger, ruleCorrections, transitionMatrix`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleRuleBasedTagger()` Create a simple rule-based tagger.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `getCanAddOrDeleteWords()` Can retagger add or delete words in the original sentence?
    `<T extends AdornedWord> java.util.List<T>` | `retagSentence(java.util.List<T> sentence)` Retag a sentence.
    `<T extends AdornedWord> java.util.List<T>` | `retagWords(java.util.List<T> taggedSentence)` Retag words in a tagged sentence.
    `void` | `setCanAddOrDeleteWords(boolean canAddOrDeleteWords)` Can retagger add or delete words in the original sentence?
    `java.util.List<AdornedWord>` | `tagSentence(java.util.List<java.lang.String> sentence)` Tag a sentence.
    `java.lang.String` | `toString()` Return tagger description.

    - ### Methods inherited from class edu.northwestern.at.morphadorner.corpuslinguistics.postagger.unigram.UnigramTagger

      `tagAdornedWordList, tagWord, tagWord`

    - ### Methods inherited from class edu.northwestern.at.morphadorner.corpuslinguistics.postagger.AbstractPartOfSpeechTagger

      `clearRuleCorrections, createPartOfSpeechGuesser, getContextualSmoother, getDynamicLexicon, getLexicalSmoother, getLexicon, getLexicon, getLogger, getMostCommonTag, getPartOfSpeechGuesser, getPostTokenizer, getRetagger, getRuleCorrections, getTagCount, getTagsForWord, getTransitionMatrix, incrementRuleCorrections, setContextRules, setContextualSmoother, setLexicalRules, setLexicalSmoother, setLexicon, setLogger, setPartOfSpeechGuesser, setPostTokenizer, setRetagger, setTransitionMatrix, tagAdornedWordSentence, tagAdornedWordSentences, tagSentences, usesContextRules, usesLexicalRules, usesTransitionProbabilities`

    - ### 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.PartOfSpeechTagger

      `clearRuleCorrections, getContextualSmoother, getLexicalSmoother, getLexicon, getLexicon, getPartOfSpeechGuesser, getPostTokenizer, getRetagger, getRuleCorrections, getTagCount, getTagsForWord, getTransitionMatrix, incrementRuleCorrections, setContextRules, setContextualSmoother, setLexicalRules, setLexicalSmoother, setLexicon, setPartOfSpeechGuesser, setPostTokenizer, setRetagger, setTransitionMatrix, tagAdornedWordList, tagAdornedWordSentence, tagAdornedWordSentences, tagSentences, usesContextRules, usesLexicalRules, usesTransitionProbabilities`

    - ### Methods inherited from interface edu.northwestern.at.utils.IsCloseable

      `close`

- - ### Constructor Detail

    - #### SimpleRuleBasedTagger

          public SimpleRuleBasedTagger()

      Create a simple rule-based tagger.

  - ### Method Detail

    - #### tagSentence

          public java.util.List<AdornedWord> tagSentence(java.util.List<java.lang.String> sentence)

      Tag a sentence.
      Specified by:
        `tagSentence` in interface `PartOfSpeechTagger`
      Overrides:
        `tagSentence` in class `AbstractPartOfSpeechTagger`
      Parameters:
        `sentence` - The sentence as a list of string words.
      Returns:
        An `AdornedWord` of the words in the sentence tagged with parts of speech.

        The input sentence is a `List` of string words to be tagged. The output is `AdornedWord` of the words with parts of speech added.

    - #### retagWords

          public <T extends AdornedWord> java.util.List<T> retagWords(java.util.List<T> taggedSentence)

      Retag words in a tagged sentence.
      Specified by:
        `retagWords` in interface `PartOfSpeechTagger`
      Overrides:
        `retagWords` in class `AbstractPartOfSpeechTagger`
      Parameters:
        `taggedSentence` - The tagged sentence.
      Returns:
        The retagged sentence.

        This method applies the short list of fixup rules. The resultant tagging is crude but good enough for tasks like sentence boundary detection.

    - #### retagSentence

          public <T extends AdornedWord> java.util.List<T> retagSentence(java.util.List<T> sentence)

      Retag a sentence.
      Specified by:
        `retagSentence` in interface `PartOfSpeechRetagger`
      Parameters:
        `sentence` - The sentence as an `AdornedWord` .
      Returns:
        The sentence with words retagged.

    - #### getCanAddOrDeleteWords

          public boolean getCanAddOrDeleteWords()

      Can retagger add or delete words in the original sentence?
      Specified by:
        `getCanAddOrDeleteWords` in interface `PartOfSpeechRetagger`
      Returns:
        true if retagger can add or delete words.

    - #### setCanAddOrDeleteWords

          public void setCanAddOrDeleteWords(boolean canAddOrDeleteWords)

      Can retagger add or delete words in the original sentence?
      Specified by:
        `setCanAddOrDeleteWords` in interface `PartOfSpeechRetagger`
      Parameters:
        `canAddOrDeleteWords` - true if retagger can add or delete words.

        Ignored here.

    - #### toString

          public java.lang.String toString()

      Return tagger description.
      Overrides:
        `toString` in class `UnigramTagger`
      Returns:
        Tagger description.