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.
-
-
Constructor Summary
Constructors Constructor Description LongSentenceRule(ResourceBundle messages, UserConfig userConfig)
Creates a rule with default values can be overwritten by configuration settingsLongSentenceRule(ResourceBundle messages, UserConfig userConfig, int defaultWords)
Creates a rule with default inactiveLongSentenceRule(ResourceBundle messages, UserConfig userConfig, int defaultWords, boolean defaultActive)
-
Method Summary
All Methods Instance 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 valueString
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 String RULE_ID
- See Also:
- Constant Field Values
-
maxWords
protected int maxWords
-
-
Constructor Detail
-
LongSentenceRule
public LongSentenceRule(ResourceBundle messages, UserConfig userConfig, int defaultWords, boolean defaultActive)
- Since:
- 4.2
-
LongSentenceRule
public LongSentenceRule(ResourceBundle messages, UserConfig userConfig, int defaultWords)
Creates a rule with default inactive- Since:
- 4.2
-
LongSentenceRule
public LongSentenceRule(ResourceBundle messages, UserConfig userConfig)
Creates a rule with default values can be overwritten by configuration settings- Since:
- 4.2
-
-
Method Detail
-
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
-
getId
public 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 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 String getMessage()
-
match
public RuleMatch[] match(AnalyzedSentence sentence) throws 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).- Specified by:
match
in classRule
- Parameters:
sentence
- a pre-analyzed sentence- Returns:
- an array of
RuleMatch
objects - Throws:
IOException
-
-