Package org.languagetool.rules
Class AbstractSimpleReplaceRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.AbstractSimpleReplaceRule
- Direct Known Subclasses:
AbstractSimpleReplaceLemmasRule,CastWordsRule,ContractionSpellingRule,DativePluralStandardReplaceRule,EnglishContractionSpellingRule,EnglishHomophoneRule,IrishFGBEqReplaceRule,IrishReplaceRule,LogainmRule,PeopleRule,PortugueseAgreementReplaceRule,PortugueseOrthographyReplaceRule,PortugueseReplaceRule,PrestandardReplaceRule,ReplaceOperationNamesRule,SimpleReplaceAdverbsMent,SimpleReplaceBalearicRule,SimpleReplaceDiacriticsIEC,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceSoftRule,SimpleReplaceSpelling1992Rule,SimpleReplaceVerbsRule,SimpleReplaceVerbsRule,SpacesRule
A rule that matches words which should not be used and suggests
correct ones instead. Loads the relevant words from
rules/XX/replace.txt, where XX is a code of the language.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprotected booleanprivate final Languageprivate static final org.slf4j.Loggerprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Stringprotected RuleMatchcreateRuleMatch(AnalyzedTokenReadings tokenReadings, List<String> replacements, AnalyzedSentence sentence, String originalTokenStr) findMatches(AnalyzedTokenReadings tokenReadings, AnalyzedSentence sentence) A short description of the error this rule can detect, usually in the language of the text that is checked.getId()A string used to identify the rule in e.g.getMessage(String tokenStr, List<String> replacements) getShort()Synthesizer to generate inflected suggestionsbooleanIndicates if the rule is case-sensitive.booleanprotected booleanisTagged(AnalyzedTokenReadings tokenReadings) This method allows to override which tags will mark token as taggedprotected booleanloadFromPath(String path) loadFromPath(String... paths) match(AnalyzedSentence sentence) Check whether the given sentence matches this error rule, i.e.voidsetCheckLemmas(boolean checkLemmas) Used to disable matching lemmas.voidSkip words that are known in the POS tagging dictionary, assuming they cannot be incorrect.voidIf this is set, each replacement pair will have its own rule ID, making rule deactivations more specific.Methods inherited from class org.languagetool.rules.Rule
addExamplePair, addTags, addToneTags, cacheAntiPatterns, estimateContextForSureMatch, getAntiPatterns, getCategory, getCorrectExamples, getDistanceTokens, getErrorTriggeringExamples, getFullId, getIncorrectExamples, getLocQualityIssueType, getMinPrevMatches, getPriority, getRuleOptions, 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
-
ignoreTaggedWords
protected boolean ignoreTaggedWords -
subRuleSpecificIds
protected boolean subRuleSpecificIds -
logger
private static final org.slf4j.Logger logger -
checkLemmas
private boolean checkLemmas -
language
-
-
Constructor Details
-
AbstractSimpleReplaceRule
-
-
Method Details
-
getWrongWords
-
loadFromPath
-
loadFromPath
- Since:
- 5.0
-
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
- 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
Description copied from class:RuleA 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-Zand the underscore. -
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
-
getMessage
-
getShort
-
cleanup
-
match
Description copied from class:RuleCheck 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 from 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). In other words, implementations must be stateless, so that a previous call to this method has no influence on later calls.- Specified by:
matchin classRule- Parameters:
sentence- a pre-analyzed sentence- Returns:
- an array of
RuleMatchobjects - Throws:
IOException
-
findMatches
protected List<RuleMatch> findMatches(AnalyzedTokenReadings tokenReadings, AnalyzedSentence sentence) throws IOException - Throws:
IOException
-
isTagged
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, String originalTokenStr) -
isCheckLemmas
public boolean isCheckLemmas()- Since:
- 2.5
-
setCheckLemmas
public void setCheckLemmas(boolean checkLemmas) Used to disable matching lemmas.- Since:
- 2.5
-
getSynthesizer
Synthesizer to generate inflected suggestions- Since:
- 5.1
-
isTokenException
-
useSubRuleSpecificIds
public void useSubRuleSpecificIds()If this is set, each replacement pair will have its own rule ID, making rule deactivations more specific.- Since:
- 5.5
-