Package org.languagetool.rules
Class AbstractStyleRepeatedWordRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.TextLevelRule
org.languagetool.rules.AbstractStyleRepeatedWordRule
- Direct Known Subclasses:
GermanStyleRepeatedWordRule
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
FieldsModifier and TypeFieldDescriptionprivate static final Patternprivate static final booleanprotected booleanprotected final Languageprotected final LinguServicesprivate static final intprivate static final intprotected intprivate static final Patternprivate static final Pattern -
Constructor Summary
ConstructorsConstructorDescriptionAbstractStyleRepeatedWordRule(ResourceBundle messages, Language lang, UserConfig userConfig) -
Method Summary
Modifier and TypeMethodDescriptionA short description of the error this rule can detect, usually in the language of the text that is checked.getId()Override this ID by adding a language acronym (e.g.give the user the possibility to configure the functionprivate booleangetStartsWithDirectSpeech(int n, List<AnalyzedSentence> sentences, boolean isDirectSpeech) private static booleanhasBreakToken(AnalyzedTokenReadings[] tokens) protected booleanisExceptionPair(AnalyzedTokenReadings token1, AnalyzedTokenReadings token2) private booleanisInQuotes(AnalyzedTokenReadings[] tokens, int i) protected booleanisPartOfWord(String testTokenText, String tokenText) private static booleanisQuestionResponse(int nAct, int nTest, List<AnalyzedTokenReadings[]> tokenList) private booleanisTokenInSentence(AnalyzedTokenReadings testToken, AnalyzedTokenReadings[] tokens, boolean isDirectSpeech) private booleanisTokenInSentence(AnalyzedTokenReadings testToken, AnalyzedTokenReadings[] tokens, int notCheck, boolean isDirectSpeech) protected abstract booleanisTokenPair(AnalyzedTokenReadings[] tokens, int n, boolean before) protected abstract booleanmatch(List<AnalyzedSentence> sentences) protected abstract Stringprotected abstract Stringprotected abstract StringintGives back the minimum number of paragraphs to check to give back a correct result.protected URLsetURL(AnalyzedTokenReadings token) Methods inherited from class org.languagetool.rules.TextLevelRule
estimateContextForSureMatch, match, matchMethods inherited from class org.languagetool.rules.Rule
addExamplePair, addTags, addToneTags, cacheAntiPatterns, getAntiPatterns, getCategory, getCorrectExamples, getDistanceTokens, getErrorTriggeringExamples, getFullId, getIncorrectExamples, getLocQualityIssueType, getMinPrevMatches, getPriority, getSentenceWithImmunization, getSourceFile, getSubId, getTags, getToneTags, getUrl, hasTag, hasToneTag, isDefaultOff, isDefaultTempOff, isDictionaryBasedSpellingRule, isGoalSpecific, isIncludedInHiddenMatches, isOfficeDefaultOff, isOfficeDefaultOn, isPremium, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setDistanceTokens, setErrorTriggeringExamples, setExamplePair, setGoalSpecific, setIncludedInHiddenMatches, setIncorrectExamples, setLocQualityIssueType, setMinPrevMatches, setOfficeDefaultOff, setOfficeDefaultOn, setPremium, setPriority, setTags, setToneTags, setUrl, supportsLanguage, toRuleMatchArray, useInOffice
-
Field Details
-
OPENING_QUOTES
-
ENDING_QUOTES
-
SINGLE_QUOTES
-
MAX_TOKEN_TO_CHECK
private static final int MAX_TOKEN_TO_CHECK- See Also:
-
MAX_DISTANCE_OF_SENTENCES
private static final int MAX_DISTANCE_OF_SENTENCES- See Also:
-
EXCLUDE_DIRECT_SPEECH
private static final boolean EXCLUDE_DIRECT_SPEECH- See Also:
-
linguServices
-
lang
-
maxDistanceOfSentences
protected int maxDistanceOfSentences -
excludeDirectSpeech
protected boolean excludeDirectSpeech
-
-
Constructor Details
-
AbstractStyleRepeatedWordRule
-
-
Method Details
-
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
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
-
messageSentenceBefore
-
messageSentenceAfter
-
getRuleOptions
give the user the possibility to configure the function- Overrides:
getRuleOptionsin classRule
-
isTokenToCheck
-
isTokenPair
-
hasBreakToken
-
isQuestionResponse
private static boolean isQuestionResponse(int nAct, int nTest, List<AnalyzedTokenReadings[]> tokenList) -
isTokenInSentence
private boolean isTokenInSentence(AnalyzedTokenReadings testToken, AnalyzedTokenReadings[] tokens, boolean isDirectSpeech) -
isPartOfWord
-
isExceptionPair
-
setURL
- Throws:
MalformedURLException
-
isTokenInSentence
private boolean isTokenInSentence(AnalyzedTokenReadings testToken, AnalyzedTokenReadings[] tokens, int notCheck, boolean isDirectSpeech) -
isInQuotes
-
getStartsWithDirectSpeech
private boolean getStartsWithDirectSpeech(int n, List<AnalyzedSentence> sentences, boolean isDirectSpeech) -
match
- Specified by:
matchin classTextLevelRule- Throws:
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
-