public class TrieMapMatcher<K,V>
extends java.lang.Object
TrieMapMatcher
provides functions to match against a trie.
It can be used to:
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator<Match> |
MATCH_LENGTH_ENDPOINTS_COMPARATOR |
static java.util.function.ToDoubleFunction<Match> |
MATCH_LENGTH_SCORER |
Constructor and Description |
---|
TrieMapMatcher(TrieMap<K,V> root) |
TrieMapMatcher(TrieMap<K,V> root,
java.util.List<K> multimatchDelimiter) |
Modifier and Type | Method and Description |
---|---|
static <K,V> MatchCostFunction<K,V> |
defaultCost() |
java.util.List<Match<K,V>> |
findAllMatches(K... list)
Given a sequence to search through (e.g.
|
java.util.List<Match<K,V>> |
findAllMatches(java.util.List<K> list)
Given a sequence to search through (e.g.
|
java.util.List<Match<K,V>> |
findAllMatches(java.util.List<K> list,
int start,
int end)
Given a sequence to search through (e.g.
|
java.util.List<ApproxMatch<K,V>> |
findClosestMatches(K[] target,
int n)
Given a target sequence, returns the n closes matches (or sequences of matches) from the trie.
|
java.util.List<ApproxMatch<K,V>> |
findClosestMatches(K[] target,
int n,
boolean multimatch,
boolean keepAlignments)
Given a target sequence, returns the n closes matches (or sequences of matches) from the trie.
|
java.util.List<ApproxMatch<K,V>> |
findClosestMatches(K[] target,
MatchCostFunction<K,V> costFunction,
java.lang.Double maxCost,
int n,
boolean multimatch,
boolean keepAlignments)
Given a target sequence, returns the n closes matches (or sequences of matches) from the trie
based on the cost function (lower cost mean better match).
|
java.util.List<ApproxMatch<K,V>> |
findClosestMatches(java.util.List<K> target,
int n)
Given a target sequence, returns the n closes matches (or sequences of matches) from the trie.
|
java.util.List<ApproxMatch<K,V>> |
findClosestMatches(java.util.List<K> target,
int n,
boolean multimatch,
boolean keepAlignments)
Given a target sequence, returns the n closes matches (or sequences of matches) from the trie.
|
java.util.List<ApproxMatch<K,V>> |
findClosestMatches(java.util.List<K> target,
MatchCostFunction<K,V> costFunction,
double maxCost,
int n,
boolean multimatch,
boolean keepAlignments)
Given a target sequence, returns the n closes matches (or sequences of matches) from the trie
based on the cost function (lower cost mean better match).
|
java.util.List<Match<K,V>> |
findNonOverlapping(K... list)
Given a sequence to search through (e.g.
|
java.util.List<Match<K,V>> |
findNonOverlapping(java.util.List<K> list)
Given a sequence to search through (e.g.
|
java.util.List<Match<K,V>> |
findNonOverlapping(java.util.List<K> list,
int start,
int end)
Given a sequence to search through (e.g.
|
java.util.List<Match<K,V>> |
findNonOverlapping(java.util.List<K> list,
int start,
int end,
java.util.Comparator<? super Match<K,V>> compareFunc)
Given a sequence to search through (e.g.
|
java.util.List<Match<K,V>> |
findNonOverlapping(java.util.List<K> list,
int start,
int end,
java.util.function.ToDoubleFunction<? super Match<K,V>> scoreFunc)
Given a sequence to search through (e.g.
|
java.util.List<Match<K,V>> |
getNonOverlapping(java.util.List<Match<K,V>> allMatches)
Given a list of matches, returns all non-overlapping matches.
|
java.util.List<Match<K,V>> |
getNonOverlapping(java.util.List<Match<K,V>> allMatches,
java.util.Comparator<? super Match<K,V>> compareFunc)
Given a list of matches, returns all non-overlapping matches.
|
java.util.List<Match<K,V>> |
getNonOverlapping(java.util.List<Match<K,V>> allMatches,
java.util.function.ToDoubleFunction<? super Match<K,V>> scoreFunc) |
static <K,V> java.util.Comparator<edu.stanford.nlp.ling.tokensregex.matcher.TrieMapMatcher.PartialApproxMatch<K,V>> |
partialMatchComparator() |
java.util.List<Match<K,V>> |
segment(K... list)
Segment a sequence into sequence of sub-sequences by attempting to find the longest non-overlapping
sub-sequences.
|
java.util.List<Match<K,V>> |
segment(java.util.List<K> list)
Segment a sequence into sequence of sub-sequences by attempting to find the longest non-overlapping
sub-sequences.
|
java.util.List<Match<K,V>> |
segment(java.util.List<K> list,
int start,
int end)
Segment a sequence into sequence of sub-sequences by attempting to find the longest non-overlapping
sub-sequences.
|
java.util.List<Match<K,V>> |
segment(java.util.List<K> list,
int start,
int end,
java.util.Comparator<? super Match<K,V>> compareFunc)
Segment a sequence into sequence of sub-sequences by attempting to find the non-overlapping
sub-sequences that comes earlier using the compareFunc.
|
java.util.List<Match<K,V>> |
segment(java.util.List<K> list,
int start,
int end,
java.util.function.ToDoubleFunction<? super Match<K,V>> scoreFunc)
Segment a sequence into sequence of sub-sequences by attempting to maximize the total score
Non-matched parts will be included as a match with a null value.
|
java.util.List<Match<K,V>> |
segment(java.util.List<K> list,
java.util.function.ToDoubleFunction<? super Match<K,V>> scoreFunc) |
protected void |
updateAllMatches(TrieMap<K,V> trie,
java.util.List<Match<K,V>> matches,
java.util.List<K> matched,
java.util.List<K> list,
int start,
int end) |
protected void |
updateAllMatchesWithStart(TrieMap<K,V> trie,
java.util.List<Match<K,V>> matches,
java.util.List<K> matched,
java.util.List<K> list,
int start,
int end) |
public static final java.util.Comparator<Match> MATCH_LENGTH_ENDPOINTS_COMPARATOR
public static final java.util.function.ToDoubleFunction<Match> MATCH_LENGTH_SCORER
public java.util.List<ApproxMatch<K,V>> findClosestMatches(K[] target, int n)
target
- Target sequence to matchn
- Number of matches to return. The actual number of matches may be less.public java.util.List<ApproxMatch<K,V>> findClosestMatches(K[] target, int n, boolean multimatch, boolean keepAlignments)
target
- Target sequence to matchn
- Number of matches to return. The actual number of matches may be less.multimatch
- If true, attempt to return matches with sequences of elements from the trie.
Otherwise, only each match will contain one element from the trie.keepAlignments
- If true, alignment information is returnedpublic java.util.List<ApproxMatch<K,V>> findClosestMatches(K[] target, MatchCostFunction<K,V> costFunction, java.lang.Double maxCost, int n, boolean multimatch, boolean keepAlignments)
target
- Target sequence to matchcostFunction
- Cost function to usemaxCost
- Matches with a cost higher than this are discardedn
- Number of matches to return. The actual number of matches may be less.multimatch
- If true, attempt to return matches with sequences of elements from the trie.
Otherwise, only each match will contain one element from the trie.keepAlignments
- If true, alignment information is returnedpublic java.util.List<ApproxMatch<K,V>> findClosestMatches(java.util.List<K> target, int n)
target
- Target sequence to matchn
- Number of matches to return. The actual number of matches may be less.public java.util.List<ApproxMatch<K,V>> findClosestMatches(java.util.List<K> target, int n, boolean multimatch, boolean keepAlignments)
target
- Target sequence to matchn
- Number of matches to return. The actual number of matches may be less.multimatch
- If true, attempt to return matches with sequences of elements from the trie.
Otherwise, only each match will contain one element from the trie.keepAlignments
- If true, alignment information is returnedpublic java.util.List<ApproxMatch<K,V>> findClosestMatches(java.util.List<K> target, MatchCostFunction<K,V> costFunction, double maxCost, int n, boolean multimatch, boolean keepAlignments)
target
- Target sequence to matchcostFunction
- Cost function to usemaxCost
- Matches with a cost higher than this are discardedn
- Number of matches to return. The actual number of matches may be less.multimatch
- If true, attempt to return matches with sequences of elements from the trie.
Otherwise, only each match will contain one element from the trie.keepAlignments
- If true, alignment information is returned@SafeVarargs public final java.util.List<Match<K,V>> findAllMatches(K... list)
list
- Sequence to search throughpublic java.util.List<Match<K,V>> findAllMatches(java.util.List<K> list)
list
- Sequence to search throughpublic java.util.List<Match<K,V>> findAllMatches(java.util.List<K> list, int start, int end)
list
- Sequence to search throughstart
- start index to start search atend
- end index (exclusive) to end search at@SafeVarargs public final java.util.List<Match<K,V>> findNonOverlapping(K... list)
list
- Sequence to search throughpublic java.util.List<Match<K,V>> findNonOverlapping(java.util.List<K> list)
list
- Sequence to search throughpublic java.util.List<Match<K,V>> findNonOverlapping(java.util.List<K> list, int start, int end)
list
- Sequence to search throughstart
- start index to start search atend
- end index (exclusive) to end search atpublic java.util.List<Match<K,V>> findNonOverlapping(java.util.List<K> list, int start, int end, java.util.Comparator<? super Match<K,V>> compareFunc)
list
- Sequence to search throughstart
- start index to start search atend
- end index (exclusive) to end search atcompareFunc
- Comparison function to use for evaluating which overlapping sub-sequence to keep.
Earlier sub-sequences based on the comparison function are favored.public java.util.List<Match<K,V>> findNonOverlapping(java.util.List<K> list, int start, int end, java.util.function.ToDoubleFunction<? super Match<K,V>> scoreFunc)
list
- Sequence to search throughstart
- start index to start search atend
- end index (exclusive) to end search atscoreFunc
- Scoring function indicating how good the match is@SafeVarargs public final java.util.List<Match<K,V>> segment(K... list)
list
- Sequence to search throughpublic java.util.List<Match<K,V>> segment(java.util.List<K> list)
list
- Sequence to search throughpublic java.util.List<Match<K,V>> segment(java.util.List<K> list, int start, int end)
list
- Sequence to search throughstart
- start index to start search atend
- end index (exclusive) to end search atpublic java.util.List<Match<K,V>> segment(java.util.List<K> list, int start, int end, java.util.Comparator<? super Match<K,V>> compareFunc)
list
- Sequence to search throughstart
- start index to start search atend
- end index (exclusive) to end search atcompareFunc
- Comparison function to use for evaluating which overlapping sub-sequence to keep.
Earlier sub-sequences based on the comparison function are favored.public java.util.List<Match<K,V>> segment(java.util.List<K> list, int start, int end, java.util.function.ToDoubleFunction<? super Match<K,V>> scoreFunc)
list
- Sequence to search throughstart
- start index to start search atend
- end index (exclusive) to end search atscoreFunc
- Scoring function indicating how good the match ispublic java.util.List<Match<K,V>> segment(java.util.List<K> list, java.util.function.ToDoubleFunction<? super Match<K,V>> scoreFunc)
public java.util.List<Match<K,V>> getNonOverlapping(java.util.List<Match<K,V>> allMatches)
allMatches
- List of matchespublic java.util.List<Match<K,V>> getNonOverlapping(java.util.List<Match<K,V>> allMatches, java.util.Comparator<? super Match<K,V>> compareFunc)
allMatches
- List of matchescompareFunc
- Comparison function to use for evaluating which overlapping sub-sequence to keep.
Earlier sub-sequences based on the comparison function are favored.public java.util.List<Match<K,V>> getNonOverlapping(java.util.List<Match<K,V>> allMatches, java.util.function.ToDoubleFunction<? super Match<K,V>> scoreFunc)
protected void updateAllMatches(TrieMap<K,V> trie, java.util.List<Match<K,V>> matches, java.util.List<K> matched, java.util.List<K> list, int start, int end)
protected void updateAllMatchesWithStart(TrieMap<K,V> trie, java.util.List<Match<K,V>> matches, java.util.List<K> matched, java.util.List<K> list, int start, int end)
public static <K,V> MatchCostFunction<K,V> defaultCost()
public static <K,V> java.util.Comparator<edu.stanford.nlp.ling.tokensregex.matcher.TrieMapMatcher.PartialApproxMatch<K,V>> partialMatchComparator()