public abstract class ConfusionProbabilityRule extends Rule
confusion_sets.txt
) suits best.
Also see https://dev.languagetool.org/finding-errors-using-n-gram-data.Modifier and Type | Field and Description |
---|---|
static float |
MIN_COVERAGE |
static String |
RULE_ID
Deprecated.
not used anymore, the id is now more specific (like
CONFUSION_RULE_TERM1_TERM2 ) |
Constructor and Description |
---|
ConfusionProbabilityRule(ResourceBundle messages,
LanguageModel languageModel,
Language language) |
ConfusionProbabilityRule(ResourceBundle messages,
LanguageModel languageModel,
Language language,
int grams) |
ConfusionProbabilityRule(ResourceBundle messages,
LanguageModel languageModel,
Language language,
int grams,
List<String> exceptions) |
ConfusionProbabilityRule(ResourceBundle messages,
LanguageModel languageModel,
Language language,
int grams,
List<String> exceptions,
List<List<PatternToken>> antiPatterns) |
Modifier and Type | Method and Description |
---|---|
int |
estimateContextForSureMatch()
A number that estimates how many words there must be after a match before we
can be (relatively) sure the match is valid.
|
List<DisambiguationPatternRule> |
getAntiPatterns()
Overwrite this to avoid false alarms by ignoring these patterns -
note that your
Rule.match(AnalyzedSentence) method needs to
call Rule.getSentenceWithImmunization(org.languagetool.AnalyzedSentence) for this to be used
and you need to check AnalyzedTokenReadings.isImmunized() |
String |
getDescription()
A short description of the error this rule can detect, usually in the language of the text
that is checked.
|
protected List<String> |
getFilenames() |
String |
getId()
A string used to identify the rule in e.g. configuration files.
|
protected String |
getMessage(ConfusionString textString,
ConfusionString suggestion) |
int |
getNGrams()
Returns the ngram level used, typically 3.
|
protected boolean |
isCommonWord(String token) |
protected boolean |
isException(String sentenceText,
int startPos,
int endPos)
Return true to prevent a match.
|
RuleMatch[] |
match(AnalyzedSentence sentence)
Check whether the given sentence matches this error rule, i.e. whether it
contains the error detected by this rule.
|
void |
setConfusionPair(ConfusionPair pair)
Deprecated.
used only for tests
|
addExamplePair, addTags, addToneTags, cacheAntiPatterns, getCategory, getConfigureText, getCorrectExamples, getDefaultValue, getDistanceTokens, getErrorTriggeringExamples, getFullId, getIncorrectExamples, getLocQualityIssueType, getMaxConfigurableValue, getMinConfigurableValue, getMinPrevMatches, getSentenceWithImmunization, getSourceFile, getSubId, getTags, getToneTags, getUrl, hasConfigurableValue, hasTag, hasToneTag, isDefaultOff, isDefaultTempOff, isDictionaryBasedSpellingRule, isGoalSpecific, isOfficeDefaultOff, isOfficeDefaultOn, isPremium, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setDistanceTokens, setErrorTriggeringExamples, setExamplePair, setGoalSpecific, setIncorrectExamples, setLocQualityIssueType, setMinPrevMatches, setOfficeDefaultOff, setOfficeDefaultOn, setPremium, setTags, setToneTags, setUrl, supportsLanguage, toRuleMatchArray, useInOffice
public static final String RULE_ID
CONFUSION_RULE_TERM1_TERM2
)public static final float MIN_COVERAGE
public ConfusionProbabilityRule(ResourceBundle messages, LanguageModel languageModel, Language language)
public ConfusionProbabilityRule(ResourceBundle messages, LanguageModel languageModel, Language language, int grams)
public ConfusionProbabilityRule(ResourceBundle messages, LanguageModel languageModel, Language language, int grams, List<String> exceptions)
public ConfusionProbabilityRule(ResourceBundle messages, LanguageModel languageModel, Language language, int grams, List<String> exceptions, List<List<PatternToken>> antiPatterns)
public String getId()
Rule
A-Z
and the underscore.public int estimateContextForSureMatch()
Rule
-1
when the sentence needs to end to be sure there's a match.estimateContextForSureMatch
in class Rule
public RuleMatch[] match(AnalyzedSentence sentence)
Rule
protected boolean isCommonWord(String token)
protected boolean isException(String sentenceText, int startPos, int endPos)
public String getDescription()
Rule
getDescription
in class Rule
protected String getMessage(ConfusionString textString, ConfusionString suggestion)
public void setConfusionPair(ConfusionPair pair)
public int getNGrams()
public List<DisambiguationPatternRule> getAntiPatterns()
Rule
Rule.match(AnalyzedSentence)
method needs to
call Rule.getSentenceWithImmunization(org.languagetool.AnalyzedSentence)
for this to be used
and you need to check AnalyzedTokenReadings.isImmunized()
getAntiPatterns
in class Rule