/** * 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; }
cmSentence.get(CoreAnnotations.TokensAnnotation.class).subList(cm.startIndex-1, cm.endIndex-1); TokenSequenceMatcher titlePersonMatcher = titlePersonPattern.matcher(corefMentionTokens); if (titlePersonMatcher.find()) { List<CoreMap> overallMatch = titlePersonMatcher.groupNodes(0);
if ((matcher = triggerWhatIsThere.matcher(question)).matches()) { // must come before triggerWhatIs return postProcess(question, processWhatIsThere(matcher)); } else if ((matcher = triggerWhNNWill.matcher(question)).matches()) { // must come before triggerWhNNIs return postProcess(question, processWhNNWill(matcher)); } else if ((matcher = triggerWhNNIs.matcher(question)).matches()) { // must come before triggerWhatIs return postProcess(question, processWhNNIs(matcher)); } else if ((matcher = triggerWhNNHave.matcher(question)).matches()) { // must come before triggerWhatHave return postProcess(question, processWhNNHaveIs(matcher)); } else if ((matcher = triggerWhNNHaveNN.matcher(question)).matches()) { // must come before triggerWhatHave return postProcess(question, processWhNNHaveNN(matcher)); } else if ((matcher = triggerHow.matcher(question)).matches()) { // must come before triggerWhatIs return postProcess(question, processHow(matcher)); } else if ((matcher = triggerHowMuchDo.matcher(question)).matches()) { return postProcess(question, processHowMuchDo(matcher)); } else if ((matcher = triggerWhatIs.matcher(question)).matches()) { return postProcess(question, processWhatIs(matcher)); } else if ((matcher = triggerWhatHave.matcher(question)).matches()) { return postProcess(question, processWhatHave(matcher)); } else if ((matcher = triggerWhereDo.matcher(question)).matches()) { return postProcess(question, processWhereDo(matcher, question)); } else if ((matcher = triggerWhereIs.matcher(question)).matches()) { return postProcess(question, processWhereIs(matcher)); } else if ((matcher = triggerWhoIs.matcher(question)).matches()) { return postProcess(question, processWhoIs(matcher)); } else if ((matcher = triggerWhoDid.matcher(question)).matches()) { return postProcess(question, processWhoDid(matcher)); } else if ((matcher = triggerWhatDo.matcher(question)).matches()) { return postProcess(question, processWhatDo(matcher)); } else if ((matcher = triggerWhenDo.matcher(question)).matches()) {
TokenSequenceMatcher tokenMatcher = DOUBT_PATTERN.matcher(tokens); while (tokenMatcher.find()) { List<CoreLabel> doubt = (List<CoreLabel>) tokenMatcher.groupNodes("$doubt");
TokenSequenceMatcher tokenMatcher = tokenPattern.matcher(tokens); while (tokenMatcher.find()) { boolean missingPrefixBe;
/** * 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; }
cmSentence.get(CoreAnnotations.TokensAnnotation.class).subList(cm.startIndex-1, cm.endIndex-1); TokenSequenceMatcher titlePersonMatcher = titlePersonPattern.matcher(corefMentionTokens); if (titlePersonMatcher.find()) { List<CoreMap> overallMatch = titlePersonMatcher.groupNodes(0);
if ((matcher = triggerWhatIsThere.matcher(question)).matches()) { // must come before triggerWhatIs return postProcess(question, processWhatIsThere(matcher)); } else if ((matcher = triggerWhNNWill.matcher(question)).matches()) { // must come before triggerWhNNIs return postProcess(question, processWhNNWill(matcher)); } else if ((matcher = triggerWhNNIs.matcher(question)).matches()) { // must come before triggerWhatIs return postProcess(question, processWhNNIs(matcher)); } else if ((matcher = triggerWhNNHave.matcher(question)).matches()) { // must come before triggerWhatHave return postProcess(question, processWhNNHaveIs(matcher)); } else if ((matcher = triggerWhNNHaveNN.matcher(question)).matches()) { // must come before triggerWhatHave return postProcess(question, processWhNNHaveNN(matcher)); } else if ((matcher = triggerHow.matcher(question)).matches()) { // must come before triggerWhatIs return postProcess(question, processHow(matcher)); } else if ((matcher = triggerHowMuchDo.matcher(question)).matches()) { return postProcess(question, processHowMuchDo(matcher)); } else if ((matcher = triggerWhatIs.matcher(question)).matches()) { return postProcess(question, processWhatIs(matcher)); } else if ((matcher = triggerWhatHave.matcher(question)).matches()) { return postProcess(question, processWhatHave(matcher)); } else if ((matcher = triggerWhereDo.matcher(question)).matches()) { return postProcess(question, processWhereDo(matcher, question)); } else if ((matcher = triggerWhereIs.matcher(question)).matches()) { return postProcess(question, processWhereIs(matcher)); } else if ((matcher = triggerWhoIs.matcher(question)).matches()) { return postProcess(question, processWhoIs(matcher)); } else if ((matcher = triggerWhoDid.matcher(question)).matches()) { return postProcess(question, processWhoDid(matcher)); } else if ((matcher = triggerWhatDo.matcher(question)).matches()) { return postProcess(question, processWhatDo(matcher)); } else if ((matcher = triggerWhenDo.matcher(question)).matches()) {
TokenSequenceMatcher tokenMatcher = DOUBT_PATTERN.matcher(tokens); while (tokenMatcher.find()) { List<CoreLabel> doubt = (List<CoreLabel>) tokenMatcher.groupNodes("$doubt");
TokenSequenceMatcher tokenMatcher = tokenPattern.matcher(tokens); while (tokenMatcher.find()) { boolean missingPrefixBe;