Package org.languagetool.rules
Class AbstractSimpleReplaceRule2
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.AbstractSimpleReplaceRule2
- Direct Known Subclasses:
AbstractCheckCaseRule,AmericanReplaceRule,ArabicDarjaRule,ArabicDiacriticsRule,ArabicHomophonesRule,ArabicInflectedOneWordReplaceRule,ArabicRedundancyRule,ArabicSimpleReplaceRule,ArabicTransVerbRule,ArabicWordinessRule,BrazilianPortugueseReplaceRule,BritishReplaceRule,EnglishDiacriticsRule,EnglishPlainEnglishRule,EnglishRedundancyRule,GalicianBarbarismsRule,GalicianRedundancyRule,GalicianWikipediaRule,GalicianWordinessRule,GreekRedundancyRule,KhmerSimpleReplaceRule,NewZealandReplaceRule,PortugalPortugueseReplaceRule,PortugueseArchaismsRule,PortugueseBarbarismsRule,PortugueseClicheRule,PortugueseDiacriticsRule,PortugueseRedundancyRule,PortugueseWeaselWordsRule,PortugueseWikipediaRule,PortugueseWordinessRule,ReplaceHomonymsRule,RussianSimpleReplaceRule,SimpleReplaceAnglicism,SimpleReplaceMultiwordsRule,SimpleReplaceProfanityRule,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceRule,SimpleReplaceRule,SpanishWikipediaRule
A rule that matches words which should not be used and suggests correct ones instead.
Unlike AbstractSimpleReplaceRule, it supports phrases (Ex: "aqua forte" -> "acvaforte").
Note: Merge this into AbstractSimpleReplaceRule
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprotected final Languageprivate intprivate static final intprivate Map<String, SuggestionWithMessage> private Map<String, SuggestionWithMessage> private booleanprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCreate a warning if a key word of the replacement rule is not allowed by the speller rule.booleanCreate a warning if a key word of the replacement rule is allowed by the speller rule.private voidcreateMatch(List<RuleMatch> ruleMatches, SuggestionWithMessage suggestionWithMessage, int startIndex, int endIndex, String originalStr, AnalyzedTokenReadings[] tokens, AnalyzedSentence sentence, int sentStart, int[] checkCaseCoveredUpto) private voidfillMaps(Map<String, Integer> mStartSpace, Map<String, Integer> mStartNoSpace, Map<String, SuggestionWithMessage> mFullSpace, Map<String, SuggestionWithMessage> mFullNoSpace) abstract StringA short description of the error this rule can detect, usually in the language of the text that is checked.getDescription(String details) Used if each input form the replacement file has its specific id.abstract StringgetId()A string used to identify the rule in e.g.abstract Localelocale used on case-conversionabstract Stringabstract StringgetShort()protected booleanprotected booleanisException(String matchedText) protected booleanprotected booleanisPunctuationStart(String word) protected booleanisRuleMatchException(RuleMatch ruleMatch) protected booleanprivate voidlazyInit()match(AnalyzedSentence sentence) Check whether the given sentence matches this error rule, i.e.booleanprotected voidsetIgnoreShortUppercaseWords(boolean value) protected voidsetRuleHasSuggestions(boolean value) 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
-
initialized
private volatile boolean initialized -
mStartSpace
-
mStartNoSpace
-
mFullSpace
-
mFullNoSpace
-
MAX_TOKENS_IN_MULTIWORD
private static final int MAX_TOKENS_IN_MULTIWORD- See Also:
-
ignoreShortUppercaseWords
private boolean ignoreShortUppercaseWords -
MAX_LENGTH_SHORT_WORDS
private int MAX_LENGTH_SHORT_WORDS -
ruleHasSuggestions
private boolean ruleHasSuggestions -
language
-
subRuleSpecificIds
protected boolean subRuleSpecificIds
-
-
Constructor Details
-
AbstractSimpleReplaceRule2
-
-
Method Details
-
isCheckingCase
protected boolean isCheckingCase() -
getFileNames
-
getFilePaths
-
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- Returns:
- A string where
$matchwill be replaced with the matching word.
-
getShort
-
getMessage
- Returns:
- A string where
$matchwill be replaced with the matching word and$suggestionswill be replaced with the alternatives. This is the string shown to the user.
-
getSuggestionsSeparator
- Returns:
- the word used to separate multiple suggestions; used only before last suggestion, the rest are comma-separated.
-
getLocale
locale used on case-conversion -
useSubRuleSpecificIds
public void useSubRuleSpecificIds()If this is set, each replacement pair will have its own rule ID, making rule deactivations more specific.- Since:
- 5.1
-
getCaseSensitivy
-
getDescription
Used if each input form the replacement file has its specific id. -
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. -
createMatch
private void createMatch(List<RuleMatch> ruleMatches, SuggestionWithMessage suggestionWithMessage, int startIndex, int endIndex, String originalStr, AnalyzedTokenReadings[] tokens, AnalyzedSentence sentence, int sentStart, int[] checkCaseCoveredUpto) -
isRuleMatchException
-
isException
-
isTokenException
-
checkKeyWordsAreKnownToSpeller
public boolean checkKeyWordsAreKnownToSpeller()Create a warning if a key word of the replacement rule is not allowed by the speller rule. -
checkKeyWordsAreUnknownToSpeller
public boolean checkKeyWordsAreUnknownToSpeller()Create a warning if a key word of the replacement rule is allowed by the speller rule. -
separateKeyWordsBySpeller
public boolean separateKeyWordsBySpeller() -
isPunctuationStart
-
lazyInit
private void lazyInit() -
fillMaps
-
getAllFilePaths
-
getWrongWords
-
isIgnoreShortUppercaseWords
protected boolean isIgnoreShortUppercaseWords() -
setIgnoreShortUppercaseWords
protected void setIgnoreShortUppercaseWords(boolean value) -
setRuleHasSuggestions
protected void setRuleHasSuggestions(boolean value)
-