Package org.languagetool.rules
Class AbstractStatisticSentenceStyleRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.TextLevelRule
org.languagetool.rules.AbstractStatisticSentenceStyleRule
- Direct Known Subclasses:
ConjunctionAtBeginOfSentenceRule,PassiveSentenceRule,SentenceWithManRule,SentenceWithModalVerbRule
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractStatisticSentenceStyleRule(ResourceBundle messages, Language lang, UserConfig userConfig, int minPercent) AbstractStatisticSentenceStyleRule(ResourceBundle messages, Language lang, UserConfig userConfig, int minPercent, boolean defaultActive) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AnalyzedTokenReadingsconditionFulfilled(List<AnalyzedTokenReadings> tokens) 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 hintdoubleOverride, if value should be given in an other unity than percentprotected abstract booleanCondition to generate a hint related to the sentence (possibly including all exceptions)abstract Stringprotected abstract StringgetLimitMessage(int limit, double percent) Defines the message for hints which exceed the limitprivate intgetMinPercent(UserConfig userConfig, int minPercentDefault) intgive the user the possibility to configure the functionintprotected booleanisMark(AnalyzedTokenReadings token) protected booleanmatch(List<AnalyzedSentence> sentences) intGives back the minimum number of paragraphs to check to give back a correct result.voidsetWithoutDirectSpeech(boolean withoutDirectSpeech) 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, getDescription, getDistanceTokens, getErrorTriggeringExamples, getFullId, getId, 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
-
MARKS_REGEX
-
DEFAULT_ACTIVATION
private static final boolean DEFAULT_ACTIVATION- See Also:
-
minPercent
private final int minPercent -
defaultMinPercent
private final int defaultMinPercent -
sentenceCount
private int sentenceCount -
numMatches
private int numMatches -
withoutDirectSpeech
private boolean withoutDirectSpeech
-
-
Constructor Details
-
AbstractStatisticSentenceStyleRule
public AbstractStatisticSentenceStyleRule(ResourceBundle messages, Language lang, UserConfig userConfig, int minPercent, boolean defaultActive) -
AbstractStatisticSentenceStyleRule
public AbstractStatisticSentenceStyleRule(ResourceBundle messages, Language lang, UserConfig userConfig, int minPercent)
-
-
Method Details
-
conditionFulfilled
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 -
excludeDirectSpeech
protected abstract boolean excludeDirectSpeech()Condition to generate a hint related to the sentence (possibly including all exceptions) -
getLimitMessage
Defines the message for hints which exceed the limit -
getConfigureText
-
getMinPercent
-
isMark
-
isOpeningQuote
-
denominator
public double denominator()Override, if value should be given in an other unity than percent -
getRuleOptions
give the user the possibility to configure the function- Overrides:
getRuleOptionsin classRule
-
getSentenceCount
public int getSentenceCount() -
getNumberOfMatches
public int getNumberOfMatches() -
setWithoutDirectSpeech
public void setWithoutDirectSpeech(boolean withoutDirectSpeech) -
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
-