Package org.languagetool.rules
Class AbstractStyleRepeatedWordRule
- java.lang.Object
-
- org.languagetool.rules.Rule
-
- org.languagetool.rules.TextLevelRule
-
- org.languagetool.rules.AbstractStyleRepeatedWordRule
-
public abstract class AbstractStyleRepeatedWordRule extends TextLevelRule
An abstract rule checks the appearance of same words in a sentence or in two consecutive sentences. The isTokenToCheck method can be used to check only specific words (e.g. substantive, verbs and adjectives). This rule detects no grammar error but a stylistic problem (default off)- Since:
- 4.1
- Author:
- Fred Kruse
-
-
Field Summary
Fields Modifier and Type Field Description protected int
maxDistanceOfSentences
-
Constructor Summary
Constructors Constructor Description AbstractStyleRepeatedWordRule(ResourceBundle messages, Language lang, UserConfig userConfig)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
getConfigureText()
Overwrite this to define the Text in the option panel for the configurable valueint
getDefaultValue()
Overwrite this to get a default Integer value by option panelString
getDescription()
A short description of the error this rule can detect, usually in the language of the text that is checked.String
getId()
Override this ID by adding a language acronym (e.g.int
getMaxConfigurableValue()
Overwrite this to define the maximum of a configurable valueint
getMinConfigurableValue()
Overwrite this to define the minimum of a configurable valueList<String>
getSynonyms(AnalyzedTokenReadings token)
get synonyms for a repeated wordboolean
hasConfigurableValue()
Overwrite this to return true, if a value may be configured by option panelprotected boolean
isPartOfWord(String testTokenText, String tokenText)
protected abstract boolean
isTokenPair(AnalyzedTokenReadings[] tokens, int n, boolean before)
protected abstract boolean
isTokenToCheck(AnalyzedTokenReadings token)
RuleMatch[]
match(List<AnalyzedSentence> sentences)
protected abstract String
messageSameSentence()
protected abstract String
messageSentenceAfter()
protected abstract String
messageSentenceBefore()
int
minToCheckParagraph()
Gives back the minimum number of paragraphs to check to give back a correct result.protected URL
setURL(AnalyzedTokenReadings token)
-
Methods inherited from class org.languagetool.rules.TextLevelRule
estimateContextForSureMatch, match, match
-
Methods inherited from class org.languagetool.rules.Rule
addExamplePair, getAntiPatterns, getCategory, getCorrectExamples, getErrorTriggeringExamples, getIncorrectExamples, getLocQualityIssueType, getSentenceWithImmunization, getUrl, isDefaultOff, isDefaultTempOff, isDictionaryBasedSpellingRule, isOfficeDefaultOff, isOfficeDefaultOn, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setErrorTriggeringExamples, setIncorrectExamples, setLocQualityIssueType, setOfficeDefaultOff, setOfficeDefaultOn, setUrl, supportsLanguage, toRuleMatchArray, useInOffice
-
-
-
-
Constructor Detail
-
AbstractStyleRepeatedWordRule
public AbstractStyleRepeatedWordRule(ResourceBundle messages, Language lang, UserConfig userConfig)
-
-
Method Detail
-
getId
public String getId()
Override this ID by adding a language acronym (e.g. STYLE_REPEATED_WORD_RULE_DE) to use adjustment of maxWords by option panel
-
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 classRule
-
messageSameSentence
protected abstract String messageSameSentence()
-
messageSentenceBefore
protected abstract String messageSentenceBefore()
-
messageSentenceAfter
protected abstract String messageSentenceAfter()
-
getDefaultValue
public int getDefaultValue()
Description copied from class:Rule
Overwrite this to get a default Integer value by option panel- Overrides:
getDefaultValue
in classRule
-
hasConfigurableValue
public boolean hasConfigurableValue()
Description copied from class:Rule
Overwrite this to return true, if a value may be configured by option panel- Overrides:
hasConfigurableValue
in classRule
- Since:
- 4.2
-
getMinConfigurableValue
public int getMinConfigurableValue()
Description copied from class:Rule
Overwrite this to define the minimum of a configurable value- Overrides:
getMinConfigurableValue
in classRule
- Since:
- 4.2
-
getMaxConfigurableValue
public int getMaxConfigurableValue()
Description copied from class:Rule
Overwrite this to define the maximum of a configurable value- Overrides:
getMaxConfigurableValue
in classRule
- Since:
- 4.2
-
getConfigureText
public String getConfigureText()
Description copied from class:Rule
Overwrite this to define the Text in the option panel for the configurable value- Overrides:
getConfigureText
in classRule
- Since:
- 4.2
-
isTokenToCheck
protected abstract boolean isTokenToCheck(AnalyzedTokenReadings token)
-
isTokenPair
protected abstract boolean isTokenPair(AnalyzedTokenReadings[] tokens, int n, boolean before)
-
setURL
protected URL setURL(AnalyzedTokenReadings token) throws MalformedURLException
- Throws:
MalformedURLException
-
getSynonyms
public List<String> getSynonyms(AnalyzedTokenReadings token)
get synonyms for a repeated word
-
match
public RuleMatch[] match(List<AnalyzedSentence> sentences) throws IOException
- Specified by:
match
in classTextLevelRule
- 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 classTextLevelRule
-
-