public abstract class AbstractPatternRule extends Rule
Modifier and Type | Field and Description |
---|---|
protected List<DisambiguationPatternRule> |
antiPatterns |
protected int |
endPositionCorrection |
protected RuleFilter |
filter |
protected String |
filterArgs |
protected Language |
language |
protected String |
message |
protected List<PatternToken> |
patternTokens |
protected boolean |
sentStart |
protected String |
sourceFile |
protected int |
startPositionCorrection |
protected String |
subId |
protected List<Match> |
suggestionMatches |
protected List<Match> |
suggestionMatchesOutMsg |
protected String |
suggestionsOutMsg |
protected boolean |
testUnification |
protected RuleMatch.Type |
type |
Modifier | Constructor and Description |
---|---|
protected |
AbstractPatternRule(String id,
String description,
Language language) |
|
AbstractPatternRule(String id,
String description,
Language language,
List<PatternToken> patternTokens,
boolean getUnified) |
|
AbstractPatternRule(String id,
String description,
Language language,
List<PatternToken> patternTokens,
boolean getUnified,
String message) |
Modifier and Type | Method and Description |
---|---|
void |
addSuggestionMatch(Match m)
Add formatted suggestion elements.
|
void |
addSuggestionMatchOutMsg(Match m)
Add formatted suggestion elements outside message.
|
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.
|
int |
getEndPositionCorrection() |
RuleFilter |
getFilter() |
String |
getFilterArguments() |
String |
getFullId()
The rule id and its sub id, if any.
|
String |
getId()
A string used to identify the rule in e.g. configuration files.
|
Language |
getLanguage() |
String |
getMessage()
Get the message shown to the user if this rule matches.
|
PatternRuleId |
getPatternRuleId()
The rule id and its sub id, if any.
|
List<PatternToken> |
getPatternTokens() |
String |
getSourceFile() |
int |
getStartPositionCorrection() |
String |
getSubId() |
String |
getSuggestionsOutMsg() |
RuleMatch.Type |
getType()
Determines the match type, based on the type variable if set (to allow overriding) or
Rule.getLocQualityIssueType() |
int |
getXmlLineNumber()
Returns the line in the XML file where this rule is located.
|
boolean |
isAdjustSuggestionCase()
Allows adjusting the behavior of uppercasing suggestions when the matched text started with an upper-case letter
|
boolean |
isGetUnified() |
boolean |
isGroupsOrUnification() |
boolean |
isSentStart() |
boolean |
isTestUnification() |
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 |
setAdjustSuggestionCase(boolean adjustSuggestionCase)
Allows adjusting the behavior of uppercasing suggestions when the matched text started with an upper-case letter
|
void |
setAntiPatterns(List<DisambiguationPatternRule> antiPatterns)
Set up the list of antipatterns used to immunize tokens, i.e., make them
non-matchable by the current rule.
|
void |
setEndPositionCorrection(int endPositionCorrection) |
void |
setFilter(RuleFilter filter) |
void |
setFilterArguments(String filterArgs) |
void |
setMessage(String message)
Set the message shown to the user if this rule matches.
|
void |
setStartPositionCorrection(int startPositionCorrection) |
void |
setSubId(String subId) |
void |
setType(RuleMatch.Type type)
Allows overriding the match type, otherwise determined by
Rule.getLocQualityIssueType() |
void |
setXmlLineNumber(int lineNumber) |
boolean |
supportsLanguage(Language language)
Whether this rule can be used for text in the given language.
|
String |
toString() |
addExamplePair, addTags, addToneTags, cacheAntiPatterns, estimateContextForSureMatch, getCategory, getConfigureText, getCorrectExamples, getDefaultValue, getDistanceTokens, getErrorTriggeringExamples, getIncorrectExamples, getLocQualityIssueType, getMaxConfigurableValue, getMinConfigurableValue, getMinPrevMatches, getSentenceWithImmunization, 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, toRuleMatchArray, useInOffice
protected final Language language
protected final List<PatternToken> patternTokens
protected final boolean testUnification
protected final boolean sentStart
protected List<DisambiguationPatternRule> antiPatterns
protected String subId
protected int startPositionCorrection
protected int endPositionCorrection
protected String suggestionsOutMsg
protected RuleFilter filter
protected String filterArgs
protected String message
protected String sourceFile
protected RuleMatch.Type type
public AbstractPatternRule(String id, String description, Language language, List<PatternToken> patternTokens, boolean getUnified, String message)
public AbstractPatternRule(String id, String description, Language language, List<PatternToken> patternTokens, boolean getUnified)
public boolean supportsLanguage(Language language)
Rule
PatternRule
s
(before, it used to always return false
for those).supportsLanguage
in class Rule
public String getDescription()
Rule
getDescription
in class Rule
@Nullable public String getSourceFile()
getSourceFile
in class Rule
public String getId()
Rule
A-Z
and the underscore.getId
in class Rule
getFullId()
public RuleMatch[] match(AnalyzedSentence sentence) throws IOException
Rule
match
in class Rule
sentence
- a pre-analyzed sentenceRuleMatch
objectsIOException
public final Language getLanguage()
public final void setStartPositionCorrection(int startPositionCorrection)
public final int getStartPositionCorrection()
public final void setEndPositionCorrection(int endPositionCorrection)
public final int getEndPositionCorrection()
public String getFullId()
RULE_ID[SUB_ID]
, e.g. WANT_TO[2]
.public PatternRuleId getPatternRuleId()
public final void setSubId(String subId)
public boolean isGroupsOrUnification()
public boolean isGetUnified()
public boolean isSentStart()
public boolean isTestUnification()
public List<PatternToken> getPatternTokens()
public final void addSuggestionMatch(Match m)
public final void addSuggestionMatchOutMsg(Match m)
@NotNull public final String getSuggestionsOutMsg()
public final String getMessage()
public final void setMessage(String message)
public void setFilter(RuleFilter filter)
@Nullable public RuleFilter getFilter()
public void setFilterArguments(String filterArgs)
@Nullable public String getFilterArguments()
public void setAntiPatterns(List<DisambiguationPatternRule> antiPatterns)
antiPatterns
- A list of antiPatterns, implemented as DisambiguationPatternRule
.public final 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
@Nullable @Experimental public RuleMatch.Type getType()
Rule.getLocQualityIssueType()
@Experimental public void setType(RuleMatch.Type type)
Rule.getLocQualityIssueType()
type
- the desired match type@Experimental public boolean isAdjustSuggestionCase()
@Experimental public void setAdjustSuggestionCase(boolean adjustSuggestionCase)
public void setXmlLineNumber(int lineNumber)
public int getXmlLineNumber()
-1
if the line isn't known.