use of edu.stanford.nlp.ling.tokensregex.TokenSequenceMatcher in project CoreNLP by stanfordnlp.
the class Sentence method find.
/**
* Apply a TokensRegex pattern to the sentence.
*
* @param pattern The TokensRegex pattern to match against.
* @param fn The action to do on each match.
* @return the list of matches, after run through the function.
*/
public <T> List<T> find(TokenSequencePattern pattern, Function<TokenSequenceMatcher, T> fn) {
TokenSequenceMatcher matcher = pattern.matcher(asCoreLabels());
List<T> lst = new ArrayList<>();
while (matcher.find()) {
lst.add(fn.apply(matcher));
}
return lst;
}
Aggregations