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
-
-
Field Summary
Fields Modifier and Type Field Description private Languagelangprivate LinguServiceslinguServicesprivate static intMAX_TOKEN_TO_CHECKprotected intmaxDistanceOfSentences
-
Constructor Summary
Constructors Constructor Description AbstractStyleRepeatedWordRule(java.util.ResourceBundle messages, Language lang, UserConfig userConfig)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetConfigureText()Overwrite this to define the Text in the option panel for the configurable valueintgetDefaultValue()Overwrite this to get a default Integer value by option paneljava.lang.StringgetDescription()A short description of the error this rule can detect, usually in the language of the text that is checked.java.lang.StringgetId()Override this ID by adding a language acronym (e.g.intgetMaxConfigurableValue()Overwrite this to define the maximum of a configurable valueintgetMinConfigurableValue()Overwrite this to define the minimum of a configurable valuejava.util.List<java.lang.String>getSynonyms(AnalyzedTokenReadings token)get synonyms for a repeated wordprivate static booleanhasBreakToken(AnalyzedTokenReadings[] tokens)booleanhasConfigurableValue()Overwrite this to return true, if a value may be configured by option panelprotected booleanisPartOfWord(java.lang.String testTokenText, java.lang.String tokenText)private booleanisTokenInSentence(AnalyzedTokenReadings testToken, AnalyzedTokenReadings[] tokens)private booleanisTokenInSentence(AnalyzedTokenReadings testToken, AnalyzedTokenReadings[] tokens, int notCheck)protected abstract booleanisTokenPair(AnalyzedTokenReadings[] tokens, int n, boolean before)protected abstract booleanisTokenToCheck(AnalyzedTokenReadings token)RuleMatch[]match(java.util.List<AnalyzedSentence> sentences)protected abstract java.lang.StringmessageSameSentence()protected abstract java.lang.StringmessageSentenceAfter()protected abstract java.lang.StringmessageSentenceBefore()intminToCheckParagraph()Gives back the minimum number of paragraphs to check to give back a correct result.protected java.net.URLsetURL(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
-
-
-
-
Field Detail
-
MAX_TOKEN_TO_CHECK
private static final int MAX_TOKEN_TO_CHECK
- See Also:
- Constant Field Values
-
linguServices
private final LinguServices linguServices
-
lang
private final Language lang
-
maxDistanceOfSentences
protected int maxDistanceOfSentences
-
-
Constructor Detail
-
AbstractStyleRepeatedWordRule
public AbstractStyleRepeatedWordRule(java.util.ResourceBundle messages, Language lang, UserConfig userConfig)
-
-
Method Detail
-
getId
public java.lang.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 java.lang.String 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
-
messageSameSentence
protected abstract java.lang.String messageSameSentence()
-
messageSentenceBefore
protected abstract java.lang.String messageSentenceBefore()
-
messageSentenceAfter
protected abstract java.lang.String messageSentenceAfter()
-
getDefaultValue
public int getDefaultValue()
Description copied from class:RuleOverwrite this to get a default Integer value by option panel- Overrides:
getDefaultValuein classRule
-
hasConfigurableValue
public boolean hasConfigurableValue()
Description copied from class:RuleOverwrite this to return true, if a value may be configured by option panel- Overrides:
hasConfigurableValuein classRule- Since:
- 4.2
-
getMinConfigurableValue
public int getMinConfigurableValue()
Description copied from class:RuleOverwrite this to define the minimum of a configurable value- Overrides:
getMinConfigurableValuein classRule- Since:
- 4.2
-
getMaxConfigurableValue
public int getMaxConfigurableValue()
Description copied from class:RuleOverwrite this to define the maximum of a configurable value- Overrides:
getMaxConfigurableValuein classRule- Since:
- 4.2
-
getConfigureText
public java.lang.String getConfigureText()
Description copied from class:RuleOverwrite this to define the Text in the option panel for the configurable value- Overrides:
getConfigureTextin classRule- Since:
- 4.2
-
isTokenToCheck
protected abstract boolean isTokenToCheck(AnalyzedTokenReadings token)
-
isTokenPair
protected abstract boolean isTokenPair(AnalyzedTokenReadings[] tokens, int n, boolean before)
-
hasBreakToken
private static boolean hasBreakToken(AnalyzedTokenReadings[] tokens)
-
isTokenInSentence
private boolean isTokenInSentence(AnalyzedTokenReadings testToken, AnalyzedTokenReadings[] tokens)
-
isPartOfWord
protected boolean isPartOfWord(java.lang.String testTokenText, java.lang.String tokenText)
-
setURL
protected java.net.URL setURL(AnalyzedTokenReadings token) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getSynonyms
public java.util.List<java.lang.String> getSynonyms(AnalyzedTokenReadings token)
get synonyms for a repeated word
-
isTokenInSentence
private boolean isTokenInSentence(AnalyzedTokenReadings testToken, AnalyzedTokenReadings[] tokens, int notCheck)
-
match
public RuleMatch[] match(java.util.List<AnalyzedSentence> sentences) throws java.io.IOException
- Specified by:
matchin classTextLevelRule- Throws:
java.io.IOException
-
minToCheckParagraph
public int minToCheckParagraph()
Description copied from class:TextLevelRuleGives 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:
minToCheckParagraphin classTextLevelRule
-
-