Package org.languagetool.rules
Class RuleMatch
java.lang.Object
org.languagetool.rules.RuleMatch
- All Implemented Interfaces:
Comparable<RuleMatch>
Information about an error rule that matches text and the position of the match.
See
ContextTools
for displaying errors in their original text context.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
(package private) static class
static enum
UnlikeCategory
, this is specific to a RuleMatch, not to a rule. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private RuleMatch.ColumnPosition
private RuleMatch.LinePosition
private final String
private RuleMatch.OffsetPosition
private final Rule
private final AnalyzedSentence
private final String
private List<SuggestedReplacement>
private static final Pattern
private RuleMatch.Type
private URL
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.RuleMatch
(Rule rule, int fromPos, int toPos, String message, String shortMessage, boolean startWithUppercase, String suggestionsOutMsg) Deprecated.use a constructor that also takes anAnalyzedSentence
parameter (deprecated since 4.0)RuleMatch
(Rule rule, AnalyzedSentence sentence, int fromPos, int toPos, String message) Creates a RuleMatch object, taking the rule that triggered this match, position of the match and an explanation message.RuleMatch
(Rule rule, AnalyzedSentence sentence, int fromPos, int toPos, String message, String shortMessage) Creates a RuleMatch object, taking the rule that triggered this match, position of the match and an explanation message.RuleMatch
(Rule rule, AnalyzedSentence sentence, int fromPos, int toPos, String message, String shortMessage, boolean startWithUppercase, String suggestionsOutMsg) Creates a RuleMatch object, taking the rule that triggered this match, position of the match and an explanation message. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSuggestedReplacement
(String replacement) void
addSuggestedReplacements
(List<String> replacements) int
Compare by start position.boolean
int
Deprecated.rely on the character-basedgetFromPos()
instead (deprecated since 3.4)int
Deprecated.rely ongetToPos()
instead (deprecated since 3.4)int
Deprecated.rely ongetToPos()
instead (deprecated since 3.4)int
Position of the start of the error (in characters, zero-based, relative to the original input text).int
getLine()
Deprecated.rely on the character-basedgetFromPos()
instead (deprecated since 3.4)A human-readable explanation describing the error.getRule()
A shorter human-readable explanation describing the error or an empty string if no such explanation is available.The text fragments which might be an appropriate fix for the problem.int
getToPos()
Position of the end of the error (in characters, zero-based, relative to the original input text).getType()
@Nullable URL
getUrl()
A URL that points to a more detailed error description ornull
.int
hashCode()
boolean
void
setAutoCorrect
(boolean autoCorrect) void
setColumn
(int column) Deprecated.(deprecated since 3.5)void
setEndColumn
(int endColumn) Deprecated.(deprecated since 3.5)void
setEndLine
(int endLine) Set the line number in which the match ends (zero-based).void
setFeatures
(@NotNull SortedMap<String, Float> features) void
setLine
(int fromLine) Set the line number in which the match occurs (zero-based).void
setOffsetPosition
(int fromPos, int toPos, RuleMatch ruleMatch) void
setSuggestedReplacement
(String replacement) void
setSuggestedReplacementObjects
(List<SuggestedReplacement> replacements) void
setSuggestedReplacements
(List<String> replacements) void
setType
(RuleMatch.Type type) void
toString()
-
Field Details
-
SUGGESTION_PATTERN
-
rule
-
message
-
shortMessage
-
sentence
-
offsetPosition
-
linePosition
-
columnPosition
-
suggestedReplacements
-
url
-
type
-
features
-
autoCorrect
private boolean autoCorrect
-
-
Constructor Details
-
RuleMatch
Deprecated.use a constructor that also takes anAnalyzedSentence
parameter (deprecated since 4.0)Creates a RuleMatch object, taking the rule that triggered this match, position of the match and an explanation message. This message is scanned for <suggestion>...</suggestion> to get suggested fixes for the problem detected by this rule. -
RuleMatch
Creates a RuleMatch object, taking the rule that triggered this match, position of the match and an explanation message. This message is scanned for <suggestion>...</suggestion> to get suggested fixes for the problem detected by this rule.- Since:
- 4.0
-
RuleMatch
public RuleMatch(Rule rule, AnalyzedSentence sentence, int fromPos, int toPos, String message, String shortMessage) Creates a RuleMatch object, taking the rule that triggered this match, position of the match and an explanation message. This message is scanned for <suggestion>...</suggestion> to get suggested fixes for the problem detected by this rule.- Parameters:
shortMessage
- used for example in OpenOffice/LibreOffice's context menu- Since:
- 4.0
-
RuleMatch
public RuleMatch(Rule rule, int fromPos, int toPos, String message, String shortMessage, boolean startWithUppercase, String suggestionsOutMsg) Deprecated.use a constructor that also takes anAnalyzedSentence
parameter (deprecated since 4.0) -
RuleMatch
public RuleMatch(Rule rule, AnalyzedSentence sentence, int fromPos, int toPos, String message, String shortMessage, boolean startWithUppercase, String suggestionsOutMsg) Creates a RuleMatch object, taking the rule that triggered this match, position of the match and an explanation message. This message is scanned for <suggestion>...</suggestion> to get suggested fixes for the problem detected by this rule.- Parameters:
fromPos
- error start position in original texttoPos
- error end position in original textshortMessage
- used for example in OpenOffice/LibreOffice's context menu (may be null)startWithUppercase
- whether the original text at the position of the match starts with an uppercase character- Since:
- 4.0
-
RuleMatch
-
RuleMatch
-
-
Method Details
-
getFeatures
-
setFeatures
-
isAutoCorrect
public boolean isAutoCorrect() -
setAutoCorrect
public void setAutoCorrect(boolean autoCorrect) -
getRule
-
getLine
public int getLine()Deprecated.rely on the character-basedgetFromPos()
instead (deprecated since 3.4)Get the line number in which the match occurs (zero-based). -
setLine
public void setLine(int fromLine) Set the line number in which the match occurs (zero-based). -
getEndLine
public int getEndLine()Deprecated.rely ongetToPos()
instead (deprecated since 3.4)Get the line number in which the match ends (zero-based). -
setEndLine
public void setEndLine(int endLine) Set the line number in which the match ends (zero-based). -
getColumn
public int getColumn()Deprecated.rely on the character-basedgetFromPos()
instead (deprecated since 3.4)Get the column number in which the match occurs (zero-based). -
setColumn
public void setColumn(int column) Deprecated.(deprecated since 3.5)Set the column number in which the match occurs (zero-based). -
getEndColumn
public int getEndColumn()Deprecated.rely ongetToPos()
instead (deprecated since 3.4)Get the column number in which the match ends (zero-based). -
setEndColumn
public void setEndColumn(int endColumn) Deprecated.(deprecated since 3.5)Set the column number in which the match ends (zero-based). -
getFromPos
public int getFromPos()Position of the start of the error (in characters, zero-based, relative to the original input text). -
getToPos
public int getToPos()Position of the end of the error (in characters, zero-based, relative to the original input text). -
setOffsetPosition
-
getMessage
A human-readable explanation describing the error. This may contain one or more corrections marked up with <suggestion>...</suggestion>.- See Also:
-
getShortMessage
A shorter human-readable explanation describing the error or an empty string if no such explanation is available.- See Also:
-
setSuggestedReplacement
- See Also:
-
addSuggestedReplacement
-
addSuggestedReplacements
-
getSuggestedReplacements
The text fragments which might be an appropriate fix for the problem. One of these fragments can be used to replace the old text betweengetFromPos()
togetToPos()
.- Returns:
- unmodifiable list of String objects or an empty List
-
setSuggestedReplacements
- See Also:
-
getSuggestedReplacementObjects
-
setSuggestedReplacementObjects
- See Also:
-
getUrl
A URL that points to a more detailed error description ornull
. Note that theRule
itself might also have an URL, which is usually a less specific one than this. This one will overwrite the rule's URL in the JSON output.- Since:
- 4.0
-
setUrl
- Since:
- 4.0
-
getSentence
- Since:
- 4.0
-
getType
- Since:
- 4.3
-
setType
- Since:
- 4.3
-
toString
-
compareTo
Compare by start position.- Specified by:
compareTo
in interfaceComparable<RuleMatch>
-
equals
-
hashCode
public int hashCode()
-
AnalyzedSentence
parameter (deprecated since 4.0)