Package org.languagetool.rules.de
Class CaseRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.de.CaseRule
Check that adjectives and verbs are not written with an uppercase
first letter (except at the start of a sentence) and cases
like this:
Das laufen fällt mir leicht. (laufen needs
to be uppercased).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Supplier<List<DisambiguationPatternRule>> private static final Stringprivate static final String[]private static final Set<StringMatcher[]> private static final String[]private static final String[]private static final Patternprivate final Germanprivate static final Stringprivate static final Patternprivate static final String[]private static final String[]private static final Patternprivate static final String[]private static final Stringprivate static final Patternprivate static final Pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddRuleMatch(List<RuleMatch> ruleMatches, AnalyzedSentence sentence, String msg, AnalyzedTokenReadings tokenReadings, String fixedWord) (package private) static booleancompareLists(AnalyzedTokenReadings[] tokens, int startIndex, int endIndex, StringMatcher... patterns) intA number that estimates how many words there must be after a match before we can be (relatively) sure the match is valid.private booleanfollowedByGenderGap(AnalyzedTokenReadings[] tokens, int i) Overwrite 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.private intgetTokensWithPosTagStartingWithCount(AnalyzedTokenReadings[] tokens, String partialPosTag) getUrl()An optional URL describing the rule match in more detail.private booleanhasNounReading(AnalyzedTokenReadings readings) private booleanhasPartialTag(AnalyzedTokenReadings token, String... posTags) private booleanisAdjectiveAsNoun(int i, AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings lowercaseReadings) private booleanisAdverbAndNominalization(int i, AnalyzedTokenReadings[] tokens) private booleanisCaseTypo(String token) private booleanprivate booleanprivate booleanisEllipsis(int i, AnalyzedTokenReadings[] tokens) private booleanisExceptionPhrase(int i, AnalyzedTokenReadings[] tokens) private booleanisFollowedByRelativeOrSubordinateClause(int i, AnalyzedTokenReadings[] tokens) private booleanisInvisibleSeparator(int i, AnalyzedTokenReadings[] tokens) private booleanisLanguage(int i, AnalyzedTokenReadings[] tokens, String token) private booleanisNominalization(int i, AnalyzedTokenReadings[] tokens, String token, AnalyzedTokenReadings lowercaseReadings) private booleanisNounWithVerbReading(int i, AnalyzedTokenReadings[] tokens) private booleanprivate booleanisNumbering(int i, AnalyzedTokenReadings[] tokens) private booleanisPotentialUpperCaseError(int pos, AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings lowercaseReadings, boolean isPrecededByModalOrAuxiliary) private booleanisPrevProbablyRelativePronoun(AnalyzedTokenReadings[] tokens, int i) private booleanisProbablyCity(int i, AnalyzedTokenReadings[] tokens, String token) private booleanisSalutation(String token) private booleanisSingularImperative(AnalyzedTokenReadings lowercaseReadings, AnalyzedTokenReadings token) private booleanisSpecialCase(int i, AnalyzedTokenReadings[] tokens) private booleanisVerbFollowing(int i, AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings lowercaseReadings) private AnalyzedTokenReadingsmatch(AnalyzedSentence sentence) Check whether the given sentence matches this error rule, i.e.private voidpotentiallyAddLowercaseMatch(List<RuleMatch> ruleMatches, AnalyzedTokenReadings tokenReadings, boolean prevTokenIsDas, String token, boolean nextTokenIsPersonalOrReflexivePronoun, AnalyzedSentence sentence) private voidpotentiallyAddUppercaseMatch(List<RuleMatch> ruleMatches, AnalyzedTokenReadings[] tokens, int i, AnalyzedTokenReadings analyzedToken, String token, AnalyzedTokenReadings lowercaseReadings, AnalyzedSentence sentence) Methods 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, 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
-
NUMERALS_EN
-
TWO_UPPERCASE_CHARS
-
nounIndicators
-
UPPERCASE_MESSAGE
- See Also:
-
LOWERCASE_MESSAGE
- See Also:
-
COLON_MESSAGE
- See Also:
-
VERHALTEN
-
IRGEND_ETC
-
VER_MOD_AUX
-
SENTENCE_START_EXCEPTIONS
-
UNDEFINED_QUANTIFIERS
-
INTERROGATIVE_PARTICLES
-
POSSESSIVE_INDICATORS
-
DAS_VERB_EXCEPTIONS
-
exceptions
-
exceptionPatterns
-
substVerbenExceptions
-
antiPatterns
-
language
-
-
Constructor Details
-
CaseRule
-
-
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. -
estimateContextForSureMatch
public int estimateContextForSureMatch()Description copied from class:RuleA number that estimates how many words there must be after a match before we can be (relatively) sure the match is valid. This is useful for check-as-you-type, where a match might occur and the word that gets typed next makes the match disappear (something one would obviously like to avoid). Note: this may over-estimate the real context size. Returns-1when the sentence needs to end to be sure there's a match.- Overrides:
estimateContextForSureMatchin classRule
-
getUrl
Description copied from class:RuleAn optional URL describing the rule match in more detail. Typically points to a dictionary or grammar website with explanations and examples. Will returnnullfor rules that have no URL. -
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
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
-
getTokensWithPosTagStartingWithCount
private int getTokensWithPosTagStartingWithCount(AnalyzedTokenReadings[] tokens, String partialPosTag) -
isPotentialUpperCaseError
private boolean isPotentialUpperCaseError(int pos, AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings lowercaseReadings, boolean isPrecededByModalOrAuxiliary) -
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
-
isPrevProbablyRelativePronoun
-
isSalutation
-
isCompany
-
isDot
-
hasNounReading
-
potentiallyAddLowercaseMatch
private void potentiallyAddLowercaseMatch(List<RuleMatch> ruleMatches, AnalyzedTokenReadings tokenReadings, boolean prevTokenIsDas, String token, boolean nextTokenIsPersonalOrReflexivePronoun, AnalyzedSentence sentence) -
potentiallyAddUppercaseMatch
private void potentiallyAddUppercaseMatch(List<RuleMatch> ruleMatches, AnalyzedTokenReadings[] tokens, int i, AnalyzedTokenReadings analyzedToken, String token, AnalyzedTokenReadings lowercaseReadings, AnalyzedSentence sentence) -
followedByGenderGap
-
isCaseTypo
-
isSingularImperative
private boolean isSingularImperative(AnalyzedTokenReadings lowercaseReadings, AnalyzedTokenReadings token) -
isNounWithVerbReading
-
isInvisibleSeparator
-
isVerbFollowing
private boolean isVerbFollowing(int i, AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings lowercaseReadings) -
addRuleMatch
private void addRuleMatch(List<RuleMatch> ruleMatches, AnalyzedSentence sentence, String msg, AnalyzedTokenReadings tokenReadings, String fixedWord) -
isNumbering
-
isEllipsis
-
isNominalization
private boolean isNominalization(int i, AnalyzedTokenReadings[] tokens, String token, AnalyzedTokenReadings lowercaseReadings) -
isNumber
-
isAdverbAndNominalization
-
hasPartialTag
-
isSpecialCase
-
isAdjectiveAsNoun
private boolean isAdjectiveAsNoun(int i, AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings lowercaseReadings) -
isLanguage
-
isProbablyCity
-
isFollowedByRelativeOrSubordinateClause
-
isExceptionPhrase
-
compareLists
@VisibleForTesting static boolean compareLists(AnalyzedTokenReadings[] tokens, int startIndex, int endIndex, StringMatcher... patterns) -
lookup
-