Package org.languagetool.rules
Class AbstractSimpleReplaceRule
- java.lang.Object
-
- org.languagetool.rules.Rule
-
- org.languagetool.rules.AbstractSimpleReplaceRule
-
public abstract class AbstractSimpleReplaceRule extends Rule
A rule that matches words which should not be used and suggests correct ones instead. Loads the relevant words fromrules/XX/replace.txt
, where XX is a code of the language.- Author:
- Andriy Rysin
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
ignoreTaggedWords
-
Constructor Summary
Constructors Constructor Description AbstractSimpleReplaceRule(ResourceBundle messages)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected RuleMatch
createRuleMatch(AnalyzedTokenReadings tokenReadings, List<String> replacements, AnalyzedSentence sentence)
protected List<RuleMatch>
findMatches(AnalyzedTokenReadings tokenReadings, AnalyzedSentence sentence)
String
getDescription()
A short description of the error this rule can detect, usually in the language of the text that is checked.String
getId()
A string used to identify the rule in e.g.Locale
getLocale()
String
getMessage(String tokenStr, List<String> replacements)
String
getShort()
protected abstract Map<String,List<String>>
getWrongWords()
boolean
isCaseSensitive()
Indicates if the rule is case-sensitive.boolean
isCheckLemmas()
protected boolean
isTagged(AnalyzedTokenReadings tokenReadings)
This method allows to override which tags will mark token as taggedprotected static Map<String,List<String>>
loadFromPath(String path)
RuleMatch[]
match(AnalyzedSentence sentence)
Check whether the given sentence matches this error rule, i.e.void
setCheckLemmas(boolean checkLemmas)
Used to disable matching lemmas.void
setIgnoreTaggedWords()
Skip words that are known in the POS tagging dictionary, assuming they cannot be incorrect.-
Methods inherited from class org.languagetool.rules.Rule
addExamplePair, estimateContextForSureMatch, getAntiPatterns, getCategory, getConfigureText, getCorrectExamples, getDefaultValue, getErrorTriggeringExamples, getIncorrectExamples, getLocQualityIssueType, getMaxConfigurableValue, getMinConfigurableValue, getSentenceWithImmunization, getUrl, hasConfigurableValue, isDefaultOff, isDefaultTempOff, isDictionaryBasedSpellingRule, isOfficeDefaultOff, isOfficeDefaultOn, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setErrorTriggeringExamples, setIncorrectExamples, setLocQualityIssueType, setOfficeDefaultOff, setOfficeDefaultOn, setUrl, supportsLanguage, toRuleMatchArray, useInOffice
-
-
-
-
Constructor Detail
-
AbstractSimpleReplaceRule
public AbstractSimpleReplaceRule(ResourceBundle messages)
-
-
Method Detail
-
isCaseSensitive
public boolean isCaseSensitive()
Indicates if the rule is case-sensitive. Default value istrue
.- Returns:
- true if the rule is case-sensitive, false otherwise.
-
getLocale
public Locale getLocale()
- Returns:
- the locale used for case conversion when
isCaseSensitive()
is set tofalse
.
-
setIgnoreTaggedWords
public void setIgnoreTaggedWords()
Skip words that are known in the POS tagging dictionary, assuming they cannot be incorrect.- Since:
- 2.3
-
getId
public String getId()
Description copied from class:Rule
A string used to identify the rule in e.g. configuration files. This string is supposed to be unique and to stay the same in all upcoming versions of LanguageTool. It's supposed to contain only the charactersA-Z
and the underscore.
-
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
-
getShort
public String getShort()
-
match
public RuleMatch[] match(AnalyzedSentence sentence)
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).
-
findMatches
protected List<RuleMatch> findMatches(AnalyzedTokenReadings tokenReadings, AnalyzedSentence sentence)
-
isTagged
protected boolean isTagged(AnalyzedTokenReadings tokenReadings)
This method allows to override which tags will mark token as tagged- Returns:
- returns true if token has valid tag
-
createRuleMatch
protected RuleMatch createRuleMatch(AnalyzedTokenReadings tokenReadings, List<String> replacements, AnalyzedSentence sentence)
-
isCheckLemmas
public boolean isCheckLemmas()
- Since:
- 2.5
-
setCheckLemmas
public void setCheckLemmas(boolean checkLemmas)
Used to disable matching lemmas.- Since:
- 2.5
-
-