Class MissingCommaRelativeClauseRule


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

      Fields 
      Modifier and Type Field Description
      private static java.util.List<java.util.List<org.languagetool.rules.patterns.PatternToken>> ANTI_PATTERNS  
      private boolean behind  
      private static German GERMAN  
      private static java.util.regex.Pattern MARKS_REGEX  
      • Fields inherited from class org.languagetool.rules.Rule

        messages
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<org.languagetool.tagging.disambiguation.rules.DisambiguationPatternRule> getAntiPatterns()  
      private static int getCommaBehind​(org.languagetool.AnalyzedTokenReadings[] tokens, java.util.List<java.lang.Integer> verbs, int start, int end)
      gives back position where a comma is missed
      java.lang.String getDescription()  
      private static java.lang.String getGender​(org.languagetool.AnalyzedTokenReadings token)
      get the gender of of a token
      java.lang.String getId()  
      private static java.lang.String getSinOrPluOfPro​(org.languagetool.AnalyzedTokenReadings token)
      checks if personal pronoun is singular or plural gives back null if token is not a personal pronoun
      private static int hasPotentialSubclause​(org.languagetool.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
      private static boolean isAnyVerb​(org.languagetool.AnalyzedTokenReadings[] tokens, int n)
      is any verb but not an "Infinitiv mit zu"
      private static boolean isArticle​(java.lang.String gender, org.languagetool.AnalyzedTokenReadings[] tokens, int from, int to)
      check if token is potentially an article
      private static boolean isArticleWithoutSub​(java.lang.String gender, org.languagetool.AnalyzedTokenReadings[] tokens, int n)
      is the token a potential article without a noun
      private static boolean isFourCombinedVerbs​(org.languagetool.AnalyzedTokenReadings[] tokens, int first, int last)
      is a special combination of four verbs combination
      private static boolean isInfinitivZu​(org.languagetool.AnalyzedTokenReadings[] tokens, int last)
      is participle plus special combination of two verbs combination
      private static boolean isKonAfterVerb​(org.languagetool.AnalyzedTokenReadings[] tokens, int start, int end)
      conjunction follows last verb
      private static boolean isKonUnt​(org.languagetool.AnalyzedTokenReadings token)
      first token initiate a subclause
      private static boolean isPar​(org.languagetool.AnalyzedTokenReadings token)
      is participle
      private static boolean isPerfect​(org.languagetool.AnalyzedTokenReadings[] tokens, int first, int second)
      is a pair of verbs to build the perfect
      private static boolean isPerfect​(org.languagetool.AnalyzedTokenReadings[] tokens, int first, int second, int third)
      is a pair of verbs to build the perfect
      private static boolean isPronoun​(org.languagetool.AnalyzedTokenReadings[] tokens, int n)
      is potential relative pronoun
      private static boolean isPrp​(org.languagetool.AnalyzedTokenReadings token)
      is preposition
      private static boolean isSeparator​(java.lang.String token)
      is a separator
      private static boolean isSeparatorOrInf​(org.languagetool.AnalyzedTokenReadings[] tokens, int n)
      is separator or VER:INF
      private static boolean isSpecialInf​(org.languagetool.AnalyzedTokenReadings[] tokens, int first, int second, int start)
      is Infinitive in combination with substantiv
      private static boolean isSpecialPair​(org.languagetool.AnalyzedTokenReadings[] tokens, int first, int second)
      two infinitive verbs as pair
      private static boolean isThreeCombinedVerbs​(org.languagetool.AnalyzedTokenReadings[] tokens, int first, int last)
      is a special combination of three verbs combination
      private static boolean isTwoCombinedVerbs​(org.languagetool.AnalyzedTokenReadings first, org.languagetool.AnalyzedTokenReadings second)
      is a special combination of two verbs combination
      private static boolean isTwoPlusCombinedVerbs​(org.languagetool.AnalyzedTokenReadings[] tokens, int first, int last)
      is verb plus special combination of two verbs combination
      private static boolean isVerb​(org.languagetool.AnalyzedTokenReadings[] tokens, int n)
      is a potential verb used in sentence or subclause
      (package private) static boolean isVerbBehind​(org.languagetool.AnalyzedTokenReadings[] tokens, int end)
      is a verb after sub clause
      private static boolean isVerbProPair​(org.languagetool.AnalyzedTokenReadings[] tokens, int n)  
      org.languagetool.rules.RuleMatch[] match​(org.languagetool.AnalyzedSentence sentence)  
      private static boolean matchesGender​(java.lang.String gender, org.languagetool.AnalyzedTokenReadings[] tokens, int from, int to)
      does the gender match with a subject or name?
      private static int missedCommaBehind​(org.languagetool.AnalyzedTokenReadings[] tokens, int inFront, int start, int end)
      gives back position where a comma is missed PRP has to be treated separately
      private static int missedCommaInFront​(org.languagetool.AnalyzedTokenReadings[] tokens, int start, int end, int lastVerb)
      gives back position where a comma is missed PRP has to be treated separately
      private static int nextSeparator​(org.languagetool.AnalyzedTokenReadings[] tokens, int start)
      get the position of the next separator
      private static int skipSub​(org.languagetool.AnalyzedTokenReadings[] tokens, int n, int to)
      skip tokens till the next noun check for e.g.
      private static int skipToSub​(java.lang.String gender, org.languagetool.AnalyzedTokenReadings[] tokens, int n, int to)
      skip tokens till the next noun check for e.g.
      private static java.util.List<java.lang.Integer> verbPos​(org.languagetool.AnalyzedTokenReadings[] tokens, int start, int end)
      gives the positions of verbs in a subclause
      • Methods inherited from class org.languagetool.rules.Rule

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

      • MARKS_REGEX

        private static final java.util.regex.Pattern MARKS_REGEX
      • behind

        private final boolean behind
      • GERMAN

        private static final German GERMAN
      • ANTI_PATTERNS

        private static final java.util.List<java.util.List<org.languagetool.rules.patterns.PatternToken>> ANTI_PATTERNS
    • Constructor Detail

      • MissingCommaRelativeClauseRule

        public MissingCommaRelativeClauseRule​(java.util.ResourceBundle messages)
      • MissingCommaRelativeClauseRule

        public MissingCommaRelativeClauseRule​(java.util.ResourceBundle messages,
                                              boolean behind)
    • Method Detail

      • getId

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

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

        private static boolean isSeparator​(java.lang.String token)
        is a separator
      • nextSeparator

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

        private static boolean isPrp​(org.languagetool.AnalyzedTokenReadings token)
        is preposition
      • isVerb

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

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

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

        private static java.util.List<java.lang.Integer> verbPos​(org.languagetool.AnalyzedTokenReadings[] tokens,
                                                                 int start,
                                                                 int end)
        gives the positions of verbs in a subclause
      • isKonUnt

        private static boolean isKonUnt​(org.languagetool.AnalyzedTokenReadings token)
        first token initiate a subclause
      • hasPotentialSubclause

        private static int hasPotentialSubclause​(org.languagetool.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​(org.languagetool.AnalyzedTokenReadings[] tokens,
                                         int n)
        is potential relative pronoun
      • getGender

        private static java.lang.String getGender​(org.languagetool.AnalyzedTokenReadings token)
        get the gender of of a token
      • matchesGender

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

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

        private static int skipSub​(org.languagetool.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​(java.lang.String gender,
                                     org.languagetool.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​(java.lang.String gender,
                                         org.languagetool.AnalyzedTokenReadings[] tokens,
                                         int from,
                                         int to)
        check if token is potentially an article
      • missedCommaInFront

        private static int missedCommaInFront​(org.languagetool.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​(org.languagetool.AnalyzedTokenReadings first,
                                                  org.languagetool.AnalyzedTokenReadings second)
        is a special combination of two verbs combination
      • isThreeCombinedVerbs

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

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

        private static boolean isPar​(org.languagetool.AnalyzedTokenReadings token)
        is participle
      • isInfinitivZu

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

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

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

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

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

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

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

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

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

        private static int missedCommaBehind​(org.languagetool.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 java.lang.String getSinOrPluOfPro​(org.languagetool.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​(org.languagetool.AnalyzedTokenReadings[] tokens,
                                             int n)
      • match

        public org.languagetool.rules.RuleMatch[] match​(org.languagetool.AnalyzedSentence sentence)
                                                 throws java.io.IOException
        Specified by:
        match in class org.languagetool.rules.Rule
        Throws:
        java.io.IOException
      • getAntiPatterns

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