Class AbstractStatisticStyleRule

java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.TextLevelRule
org.languagetool.rules.AbstractStatisticStyleRule
Direct Known Subclasses:
AbstractFillerWordsRule, GermanFillerWordsRule, NonSignificantVerbsRule, UnnecessaryPhraseRule

public abstract class AbstractStatisticStyleRule extends TextLevelRule
A rule that gives hints when a defined condition is fulfilled and the percentage of hints in the text exceeds the given limit. (For office extension: Works on the level of chapters) A limit of 0 shows all hints. Direct speech or citation can be excluded. A second condition per sentences can be defined. The rule detects no grammar error but gives stylistic hints in a statistic way (default off).
Since:
5.3
  • Field Details

    • OPENING_QUOTES

      private static final Pattern OPENING_QUOTES
    • ENDING_QUOTES

      private static final Pattern ENDING_QUOTES
    • DEFAULT_ACTIVATION

      private static final boolean DEFAULT_ACTIVATION
      See Also:
    • minPercent

      private final int minPercent
    • defaultMinPercent

      private final int defaultMinPercent
    • wordCount

      private int wordCount
    • numMatches

      private int numMatches
    • withoutDirectSpeech

      private boolean withoutDirectSpeech
    • excludeDirectSpeech

      private boolean excludeDirectSpeech
  • Constructor Details

  • Method Details

    • conditionFulfilled

      protected abstract int conditionFulfilled(AnalyzedTokenReadings[] tokens, int nAnalysedToken)
      Condition to generate a hint (possibly including all exceptions) Returns: < nAnalysedToken, if condition is not fulfilled >= nAnalysedToken, if condition is not fulfilled; integer is number of token which is the end hint
    • sentenceConditionFulfilled

      protected abstract boolean sentenceConditionFulfilled(AnalyzedTokenReadings[] tokens, int nAnalysedToken)
      Condition to generate a hint related to the sentence (possibly including all exceptions)
    • excludeDirectSpeech

      protected abstract boolean excludeDirectSpeech()
      Condition to generate a hint related to the sentence (possibly including all exceptions)
    • getLimitMessage

      protected abstract String getLimitMessage(int limit, double percent)
      Defines the message for hints which exceed the limit
    • getSentenceMessage

      protected abstract String getSentenceMessage()
      Defines the message for sentence related hints
    • getConfigurePercentText

      public abstract String getConfigurePercentText()
    • getConfigureWithoutDirectSpeachText

      public abstract String getConfigureWithoutDirectSpeachText()
    • getMinPercent

      private int getMinPercent(UserConfig userConfig, int minPercentDefault)
    • getExcludeDirectSpeech

      private boolean getExcludeDirectSpeech(UserConfig userConfig)
    • denominator

      public double denominator()
      Override, if value should be given in an other unity than percent
    • getRuleOptions

      public RuleOption[] getRuleOptions()
      give the user the possibility to configure the function
      Overrides:
      getRuleOptions in class Rule
    • getWordCount

      public int getWordCount()
    • getNumberOfMatches

      public int getNumberOfMatches()
    • setWithoutDirectSpeech

      public void setWithoutDirectSpeech(boolean withoutDirectSpeech)
    • match

      public RuleMatch[] match(List<AnalyzedSentence> sentences) throws IOException
      Specified by:
      match in class TextLevelRule
      Throws:
      IOException
    • minToCheckParagraph

      public int minToCheckParagraph()
      Description copied from class: TextLevelRule
      Gives 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:
      minToCheckParagraph in class TextLevelRule