Class AvsAnRule

java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.en.AvsAnRule

public class AvsAnRule extends org.languagetool.rules.Rule
Check if the determiner (if any) preceding a word is:
  • an if the next word starts with a vowel
  • a if the next word does not start with a vowel
This rule loads some exceptions from external files det_a.txt and det_an.txt (e.g. for an hour).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Pattern
     

    Fields inherited from class org.languagetool.rules.Rule

    messages
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    (package private) AvsAnRule.Determiner
    getCorrectDeterminerFor(org.languagetool.AnalyzedTokenReadings token)
     
     
     
    private boolean
    isVowel(char c)
     
    org.languagetool.rules.RuleMatch[]
    match(org.languagetool.AnalyzedSentence sentence)
     
    suggestAorAn(String origWord)
    Adds "a" or "an" to the English noun.

    Methods inherited from class org.languagetool.rules.Rule

    addExamplePair, getAntiPatterns, getCategory, getConfigureText, getCorrectExamples, getDefaultValue, getErrorTriggeringExamples, getIncorrectExamples, getLocQualityIssueType, getMaxConfigurableValue, getMinConfigurableValue, getSentenceWithImmunization, getUrl, hasConfigurableValue, isDefaultOff, isDefaultTempOff, isDictionaryBasedSpellingRule, isOfficeDefaultOff, isOfficeDefaultOn, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setErrorTriggeringExamples, setIncorrectExamples, setLocQualityIssueType, setOfficeDefaultOff, setOfficeDefaultOn, setUrl, supportsLanguage, toRuleMatchArray, useInOffice

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cleanupPattern

      private static final Pattern cleanupPattern
  • Constructor Details

  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in class org.languagetool.rules.Rule
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class org.languagetool.rules.Rule
    • estimateContextForSureMatch

      public int estimateContextForSureMatch()
      Overrides:
      estimateContextForSureMatch in class org.languagetool.rules.Rule
    • match

      public org.languagetool.rules.RuleMatch[] match(org.languagetool.AnalyzedSentence sentence)
      Specified by:
      match in class org.languagetool.rules.Rule
    • suggestAorAn

      public String suggestAorAn(String origWord)
      Adds "a" or "an" to the English noun. Used for suggesting the proper form of the indefinite article. For the rare cases where both "a" and "an" are considered okay (e.g. for "historical"), "a" is returned.
      Parameters:
      origWord - Word that needs an article.
      Returns:
      String containing the word with a determiner, or just the word if the word is an abbreviation.
    • getCorrectDeterminerFor

      AvsAnRule.Determiner getCorrectDeterminerFor(org.languagetool.AnalyzedTokenReadings token)
    • isVowel

      private boolean isVowel(char c)