Package org.languagetool.rules.de
Class MissingCommaRelativeClauseRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.de.MissingCommaRelativeClauseRule
A rule checks a sentence for a missing comma before or after a relative clause (only for German language).
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMissingCommaRelativeClauseRule(ResourceBundle messages) MissingCommaRelativeClauseRule(ResourceBundle messages, boolean behind) -
Method Summary
Modifier and TypeMethodDescriptionOverwrite this to avoid false alarms by ignoring these patterns - note that yourRule.match(AnalyzedSentence)method needs to callRule.getSentenceWithImmunization(org.languagetool.AnalyzedSentence)for this to be used and you need to checkAnalyzedTokenReadings.isImmunized()private static intgetCommaBehind(AnalyzedTokenReadings[] tokens, List<Integer> verbs, int start, int end) gives back position where a comma is missedA short description of the error this rule can detect, usually in the language of the text that is checked.private static StringgetGender(AnalyzedTokenReadings token) get the gender of of a tokengetId()A string used to identify the rule in e.g.private static Stringchecks if personal pronoun is singular or plural gives back null if token is not a personal pronounprivate static inthasPotentialSubclause(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 assumedprivate static booleanisAnyVerb(AnalyzedTokenReadings[] tokens, int n) is any verb but not an "Infinitiv mit zu"private static booleanisArticle(String gender, AnalyzedTokenReadings[] tokens, int from, int to) check if token is potentially an articleprivate static booleanisArticleWithoutSub(String gender, AnalyzedTokenReadings[] tokens, int n) is the token a potential article without a nounprivate static booleanisFourCombinedVerbs(AnalyzedTokenReadings[] tokens, int first, int last) is a special combination of four verbs combinationprivate static booleanisInfinitivZu(AnalyzedTokenReadings[] tokens, int last) is participle plus special combination of two verbs combinationprivate static booleanisKonAfterVerb(AnalyzedTokenReadings[] tokens, int start, int end) conjunction follows last verbprivate static booleanisKonUnt(AnalyzedTokenReadings token) first token initiate a subclauseprivate static booleanisPar(AnalyzedTokenReadings token) is participleprivate static booleanisPerfect(AnalyzedTokenReadings[] tokens, int first, int second) is a pair of verbs to build the perfectprivate static booleanisPerfect(AnalyzedTokenReadings[] tokens, int first, int second, int third) is a pair of verbs to build the perfectprivate static booleanisPronoun(AnalyzedTokenReadings[] tokens, int n) is potential relative pronounprivate static booleanisPrp(AnalyzedTokenReadings token) is prepositionprivate static booleanisSeparator(String token) is a separatorprivate static booleanisSeparatorOrInf(AnalyzedTokenReadings[] tokens, int n) is separator or VER:INFprivate static booleanisSpecialInf(AnalyzedTokenReadings[] tokens, int first, int second, int start) is Infinitive in combination with substantivprivate static booleanisSpecialPair(AnalyzedTokenReadings[] tokens, int first, int second) two infinitive verbs as pairprivate static booleanisThreeCombinedVerbs(AnalyzedTokenReadings[] tokens, int first, int last) is a special combination of three verbs combinationprivate static booleanisTwoCombinedVerbs(AnalyzedTokenReadings first, AnalyzedTokenReadings second) is a special combination of two verbs combinationprivate static booleanisTwoPlusCombinedVerbs(AnalyzedTokenReadings[] tokens, int first, int last) is verb plus special combination of two verbs combinationprivate static booleanisVerb(AnalyzedTokenReadings[] tokens, int n) is a potential verb used in sentence or subclause(package private) static booleanisVerbBehind(AnalyzedTokenReadings[] tokens, int end) is a verb after sub clauseprivate static booleanisVerbProPair(AnalyzedTokenReadings[] tokens, int n) match(AnalyzedSentence sentence) Check whether the given sentence matches this error rule, i.e.private static booleanmatchesGender(String gender, AnalyzedTokenReadings[] tokens, int from, int to) does the gender match with a subject or name?private static intmissedCommaBehind(AnalyzedTokenReadings[] tokens, int inFront, int start, int end) gives back position where a comma is missed PRP has to be treated separatelyprivate static intmissedCommaInFront(AnalyzedTokenReadings[] tokens, int start, int end, int lastVerb) gives back position where a comma is missed PRP has to be treated separatelyprivate static intnextSeparator(AnalyzedTokenReadings[] tokens, int start) get the position of the next separatorprivate static intskipSub(AnalyzedTokenReadings[] tokens, int n, int to) skip tokens till the next noun check for e.g.private static intskipToSub(String gender, AnalyzedTokenReadings[] tokens, int n, int to) skip tokens till the next noun check for e.g.verbPos(AnalyzedTokenReadings[] tokens, int start, int end) gives the positions of verbs in a subclauseMethods inherited from class org.languagetool.rules.Rule
addExamplePair, addTags, addToneTags, cacheAntiPatterns, estimateContextForSureMatch, getCategory, getCorrectExamples, getDistanceTokens, getErrorTriggeringExamples, getFullId, getIncorrectExamples, getLocQualityIssueType, getMinPrevMatches, getPriority, getRuleOptions, getSentenceWithImmunization, getSourceFile, getSubId, getTags, getToneTags, getUrl, hasTag, hasToneTag, isDefaultOff, isDefaultTempOff, isDictionaryBasedSpellingRule, isGoalSpecific, isIncludedInHiddenMatches, isOfficeDefaultOff, isOfficeDefaultOn, isPremium, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setDistanceTokens, setErrorTriggeringExamples, setExamplePair, setGoalSpecific, setIncludedInHiddenMatches, setIncorrectExamples, setLocQualityIssueType, setMinPrevMatches, setOfficeDefaultOff, setOfficeDefaultOn, setPremium, setPriority, setTags, setToneTags, setUrl, supportsLanguage, toRuleMatchArray, useInOffice
-
Field Details
-
MARKS_REGEX
-
PRONOUN
-
verbPattern
-
zalEtcPattern
-
behind
private final boolean behind -
ANTI_PATTERNS
-
-
Constructor Details
-
MissingCommaRelativeClauseRule
-
MissingCommaRelativeClauseRule
-
-
Method Details
-
getId
Description copied from class:RuleA 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 charactersA-Zand the underscore. -
getDescription
Description copied from class:RuleA short description of the error this rule can detect, usually in the language of the text that is checked.- Specified by:
getDescriptionin classRule
-
isSeparator
is a separator -
nextSeparator
get the position of the next separator -
isPrp
is preposition -
isVerb
is a potential verb used in sentence or subclause -
isAnyVerb
is any verb but not an "Infinitiv mit zu" -
isVerbBehind
is a verb after sub clause -
verbPos
gives the positions of verbs in a subclause -
isKonUnt
first token initiate a subclause -
hasPotentialSubclause
checks to what position a test of relative clause should done return -1 if no potential relative clause is assumed -
isPronoun
is potential relative pronoun -
getGender
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
is the token a potential article without a noun -
skipSub
skip tokens till the next noun check for e.g. "das in die dunkle Garage fahrende Auto" -> "das" is article -
skipToSub
skip tokens till the next noun check for e.g. "das in die dunkle Garage fahrende Auto" -> "das" is article -
isArticle
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
is a special combination of three verbs combination -
isFourCombinedVerbs
is a special combination of four verbs combination -
isPar
is participle -
isInfinitivZu
is participle plus special combination of two verbs combination -
isTwoPlusCombinedVerbs
is verb plus special combination of two verbs combination -
isKonAfterVerb
conjunction follows last verb -
isSpecialPair
two infinitive verbs as pair -
isPerfect
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
is a pair of verbs to build the perfect -
isSeparatorOrInf
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
checks if personal pronoun is singular or plural gives back null if token is not a personal pronoun -
isVerbProPair
-
match
Description copied from class:RuleCheck 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:
matchin classRule- Parameters:
sentence- a pre-analyzed sentence- Returns:
- an array of
RuleMatchobjects - Throws:
IOException
-
getAntiPatterns
Description copied from class:RuleOverwrite this to avoid false alarms by ignoring these patterns - note that yourRule.match(AnalyzedSentence)method needs to callRule.getSentenceWithImmunization(org.languagetool.AnalyzedSentence)for this to be used and you need to checkAnalyzedTokenReadings.isImmunized()- Overrides:
getAntiPatternsin classRule
-