Class CaseRule

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

public class CaseRule extends Rule
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 Details

    • NUMERALS_EN

      private static final Pattern NUMERALS_EN
    • TWO_UPPERCASE_CHARS

      private static final Pattern TWO_UPPERCASE_CHARS
    • nounIndicators

      private static final Set<String> nounIndicators
    • UPPERCASE_MESSAGE

      private static final String UPPERCASE_MESSAGE
      See Also:
    • LOWERCASE_MESSAGE

      private static final String LOWERCASE_MESSAGE
      See Also:
    • COLON_MESSAGE

      private static final String COLON_MESSAGE
      See Also:
    • VERHALTEN

      private static final Pattern VERHALTEN
    • IRGEND_ETC

      private static final Pattern IRGEND_ETC
    • VER_MOD_AUX

      private static final Pattern VER_MOD_AUX
    • SENTENCE_START_EXCEPTIONS

      private static final String[] SENTENCE_START_EXCEPTIONS
    • UNDEFINED_QUANTIFIERS

      private static final String[] UNDEFINED_QUANTIFIERS
    • INTERROGATIVE_PARTICLES

      private static final String[] INTERROGATIVE_PARTICLES
    • POSSESSIVE_INDICATORS

      private static final String[] POSSESSIVE_INDICATORS
    • DAS_VERB_EXCEPTIONS

      private static final String[] DAS_VERB_EXCEPTIONS
    • exceptions

      private static final String[] exceptions
    • exceptionPatterns

      private static final Set<StringMatcher[]> exceptionPatterns
    • substVerbenExceptions

      private static final Set<String> substVerbenExceptions
    • antiPatterns

      private final Supplier<List<DisambiguationPatternRule>> antiPatterns
    • language

      private final German language
  • Constructor Details

  • 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
    • estimateContextForSureMatch

      public int estimateContextForSureMatch()
      Description copied from class: Rule
      A 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 -1 when the sentence needs to end to be sure there's a match.
      Overrides:
      estimateContextForSureMatch in class Rule
    • getUrl

      public URL getUrl()
      Description copied from class: Rule
      An optional URL describing the rule match in more detail. Typically points to a dictionary or grammar website with explanations and examples. Will return null for rules that have no URL.
      Overrides:
      getUrl 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
    • 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
    • getTokensWithPosTagStartingWithCount

      private int getTokensWithPosTagStartingWithCount(AnalyzedTokenReadings[] tokens, String partialPosTag)
    • isPotentialUpperCaseError

      private boolean isPotentialUpperCaseError(int pos, AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings lowercaseReadings, boolean isPrecededByModalOrAuxiliary)
    • 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
    • isPrevProbablyRelativePronoun

      private boolean isPrevProbablyRelativePronoun(AnalyzedTokenReadings[] tokens, int i)
    • isSalutation

      private boolean isSalutation(String token)
    • isCompany

      private boolean isCompany(String token)
    • isDot

      private boolean isDot(String token)
    • hasNounReading

      private boolean hasNounReading(AnalyzedTokenReadings readings)
    • 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

      private boolean followedByGenderGap(AnalyzedTokenReadings[] tokens, int i)
    • isCaseTypo

      private boolean isCaseTypo(String token)
    • isSingularImperative

      private boolean isSingularImperative(AnalyzedTokenReadings lowercaseReadings, AnalyzedTokenReadings token)
    • isNounWithVerbReading

      private boolean isNounWithVerbReading(int i, AnalyzedTokenReadings[] tokens)
    • isInvisibleSeparator

      private boolean isInvisibleSeparator(int i, AnalyzedTokenReadings[] tokens)
    • 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

      private boolean isNumbering(int i, AnalyzedTokenReadings[] tokens)
    • isEllipsis

      private boolean isEllipsis(int i, AnalyzedTokenReadings[] tokens)
    • isNominalization

      private boolean isNominalization(int i, AnalyzedTokenReadings[] tokens, String token, AnalyzedTokenReadings lowercaseReadings)
    • isNumber

      private boolean isNumber(String token)
    • isAdverbAndNominalization

      private boolean isAdverbAndNominalization(int i, AnalyzedTokenReadings[] tokens)
    • hasPartialTag

      private boolean hasPartialTag(AnalyzedTokenReadings token, String... posTags)
    • isSpecialCase

      private boolean isSpecialCase(int i, AnalyzedTokenReadings[] tokens)
    • isAdjectiveAsNoun

      private boolean isAdjectiveAsNoun(int i, AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings lowercaseReadings)
    • isLanguage

      private boolean isLanguage(int i, AnalyzedTokenReadings[] tokens, String token)
    • isProbablyCity

      private boolean isProbablyCity(int i, AnalyzedTokenReadings[] tokens, String token)
    • isFollowedByRelativeOrSubordinateClause

      private boolean isFollowedByRelativeOrSubordinateClause(int i, AnalyzedTokenReadings[] tokens)
    • isExceptionPhrase

      private boolean isExceptionPhrase(int i, AnalyzedTokenReadings[] tokens)
    • compareLists

      @VisibleForTesting static boolean compareLists(AnalyzedTokenReadings[] tokens, int startIndex, int endIndex, StringMatcher... patterns)
    • lookup

      private AnalyzedTokenReadings lookup(String word)