Package org.languagetool.rules
Class LongSentenceRule
- java.lang.Object
-
- org.languagetool.rules.Rule
-
- org.languagetool.rules.LongSentenceRule
-
public class LongSentenceRule extends Rule
A rule that warns on long sentences. Note that this rule is off by default.
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
DEFAULT_ACTIVATION
private static int
DEFAULT_MAX_WORDS
protected int
maxWords
static java.lang.String
RULE_ID
-
Constructor Summary
Constructors Constructor Description LongSentenceRule(java.util.ResourceBundle messages, UserConfig userConfig)
Creates a rule with default values can be overwritten by configuration settingsLongSentenceRule(java.util.ResourceBundle messages, UserConfig userConfig, int defaultWords)
Creates a rule with default inactiveLongSentenceRule(java.util.ResourceBundle messages, UserConfig userConfig, int defaultWords, boolean defaultActive)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.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 paneljava.lang.String
getDescription()
A short description of the error this rule can detect, usually in the language of the text that is checked.java.lang.String
getId()
Override this ID by adding a language acronym (e.g.int
getMaxConfigurableValue()
Overwrite this to define the maximum of a configurable valuejava.lang.String
getMessage()
int
getMinConfigurableValue()
Overwrite this to define the minimum of a configurable valueboolean
hasConfigurableValue()
Overwrite this to return true, if a value may be configured by option panelRuleMatch[]
match(AnalyzedSentence sentence)
Check whether the given sentence matches this error rule, i.e.-
Methods inherited from class org.languagetool.rules.Rule
addExamplePair, estimateContextForSureMatch, 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
-
RULE_ID
public static final java.lang.String RULE_ID
- See Also:
- Constant Field Values
-
DEFAULT_MAX_WORDS
private static final int DEFAULT_MAX_WORDS
- See Also:
- Constant Field Values
-
DEFAULT_ACTIVATION
private static final boolean DEFAULT_ACTIVATION
- See Also:
- Constant Field Values
-
maxWords
protected int maxWords
-
-
Constructor Detail
-
LongSentenceRule
public LongSentenceRule(java.util.ResourceBundle messages, UserConfig userConfig, int defaultWords, boolean defaultActive)
- Since:
- 4.2
-
LongSentenceRule
public LongSentenceRule(java.util.ResourceBundle messages, UserConfig userConfig, int defaultWords)
Creates a rule with default inactive- Since:
- 4.2
-
LongSentenceRule
public LongSentenceRule(java.util.ResourceBundle messages, UserConfig userConfig)
Creates a rule with default values can be overwritten by configuration settings- Since:
- 4.2
-
-
Method Detail
-
getDescription
public java.lang.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
-
getId
public java.lang.String getId()
Override this ID by adding a language acronym (e.g. TOO_LONG_SENTENCE_DE) to use adjustment of maxWords by option panel
-
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 java.lang.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
-
getMessage
public java.lang.String getMessage()
-
match
public RuleMatch[] match(AnalyzedSentence sentence) throws java.io.IOException
Description copied from class:Rule
Check whether the given sentence matches this error rule, i.e. whether it contains the error detected by this rule. Note that the order in which this method is called is not always guaranteed, i.e. the sentence order in the text may be different than the order in which you get the sentences (this may be the case when LanguageTool is used as a LibreOffice/OpenOffice add-on, for example).
-
-