Class AbstractStyleTooOftenUsedWordRule

java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.TextLevelRule
org.languagetool.rules.AbstractStyleTooOftenUsedWordRule
Direct Known Subclasses:
StyleTooOftenUsedAdjectiveRule, StyleTooOftenUsedAdjectiveRule, StyleTooOftenUsedNounRule, StyleTooOftenUsedNounRule, StyleTooOftenUsedVerbRule, StyleTooOftenUsedVerbRule

public abstract class AbstractStyleTooOftenUsedWordRule extends TextLevelRule
The method gives stylistic hints that a word is being used too often when the set percentage has been exceeded.(default off).
Since:
6.2.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:
    • MIN_WORD_COUNT

      private static final int MIN_WORD_COUNT
      See Also:
    • minPercent

      private final int minPercent
    • defaultMinPercent

      private final int defaultMinPercent
    • wordMap

      private final Map<String,Integer> wordMap
    • withoutDirectSpeech

      private boolean withoutDirectSpeech
  • Constructor Details

    • AbstractStyleTooOftenUsedWordRule

      public AbstractStyleTooOftenUsedWordRule(ResourceBundle messages, Language lang, UserConfig userConfig, int minPercent)
    • AbstractStyleTooOftenUsedWordRule

      public AbstractStyleTooOftenUsedWordRule(ResourceBundle messages, Language lang, UserConfig userConfig, int minPercent, boolean defaultActive)
  • Method Details

    • isToCountedWord

      protected abstract boolean isToCountedWord(AnalyzedTokenReadings token)
      A token that has to be counted
    • isException

      protected abstract boolean isException(AnalyzedTokenReadings[] tokens, int n)
      An exception is defined for the token
    • toAddedLemma

      protected abstract String toAddedLemma(AnalyzedTokenReadings token)
      Gives back the lemma that should be added to the word map
    • getLimitMessage

      protected abstract String getLimitMessage(int minPercent)
      Defines the message for hints which exceed the limit
    • getConfigureText

      public abstract String getConfigureText()
    • getMinPercent

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

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

      public Map<String,Integer> getWordMap()
    • setWithoutDirectSpeech

      public void setWithoutDirectSpeech(boolean withoutDirectSpeech)
    • FillWordMap

      private void FillWordMap(List<AnalyzedSentence> sentences)
      fill the map with all words and the number of occurrence
    • getTooOftenUsedWords

      private List<String> getTooOftenUsedWords()
      get all words that are used more often than minPercent
    • 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
    • getLemmaForPosTagStartsWith

      protected String getLemmaForPosTagStartsWith(String startPos, AnalyzedTokenReadings token)