Modifier and Type | Class and Description |
---|---|
static class |
PatternToken.PosToken |
Modifier and Type | Field and Description |
---|---|
static String |
UNKNOWN_TAG
Matches only tokens without any POS tag.
|
Constructor and Description |
---|
PatternToken(String token,
boolean caseSensitive,
boolean regExp,
boolean inflected)
Creates Element that is used to match tokens in the text.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
PatternToken |
compile(AnalyzedTokenReadings token,
Synthesizer synth)
Prepare PatternToken for matching by formatting its string token and POS (if the Element is supposed
to refer to some other token).
|
List<PatternToken> |
getAndGroup()
Returns the group of elements linked with AND operator.
|
ChunkTag |
getChunkTag() |
List<PatternToken> |
getExceptionList() |
Match |
getMatch() |
int |
getMaxOccurrence()
The maximum number of times the element may occur.
|
int |
getMinOccurrence()
The minimum number of times the element needs to occur.
|
boolean |
getNegation()
|
List<PatternToken> |
getOrGroup()
Returns the group of elements linked with OR operator.
|
String |
getPhraseName()
Gets the phrase the element is in.
|
boolean |
getPOSNegation() |
String |
getPOStag() |
int |
getSkipNext()
Gets the exception scope length.
|
String |
getString() |
Map<String,List<String>> |
getUniFeatures()
Get unification features and types.
|
boolean |
hasAndGroup()
Checks if this element has an AND group associated with it.
|
boolean |
hasCurrentOrNextExceptions() |
boolean |
hasExceptionList() |
boolean |
hasNextException()
Checks if the element has an exception for a next scope.
|
boolean |
hasOrGroup()
Checks if this element has an OR group associated with it.
|
boolean |
hasPreviousException()
Checks if the element has an exception for a previous token.
|
boolean |
isAndExceptionGroupMatched(AnalyzedToken token)
Enables testing multiple conditions specified by multiple element exceptions.
|
boolean |
isCaseSensitive()
Whether the element matches case sensitively.
|
boolean |
isExceptionMatched(AnalyzedToken token)
Checks whether an exception matches.
|
boolean |
isExceptionMatchedCompletely(AnalyzedToken token)
This method checks exceptions both in AND-group and the token.
|
boolean |
isInflected() |
boolean |
isInsideMarker() |
boolean |
isLastInUnification() |
boolean |
isMatched(AnalyzedToken token)
Checks whether the rule element matches the token given as a parameter.
|
boolean |
isMatchedByPreviousException(AnalyzedToken token)
Checks whether an exception for a previous token matches (in case the exception had scope ==
"previous").
|
boolean |
isMatchedByPreviousException(AnalyzedTokenReadings prevToken)
Checks whether an exception for a previous token matches all readings of a given token (in case
the exception had scope == "previous").
|
boolean |
isMatchedByScopeNextException(AnalyzedToken token)
Checks whether a previously set exception matches (in case the exception had scope == "next").
|
boolean |
isPartOfPhrase()
Checks if the Element is in any phrase.
|
boolean |
isPOStagRegularExpression()
Tests whether the POS matches a regular expression.
|
boolean |
isReferenceElement() |
boolean |
isRegularExpression()
Tests whether the element matches a regular expression.
|
boolean |
isSentenceStart()
Checks if the token is a sentence start.
|
boolean |
isUnificationNeutral()
Determines whether the element should be silently ignored during unification,
and simply added.
|
boolean |
isUnified() |
boolean |
isUniNegated() |
boolean |
isWhitespaceBefore(AnalyzedToken token) |
void |
setAndGroupElement(PatternToken andToken) |
void |
setChunkTag(ChunkTag chunkTag) |
void |
setExceptionSpaceBefore(boolean isWhite)
Sets the attribute on the exception that determines matching of patterns
that depends on whether there was a space before the token matching the exception
or not.
|
void |
setInsideMarker(boolean isInsideMarker) |
void |
setLastInUnification() |
void |
setMatch(Match match)
Sets the reference to another token.
|
void |
setMaxOccurrence(int i)
The maximum number of times this element may occur.
|
void |
setMinOccurrence(int i)
The minimum number of times this element may occur.
|
void |
setNegation(boolean negation)
Negates the matching so that non-matching elements match and vice-versa.
|
void |
setOrGroupElement(PatternToken orToken) |
void |
setPhraseName(String id)
Sets the phrase the element is in.
|
void |
setPosToken(PatternToken.PosToken posToken) |
void |
setSkipNext(int i) |
void |
setStringElement(String token) |
void |
setStringPosException(String token,
boolean regExp,
boolean inflected,
boolean negation,
boolean scopeNext,
boolean scopePrevious,
String posToken,
boolean posRegExp,
boolean posNegation,
Boolean caseSensitivity)
Sets a string and/or pos exception for matching tokens.
|
void |
setUnification(Map<String,List<String>> uniFeatures) |
void |
setUnificationNeutral()
Sets the element as ignored during unification.
|
void |
setUniNegation() |
void |
setWhitespaceBefore(boolean isWhite) |
String |
toString() |
public static final String UNKNOWN_TAG
public PatternToken(String token, boolean caseSensitive, boolean regExp, boolean inflected)
token
- String to be matchedcaseSensitive
- true if the check is case-sensitiveregExp
- true if the check uses regular expressionsinflected
- true if the check refers to base forms (lemmas), note that token
must be a base form for this to workpublic Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public boolean isMatched(AnalyzedToken token)
token
- AnalyzedToken to check matching againstpublic boolean isExceptionMatched(AnalyzedToken token)
token
- AnalyzedToken to check matching againstpublic boolean isAndExceptionGroupMatched(AnalyzedToken token)
token
- the token checked for exceptions.public boolean isExceptionMatchedCompletely(AnalyzedToken token)
token
- Token to matchpublic void setAndGroupElement(PatternToken andToken)
public boolean hasAndGroup()
public List<PatternToken> getAndGroup()
public void setOrGroupElement(PatternToken orToken)
public boolean hasOrGroup()
public List<PatternToken> getOrGroup()
public boolean isMatchedByScopeNextException(AnalyzedToken token)
token
- AnalyzedToken
to check matching against.public boolean isMatchedByPreviousException(AnalyzedToken token)
token
- AnalyzedToken
to check matching against.public boolean isMatchedByPreviousException(AnalyzedTokenReadings prevToken)
prevToken
- AnalyzedTokenReadings
to check matching against.public boolean isSentenceStart()
public void setPosToken(PatternToken.PosToken posToken)
public void setChunkTag(ChunkTag chunkTag)
public String getString()
public void setStringElement(String token)
public void setStringPosException(String token, boolean regExp, boolean inflected, boolean negation, boolean scopeNext, boolean scopePrevious, String posToken, boolean posRegExp, boolean posNegation, Boolean caseSensitivity)
token
- The string in the exception.regExp
- True if the string is specified as a regular expression.inflected
- True if the string is a base form (lemma).negation
- True if the exception is negated.scopeNext
- True if the exception scope is next tokens.scopePrevious
- True if the exception should match only a single previous token.posToken
- The part of the speech tag in the exception.posRegExp
- True if the POS is specified as a regular expression.posNegation
- True if the POS exception is negated.caseSensitivity
- if null, use this element's setting for case sensitivity, otherwise the specified valuepublic int getSkipNext()
public int getMinOccurrence()
public int getMaxOccurrence()
public void setSkipNext(int i)
i
- exception scope length.public void setMinOccurrence(int i)
i
- currently only 0
and 1
are supportedpublic void setMaxOccurrence(int i)
i
- a number >= 1 or -1
for unlimited occurrencespublic boolean hasPreviousException()
public boolean hasNextException()
public void setNegation(boolean negation)
public boolean getNegation()
public boolean isReferenceElement()
public void setMatch(Match match)
match
- Formatting object for the token reference.public Match getMatch()
public PatternToken compile(AnalyzedTokenReadings token, Synthesizer synth) throws IOException
token
- the token specified as AnalyzedTokenReadings
synth
- the language synthesizer (Synthesizer
)IOException
public void setPhraseName(String id)
id
- ID of the phrase.public boolean isPartOfPhrase()
public boolean isCaseSensitive()
public boolean isRegularExpression()
public boolean isPOStagRegularExpression()
@Nullable public String getPOStag()
null
@Nullable public ChunkTag getChunkTag()
null
public boolean getPOSNegation()
public boolean isInflected()
@Nullable public String getPhraseName()
public boolean isUnified()
@Nullable public Map<String,List<String>> getUniFeatures()
null
public void setUniNegation()
public boolean isUniNegated()
public boolean isLastInUnification()
public void setLastInUnification()
public boolean isUnificationNeutral()
public void setUnificationNeutral()
public void setWhitespaceBefore(boolean isWhite)
public boolean isInsideMarker()
public void setInsideMarker(boolean isInsideMarker)
public void setExceptionSpaceBefore(boolean isWhite)
isWhite
- If true, the space before exception is required.public boolean isWhitespaceBefore(AnalyzedToken token)
@NotNull public List<PatternToken> getExceptionList()
@ApiStatus.Internal public boolean hasCurrentOrNextExceptions()
public boolean hasExceptionList()