Package org.languagetool.rules.de
Class VerbAgreementRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.TextLevelRule
org.languagetool.rules.de.VerbAgreementRule
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]
- 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 ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final List<List<PatternToken>> private final Supplier<List<DisambiguationPatternRule>> private static final Patternprivate final German -
Constructor Summary
Constructors -
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()A short description of the error this rule can detect, usually in the language of the text that is checked.getId()A string used to identify the rule in e.g.getPronounSuggestions(AnalyzedTokenReadings verb, boolean toUppercase) getVerbSuggestions(AnalyzedTokenReadings verb, String expectedVerbPOS, boolean toUppercase) private booleanhasUnambiguouslyPersonAndNumber(AnalyzedTokenReadings tokenReadings, String person, String number) private booleanprivate booleanisNear(int a, int b) private booleanmatch(List<AnalyzedSentence> sentences) match(AnalyzedSentence sentence, int pos, AnalyzedSentence wholeSentence) intGives back the minimum number of paragraphs to check to give back a correct result.private booleannextButOneIsModal(AnalyzedTokenReadings[] tokens, int pos) private RuleMatchruleMatchWrongVerb(AnalyzedTokenReadings token, int pos, AnalyzedSentence sentence) private RuleMatchruleMatchWrongVerbSubject(AnalyzedTokenReadings subject, AnalyzedTokenReadings verb, String expectedVerbPOS, int pos, AnalyzedSentence sentence) private voidsortBySimilarity(List<String> suggestions, String markedText) verbDoesMatchPersonAndNumber(AnalyzedTokenReadings token1, AnalyzedTokenReadings token2, String person, String number, AnalyzedTokenReadings finiteVerb) Methods inherited from class org.languagetool.rules.TextLevelRule
estimateContextForSureMatch, match, matchMethods inherited from class org.languagetool.rules.Rule
addExamplePair, addTags, addToneTags, cacheAntiPatterns, 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
-
ANTI_PATTERNS
-
BIN_IGNORE
-
CONJUNCTIONS
-
QUOTATION_MARKS
-
COMMA
-
language
-
antiPatterns
-
-
Constructor Details
-
VerbAgreementRule
-
-
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
-
match
- Specified by:
matchin classTextLevelRule
-
match
-
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
-
nextButOneIsModal
-
isNear
private boolean isNear(int a, int b) - Returns:
- true if |a - b| invalid input: '<' 5, and a != -1
-
isQuotationMark
-
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
- 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
- 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
-
minToCheckParagraph
public int minToCheckParagraph()Description copied from class:TextLevelRuleGives 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:
minToCheckParagraphin classTextLevelRule
-