Class VerbAgreementRule


public class VerbAgreementRule extends 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.)
  • Field Details

  • Constructor Details

  • Method Details

    • getId

      public String getId()
      Description copied from class: Rule
      A string used to identify the rule in e.g. configuration files. This string is supposed to be unique and to stay the same in all upcoming versions of LanguageTool. It's supposed to contain only the characters A-Z and the underscore.
      Specified by:
      getId in class Rule
    • getDescription

      public String getDescription()
      Description copied from class: Rule
      A short description of the error this rule can detect, usually in the language of the text that is checked.
      Specified by:
      getDescription in class Rule
    • match

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

      private List<RuleMatch> match(AnalyzedSentence sentence, int pos, AnalyzedSentence wholeSentence)
    • getAntiPatterns

      public List<DisambiguationPatternRule> getAntiPatterns()
      Description copied from class: Rule
      Overwrite this to avoid false alarms by ignoring these patterns - note that your Rule.match(AnalyzedSentence) method needs to call Rule.getSentenceWithImmunization(org.languagetool.AnalyzedSentence) for this to be used and you need to check AnalyzedTokenReadings.isImmunized()
      Overrides:
      getAntiPatterns in class Rule
    • nextButOneIsModal

      private boolean nextButOneIsModal(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(AnalyzedTokenReadings token)
    • hasUnambiguouslyPersonAndNumber

      private boolean hasUnambiguouslyPersonAndNumber(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(AnalyzedTokenReadings token)
      Returns:
      true if @param token is a finite verb, and it is no participle, pronoun or number
    • verbDoesMatchPersonAndNumber

      private VerbAgreementRule.BooleanAndFiniteVerb verbDoesMatchPersonAndNumber(AnalyzedTokenReadings token1, AnalyzedTokenReadings token2, String person, String number, 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(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(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 RuleMatch ruleMatchWrongVerb(AnalyzedTokenReadings token, int pos, AnalyzedSentence sentence)
    • ruleMatchWrongVerbSubject

      private RuleMatch ruleMatchWrongVerbSubject(AnalyzedTokenReadings subject, AnalyzedTokenReadings verb, String expectedVerbPOS, int pos, AnalyzedSentence sentence)
    • sortBySimilarity

      private void sortBySimilarity(List<String> suggestions, String markedText)
    • minToCheckParagraph

      public int minToCheckParagraph()
      Description copied from class: TextLevelRule
      Gives back the minimum number of paragraphs to check to give back a correct result. Only used by LO office extension.
      • n == -1 --> need to check full text (use only if really needed / bad performance) examples: AbstractWordCoherencyRule, GenericUnpairedBracketsRule, ...
      • n == 0 --> need only to check the current paragraph examples: MultipleWhitespaceRule, LongParagraphRule, ...
      • n >= 1 --> need only to check n paragraphs around the current paragraph examples: ParagraphRepeatBeginningRule (n == 1), WordRepeatBeginningRule (n == 2), ...
      Specified by:
      minToCheckParagraph in class TextLevelRule