Package org.languagetool.rules.patterns
Class MatchState
- java.lang.Object
-
- org.languagetool.rules.patterns.MatchState
-
public class MatchState extends java.lang.Object
The state of a matching process. This state is NOT thread-safe.- Since:
- 2.3
-
-
Field Summary
Fields Modifier and Type Field Description private AnalyzedTokenReadings
formattedToken
private Match
match
private AnalyzedTokenReadings
matchedToken
private java.lang.String
skippedTokens
private Synthesizer
synthesizer
-
Constructor Summary
Constructors Constructor Description MatchState(Match match, Synthesizer synthesizer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.lang.String
convertCase(java.lang.String s, java.lang.String sample, Language lang)
Converts case of the string token according to match element attributes.AnalyzedTokenReadings
filterReadings()
Match
getMatch()
private java.util.List<AnalyzedToken>
getNewToken(int numRead, java.lang.String token)
java.lang.String
getTargetPosTag()
Format POS tag using parameters already defined in the class.void
setToken(AnalyzedTokenReadings token)
void
setToken(AnalyzedTokenReadings[] tokens, int index, int next)
Sets the token to be formatted etc.java.lang.String[]
toFinalString(Language lang)
Gets all strings formatted using the match element.(package private) java.lang.String
toTokenString()
Method for getting the formatted match as a single string.
-
-
-
Field Detail
-
match
private final Match match
-
synthesizer
private final Synthesizer synthesizer
-
formattedToken
private AnalyzedTokenReadings formattedToken
-
matchedToken
private AnalyzedTokenReadings matchedToken
-
skippedTokens
private java.lang.String skippedTokens
-
-
Constructor Detail
-
MatchState
public MatchState(Match match, Synthesizer synthesizer)
-
-
Method Detail
-
setToken
public void setToken(AnalyzedTokenReadings token)
-
setToken
public final void setToken(AnalyzedTokenReadings[] tokens, int index, int next)
Sets the token to be formatted etc. and includes the support for including the skipped tokens.- Parameters:
tokens
- Array of tokensindex
- Index of the token to be formattednext
- Position of the next token (the skipped tokens are the ones between the tokens[index] and tokens[next]
-
filterReadings
public final AnalyzedTokenReadings filterReadings()
-
convertCase
java.lang.String convertCase(java.lang.String s, java.lang.String sample, Language lang)
Converts case of the string token according to match element attributes.- Parameters:
s
- Token to be converted.sample
- the sample string used to determine how the original string looks like (used only on case preservation)- Returns:
- Converted string.
-
getNewToken
private java.util.List<AnalyzedToken> getNewToken(int numRead, java.lang.String token)
-
toFinalString
public final java.lang.String[] toFinalString(Language lang) throws java.io.IOException
Gets all strings formatted using the match element.- Throws:
java.io.IOException
-
getTargetPosTag
public final java.lang.String getTargetPosTag()
Format POS tag using parameters already defined in the class.- Returns:
- Formatted POS tag as String.
-
toTokenString
final java.lang.String toTokenString() throws java.io.IOException
Method for getting the formatted match as a single string. In case of multiple matches, it joins them using a regular expression operator "|".- Returns:
- Formatted string of the matched token.
- Throws:
java.io.IOException
-
getMatch
public Match getMatch()
-
-