Class MissingCommaRelativeClauseRule

java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.de.MissingCommaRelativeClauseRule

public class MissingCommaRelativeClauseRule extends Rule
A rule checks a sentence for a missing comma before or after a relative clause (only for German language).
  • Field Details

    • MARKS_REGEX

      private static final Pattern MARKS_REGEX
    • PRONOUN

      private static final Pattern PRONOUN
    • verbPattern

      private static final Pattern verbPattern
    • zalEtcPattern

      private static final Pattern zalEtcPattern
    • behind

      private final boolean behind
    • ANTI_PATTERNS

      private static final List<DisambiguationPatternRule> ANTI_PATTERNS
  • Constructor Details

    • MissingCommaRelativeClauseRule

      public MissingCommaRelativeClauseRule(ResourceBundle messages)
    • MissingCommaRelativeClauseRule

      public MissingCommaRelativeClauseRule(ResourceBundle messages, boolean behind)
  • 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
    • isSeparator

      private static boolean isSeparator(String token)
      is a separator
    • nextSeparator

      private static int nextSeparator(AnalyzedTokenReadings[] tokens, int start)
      get the position of the next separator
    • isPrp

      private static boolean isPrp(AnalyzedTokenReadings token)
      is preposition
    • isVerb

      private static boolean isVerb(AnalyzedTokenReadings[] tokens, int n)
      is a potential verb used in sentence or subclause
    • isAnyVerb

      private static boolean isAnyVerb(AnalyzedTokenReadings[] tokens, int n)
      is any verb but not an "Infinitiv mit zu"
    • isVerbBehind

      static boolean isVerbBehind(AnalyzedTokenReadings[] tokens, int end)
      is a verb after sub clause
    • verbPos

      private static List<Integer> verbPos(AnalyzedTokenReadings[] tokens, int start, int end)
      gives the positions of verbs in a subclause
    • isKonUnt

      private static boolean isKonUnt(AnalyzedTokenReadings token)
      first token initiate a subclause
    • hasPotentialSubclause

      private static int hasPotentialSubclause(AnalyzedTokenReadings[] tokens, int start, int end)
      checks to what position a test of relative clause should done return -1 if no potential relative clause is assumed
    • isPronoun

      private static boolean isPronoun(AnalyzedTokenReadings[] tokens, int n)
      is potential relative pronoun
    • getGender

      private static String getGender(AnalyzedTokenReadings token)
      get the gender of of a token
    • matchesGender

      private static boolean matchesGender(String gender, AnalyzedTokenReadings[] tokens, int from, int to)
      does the gender match with a subject or name?
    • isArticleWithoutSub

      private static boolean isArticleWithoutSub(String gender, AnalyzedTokenReadings[] tokens, int n)
      is the token a potential article without a noun
    • skipSub

      private static int skipSub(AnalyzedTokenReadings[] tokens, int n, int to)
      skip tokens till the next noun check for e.g. "das in die dunkle Garage fahrende Auto" -> "das" is article
    • skipToSub

      private static int skipToSub(String gender, AnalyzedTokenReadings[] tokens, int n, int to)
      skip tokens till the next noun check for e.g. "das in die dunkle Garage fahrende Auto" -> "das" is article
    • isArticle

      private static boolean isArticle(String gender, AnalyzedTokenReadings[] tokens, int from, int to)
      check if token is potentially an article
    • missedCommaInFront

      private static int missedCommaInFront(AnalyzedTokenReadings[] tokens, int start, int end, int lastVerb)
      gives back position where a comma is missed PRP has to be treated separately
    • isTwoCombinedVerbs

      private static boolean isTwoCombinedVerbs(AnalyzedTokenReadings first, AnalyzedTokenReadings second)
      is a special combination of two verbs combination
    • isThreeCombinedVerbs

      private static boolean isThreeCombinedVerbs(AnalyzedTokenReadings[] tokens, int first, int last)
      is a special combination of three verbs combination
    • isFourCombinedVerbs

      private static boolean isFourCombinedVerbs(AnalyzedTokenReadings[] tokens, int first, int last)
      is a special combination of four verbs combination
    • isPar

      private static boolean isPar(AnalyzedTokenReadings token)
      is participle
    • isInfinitivZu

      private static boolean isInfinitivZu(AnalyzedTokenReadings[] tokens, int last)
      is participle plus special combination of two verbs combination
    • isTwoPlusCombinedVerbs

      private static boolean isTwoPlusCombinedVerbs(AnalyzedTokenReadings[] tokens, int first, int last)
      is verb plus special combination of two verbs combination
    • isKonAfterVerb

      private static boolean isKonAfterVerb(AnalyzedTokenReadings[] tokens, int start, int end)
      conjunction follows last verb
    • isSpecialPair

      private static boolean isSpecialPair(AnalyzedTokenReadings[] tokens, int first, int second)
      two infinitive verbs as pair
    • isPerfect

      private static boolean isPerfect(AnalyzedTokenReadings[] tokens, int first, int second)
      is a pair of verbs to build the perfect
    • isSpecialInf

      private static boolean isSpecialInf(AnalyzedTokenReadings[] tokens, int first, int second, int start)
      is Infinitive in combination with substantiv
    • isPerfect

      private static boolean isPerfect(AnalyzedTokenReadings[] tokens, int first, int second, int third)
      is a pair of verbs to build the perfect
    • isSeparatorOrInf

      private static boolean isSeparatorOrInf(AnalyzedTokenReadings[] tokens, int n)
      is separator or VER:INF
    • getCommaBehind

      private static int getCommaBehind(AnalyzedTokenReadings[] tokens, List<Integer> verbs, int start, int end)
      gives back position where a comma is missed
    • missedCommaBehind

      private static int missedCommaBehind(AnalyzedTokenReadings[] tokens, int inFront, int start, int end)
      gives back position where a comma is missed PRP has to be treated separately
    • getSinOrPluOfPro

      private static String getSinOrPluOfPro(AnalyzedTokenReadings token)
      checks if personal pronoun is singular or plural gives back null if token is not a personal pronoun
    • isVerbProPair

      private static boolean isVerbProPair(AnalyzedTokenReadings[] tokens, int n)
    • match

      public RuleMatch[] match(AnalyzedSentence sentence) throws IOException
      Description copied from class: Rule
      Check whether the given sentence matches this error rule, i.e. whether it contains the error detected by this rule. Note that the order in which this method is called is not always guaranteed, i.e. the sentence order in the text may be different from the order in which you get the sentences (this may be the case when LanguageTool is used as a LibreOffice/OpenOffice add-on, for example). In other words, implementations must be stateless, so that a previous call to this method has no influence on later calls.
      Specified by:
      match in class Rule
      Parameters:
      sentence - a pre-analyzed sentence
      Returns:
      an array of RuleMatch objects
      Throws:
      IOException
    • 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