Class VerbAgreementRule

java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.TextLevelRule
org.languagetool.rules.de.VerbAgreementRule

public class VerbAgreementRule extends org.languagetool.rules.TextLevelRule
Simple agreement checker for German verbs and subject. Checks agreement in:
  • VER:1:SIN w/o ich: e.g. "Max bin da." (incorrect) [same for VER:2:SIN w/o du, VER:1:PLU w/o wir]
  • ich + VER:[123]:.* (not VER:1:SIN): e.g. "ich bist" (incorrect) [same for du, er, wir]
TODO:
  • wenn nur ein mögliches finites Verb -> das nehmen (Max machen das.)
  • Sie (i>1)
  • bei ich/du/er/wir sofort prüfen, damit alle vorkommen geprüft werden (Ich geht jetzt nach Hause und dort gehe ich sofort unter die Dusche.) [aber: isNear]
  • Alle Verbvorkommen merken (Er präsentieren wollte und Video hätte keine Pläne.)
  • Nested Class Summary

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

    Fields
    Modifier and Type
    Field
    Description
    private static final List<List<org.languagetool.rules.patterns.PatternToken>>
     
    private static final Set<String>
     
    private static final Set<String>
     
    private final German
     
    private static final Set<String>
     

    Fields inherited from class org.languagetool.rules.Rule

    messages
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<org.languagetool.tagging.disambiguation.rules.DisambiguationPatternRule>
     
     
     
    private List<String>
    getPronounSuggestions(org.languagetool.AnalyzedTokenReadings verb, boolean toUppercase)
     
    private List<String>
    getVerbSuggestions(org.languagetool.AnalyzedTokenReadings verb, String expectedVerbPOS, boolean toUppercase)
     
    private boolean
    hasUnambiguouslyPersonAndNumber(org.languagetool.AnalyzedTokenReadings tokenReadings, String person, String number)
     
    private boolean
    isFiniteVerb(org.languagetool.AnalyzedTokenReadings token)
     
    private boolean
    isNear(int a, int b)
     
    private boolean
    isQuotationMark(org.languagetool.AnalyzedTokenReadings token)
     
    org.languagetool.rules.RuleMatch[]
    match(List<org.languagetool.AnalyzedSentence> sentences)
     
    private List<org.languagetool.rules.RuleMatch>
    match(org.languagetool.AnalyzedSentence sentence, int pos)
     
    int
     
    private boolean
    nextButOneIsModal(org.languagetool.AnalyzedTokenReadings[] tokens, int pos)
     
    private org.languagetool.rules.RuleMatch
    ruleMatchWrongVerb(org.languagetool.AnalyzedTokenReadings token, int pos, org.languagetool.AnalyzedSentence sentence)
     
    private org.languagetool.rules.RuleMatch
    ruleMatchWrongVerbSubject(org.languagetool.AnalyzedTokenReadings subject, org.languagetool.AnalyzedTokenReadings verb, String expectedVerbPOS, int pos, org.languagetool.AnalyzedSentence sentence)
     
    verbDoesMatchPersonAndNumber(org.languagetool.AnalyzedTokenReadings token1, org.languagetool.AnalyzedTokenReadings token2, String person, String number, org.languagetool.AnalyzedTokenReadings finiteVerb)
     

    Methods inherited from class org.languagetool.rules.TextLevelRule

    estimateContextForSureMatch, match, match

    Methods inherited from class org.languagetool.rules.Rule

    addExamplePair, 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

    • ANTI_PATTERNS

      private static final List<List<org.languagetool.rules.patterns.PatternToken>> ANTI_PATTERNS
    • BIN_IGNORE

      private static final Set<String> BIN_IGNORE
    • CONJUNCTIONS

      private static final Set<String> CONJUNCTIONS
    • QUOTATION_MARKS

      private static final Set<String> QUOTATION_MARKS
    • language

      private final German language
  • 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
    • match

      public org.languagetool.rules.RuleMatch[] match(List<org.languagetool.AnalyzedSentence> sentences)
      Specified by:
      match in class org.languagetool.rules.TextLevelRule
    • match

      private List<org.languagetool.rules.RuleMatch> match(org.languagetool.AnalyzedSentence sentence, int pos)
    • getAntiPatterns

      public List<org.languagetool.tagging.disambiguation.rules.DisambiguationPatternRule> getAntiPatterns()
      Overrides:
      getAntiPatterns in class org.languagetool.rules.Rule
    • nextButOneIsModal

      private boolean nextButOneIsModal(org.languagetool.AnalyzedTokenReadings[] tokens, int pos)
    • isNear

      private boolean isNear(int a, int b)
      Returns:
      true if |a - b| invalid input: '<' 5, and a != -1
    • isQuotationMark

      private boolean isQuotationMark(org.languagetool.AnalyzedTokenReadings token)
    • hasUnambiguouslyPersonAndNumber

      private boolean hasUnambiguouslyPersonAndNumber(org.languagetool.AnalyzedTokenReadings tokenReadings, String person, String number)
      Returns:
      true if the verb @param token (if it is a verb) matches @param person and @param number, and matches no other person/number
    • isFiniteVerb

      private boolean isFiniteVerb(org.languagetool.AnalyzedTokenReadings token)
      Returns:
      true if @param token is a finite verb, and it is no participle, pronoun or number
    • verbDoesMatchPersonAndNumber

      private VerbAgreementRule.BooleanAndFiniteVerb verbDoesMatchPersonAndNumber(org.languagetool.AnalyzedTokenReadings token1, org.languagetool.AnalyzedTokenReadings token2, String person, String number, org.languagetool.AnalyzedTokenReadings finiteVerb)
      Returns:
      false if neither the verb @param token1 (if any) nor @param token2 match @param person and @param number, and none of them is "und" or "," if a finite verb is found, it is saved in finiteVerb
    • getVerbSuggestions

      private List<String> getVerbSuggestions(org.languagetool.AnalyzedTokenReadings verb, String expectedVerbPOS, boolean toUppercase)
      Parameters:
      toUppercase - true when the suggestions should be capitalized
      Returns:
      a list of forms of @param verb which match @param expectedVerbPOS (person:number)
    • getPronounSuggestions

      private List<String> getPronounSuggestions(org.languagetool.AnalyzedTokenReadings verb, boolean toUppercase)
      Parameters:
      toUppercase - true when the suggestions should be capitalized
      Returns:
      a list of pronouns which match the person and number of @param verb
    • ruleMatchWrongVerb

      private org.languagetool.rules.RuleMatch ruleMatchWrongVerb(org.languagetool.AnalyzedTokenReadings token, int pos, org.languagetool.AnalyzedSentence sentence)
    • ruleMatchWrongVerbSubject

      private org.languagetool.rules.RuleMatch ruleMatchWrongVerbSubject(org.languagetool.AnalyzedTokenReadings subject, org.languagetool.AnalyzedTokenReadings verb, String expectedVerbPOS, int pos, org.languagetool.AnalyzedSentence sentence)
    • minToCheckParagraph

      public int minToCheckParagraph()
      Specified by:
      minToCheckParagraph in class org.languagetool.rules.TextLevelRule