edu.stanford.nlp.ling.tokensregex
Interface SequenceMatchResult<T>

All Superinterfaces:
HasInterval<java.lang.Integer>, java.util.regex.MatchResult
All Known Implementing Classes:
BasicSequenceMatchResult, CoreMapSequenceMatcher, CoreMapSequenceMatcher.BasicCoreMapSequenceMatcher, SequenceMatcher, TokenSequenceMatcher

public interface SequenceMatchResult<T>
extends java.util.regex.MatchResult, HasInterval<java.lang.Integer>

The result of a match against a sequence.

Similar to Java's MatchResult except it is for sequences over arbitrary types T instead of just characters.

This interface contains query methods used to determine the results of a match against a regular expression against an sequence. The match boundaries, groups and group boundaries can be seen but not modified through a SequenceMatchResult.

Author:
Angel Chang
See Also:
SequenceMatcher

Nested Class Summary
static class SequenceMatchResult.GroupToIntervalFunc<MR extends java.util.regex.MatchResult>
           
static class SequenceMatchResult.MatchedGroupInfo<T>
          Information about a matched group
 
Field Summary
static java.util.Comparator<? super java.util.regex.MatchResult> DEFAULT_COMPARATOR
           
static int GROUP_AFTER_MATCH
           
static int GROUP_BEFORE_MATCH
           
static java.util.Comparator<java.util.regex.MatchResult> LENGTH_COMPARATOR
           
static java.util.Comparator<java.util.regex.MatchResult> OFFSET_COMPARATOR
           
static java.util.Comparator<java.util.regex.MatchResult> ORDER_COMPARATOR
           
static java.util.Comparator<java.util.regex.MatchResult> SCORE_COMPARATOR
           
static java.util.Comparator<java.util.regex.MatchResult> SCORE_LENGTH_ORDER_OFFSET_COMPARATOR
           
static SequenceMatchResult.GroupToIntervalFunc TO_INTERVAL
           
 
Fields inherited from interface edu.stanford.nlp.util.HasInterval
CONTAINS_FIRST_ENDPOINTS_COMPARATOR, ENDPOINTS_COMPARATOR, NESTED_FIRST_ENDPOINTS_COMPARATOR
 
Method Summary
 java.util.List<? extends T> elements()
          Returns the original sequence the match was performed on.
 int end(java.lang.String groupVar)
          Returns the index of the next element after the subsequence captured by the given group during this match.
 int getOrder()
           
 java.lang.String group(java.lang.String groupVar)
          Returns the String representing the matched group.
 SequenceMatchResult.MatchedGroupInfo<T> groupInfo()
           
 SequenceMatchResult.MatchedGroupInfo<T> groupInfo(int group)
           
 SequenceMatchResult.MatchedGroupInfo<T> groupInfo(java.lang.String var)
           
 java.lang.Object groupMatchResult(int groupid, int index)
          Returns an Object representing the result for the match for a particular node in a group.
 java.lang.Object groupMatchResult(java.lang.String groupVar, int index)
          Returns an Object representing the result for the match for a particular node in a group.
 java.util.List<java.lang.Object> groupMatchResults()
          Returns a list of Objects representing the match results for the entire sequence.
 java.util.List<java.lang.Object> groupMatchResults(int group)
          Returns a list of Objects representing the match results for the nodes in the group.
 java.util.List<java.lang.Object> groupMatchResults(java.lang.String groupVar)
          Returns a list of Objects representing the match results for the nodes in the group.
 java.util.List<? extends T> groupNodes()
          Returns the entire matched subsequence as a list.
 java.util.List<? extends T> groupNodes(int group)
          Returns the matched group as a list.
 java.util.List<? extends T> groupNodes(java.lang.String groupVar)
          Returns the matched group as a list.
 java.lang.Object groupValue()
           
 java.lang.Object groupValue(int group)
           
 java.lang.Object groupValue(java.lang.String var)
           
 java.lang.Object nodeMatchResult(int index)
          Returns an Object representing the result for the match for a particular node.
 SequencePattern<T> pattern()
          Returns pattern used to create this sequence match result
 double score()
           
 int start(java.lang.String groupVar)
          Returns the start index of the subsequence captured by the given group during this match.
 BasicSequenceMatchResult<T> toBasicSequenceMatchResult()
           
 
Methods inherited from interface java.util.regex.MatchResult
end, end, group, group, groupCount, start, start
 
Methods inherited from interface edu.stanford.nlp.util.HasInterval
getInterval
 

Field Detail

GROUP_BEFORE_MATCH

static final int GROUP_BEFORE_MATCH
See Also:
Constant Field Values

GROUP_AFTER_MATCH

static final int GROUP_AFTER_MATCH
See Also:
Constant Field Values

TO_INTERVAL

static final SequenceMatchResult.GroupToIntervalFunc TO_INTERVAL

SCORE_COMPARATOR

static final java.util.Comparator<java.util.regex.MatchResult> SCORE_COMPARATOR

ORDER_COMPARATOR

static final java.util.Comparator<java.util.regex.MatchResult> ORDER_COMPARATOR

LENGTH_COMPARATOR

static final java.util.Comparator<java.util.regex.MatchResult> LENGTH_COMPARATOR

OFFSET_COMPARATOR

static final java.util.Comparator<java.util.regex.MatchResult> OFFSET_COMPARATOR

SCORE_LENGTH_ORDER_OFFSET_COMPARATOR

static final java.util.Comparator<java.util.regex.MatchResult> SCORE_LENGTH_ORDER_OFFSET_COMPARATOR

DEFAULT_COMPARATOR

static final java.util.Comparator<? super java.util.regex.MatchResult> DEFAULT_COMPARATOR
Method Detail

score

double score()

elements

java.util.List<? extends T> elements()
Returns the original sequence the match was performed on.

Returns:
The list that the match was performed on

pattern

SequencePattern<T> pattern()
Returns pattern used to create this sequence match result

Returns:
the SequencePattern against which this sequence match result was matched

groupNodes

java.util.List<? extends T> groupNodes()
Returns the entire matched subsequence as a list.

Returns:
the matched subsequence as a list
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

groupNodes

java.util.List<? extends T> groupNodes(int group)
Returns the matched group as a list.

Parameters:
group - The index of a capturing group in this matcher's pattern
Returns:
the matched group as a list
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed
java.lang.IndexOutOfBoundsException - If there is no capturing group in the pattern with the given index

toBasicSequenceMatchResult

BasicSequenceMatchResult<T> toBasicSequenceMatchResult()

groupNodes

java.util.List<? extends T> groupNodes(java.lang.String groupVar)
Returns the matched group as a list.

Parameters:
groupVar - The name of the capturing group in this matcher's pattern
Returns:
the matched group as a list or null if there is no capturing group in the pattern with the given name
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

group

java.lang.String group(java.lang.String groupVar)
Returns the String representing the matched group.

Parameters:
groupVar - The name of the capturing group in this matcher's pattern
Returns:
the matched group as a String or null if there is no capturing group in the pattern with the given name
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

start

int start(java.lang.String groupVar)
Returns the start index of the subsequence captured by the given group during this match.

Parameters:
groupVar - The name of the capturing group in this matcher's pattern
Returns:
the index of the first element captured by the group, or -1 if the match was successful but the group itself did not match anything or if there is no capturing group in the pattern with the given name
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

end

int end(java.lang.String groupVar)
Returns the index of the next element after the subsequence captured by the given group during this match.

Parameters:
groupVar - The name of the capturing group in this matcher's pattern
Returns:
the index of the next element after the subsequence captured by the group, or -1 if the match was successful but the group itself did not match anything or if there is no capturing group in the pattern with the given name
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

getOrder

int getOrder()

nodeMatchResult

java.lang.Object nodeMatchResult(int index)
Returns an Object representing the result for the match for a particular node. (actual Object returned depends on the type T of the nodes. For instance, for a CoreMap, the match result is returned as a Map, while for String, the match result is typically a MatchResult.

Parameters:
index - The index of the element in the original sequence.
Returns:
the match result associated with the node at the given index.
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed
java.lang.IndexOutOfBoundsException - If the index is out of range

groupMatchResult

java.lang.Object groupMatchResult(int groupid,
                                  int index)
Returns an Object representing the result for the match for a particular node in a group. (actual Object returned depends on the type T of the nodes. For instance, for a CoreMap, the match result is returned as a Map, while for String, the match result is typically a MatchResult.

Parameters:
groupid - The index of a capturing group in this matcher's pattern
index - The index of the element in the captured subsequence.
Returns:
the match result associated with the node at the given index for the captured group.
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed
java.lang.IndexOutOfBoundsException - If there is no capturing group in the pattern with the given groupid or if the index is out of range

groupMatchResult

java.lang.Object groupMatchResult(java.lang.String groupVar,
                                  int index)
Returns an Object representing the result for the match for a particular node in a group. (actual Object returned depends on the type T of the nodes. For instance, for a CoreMap, the match result is returned as a Map, while for String, the match result is typically a MatchResult.

Parameters:
groupVar - The name of the capturing group in this matcher's pattern
index - The index of the element in the captured subsequence.
Returns:
the match result associated with the node at the given index for the captured group.
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed
java.lang.IndexOutOfBoundsException - if the index is out of range

groupMatchResults

java.util.List<java.lang.Object> groupMatchResults()
Returns a list of Objects representing the match results for the entire sequence.

Returns:
the list of match results associated with the entire sequence
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

groupMatchResults

java.util.List<java.lang.Object> groupMatchResults(int group)
Returns a list of Objects representing the match results for the nodes in the group.

Parameters:
group - The index of a capturing group in this matcher's pattern
Returns:
the list of match results associated with the nodes for the captured group.
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed
java.lang.IndexOutOfBoundsException - If there is no capturing group in the pattern with the given index

groupMatchResults

java.util.List<java.lang.Object> groupMatchResults(java.lang.String groupVar)
Returns a list of Objects representing the match results for the nodes in the group. f

Parameters:
groupVar - The name of the capturing group in this matcher's pattern
Returns:
the list of match results associated with the nodes for the captured group.
Throws:
java.lang.IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

groupValue

java.lang.Object groupValue()

groupValue

java.lang.Object groupValue(int group)

groupValue

java.lang.Object groupValue(java.lang.String var)

groupInfo

SequenceMatchResult.MatchedGroupInfo<T> groupInfo()

groupInfo

SequenceMatchResult.MatchedGroupInfo<T> groupInfo(int group)

groupInfo

SequenceMatchResult.MatchedGroupInfo<T> groupInfo(java.lang.String var)


Stanford NLP Group