public TimeExpression apply(SequenceMatchResult<CoreMap> matched) { TimeExpression te = new TimeExpression( null, Interval.toInterval( matched.start(group), matched.end(group), Interval.INTERVAL_OPEN_END), extractor, 0); te.setIncludeNested(includeNested); return te; }
public SUTime.Temporal apply(MatchResult in) { if (in instanceof SequenceMatchResult) { SequenceMatchResult<CoreMap> mr = (SequenceMatchResult<CoreMap>) (in); if (group >= 0) { List<? extends CoreMap> matched = mr.groupNodes(group); if (matched != null) { int i = (nodeIndex >= 0) ? 0 : (matched.size() + nodeIndex); TimeExpression te = getTimeExpression(matched, i); if (te != null) { return te.getTemporal(); } } } } return null; }
private void annotateMatched(List<CoreLabel> tokens) { List<SequenceMatchResult<CoreMap>> matched = multiPatternMatcher.findNonOverlapping(tokens); for (SequenceMatchResult<CoreMap> m : matched) { Entry entry = patternToEntry.get(m.pattern()); // Check if we will overwrite the existing annotation with this annotation int g = entry.annotateGroup; int start = m.start(g); int end = m.end(g); boolean overwriteOriginalNer = checkPosTags(tokens, start, end); if (overwriteOriginalNer) { overwriteOriginalNer = checkOrigNerTags(entry, tokens, start, end); } if (overwriteOriginalNer) { for (int i = start; i < end; i++) { tokens.get(i).set(CoreAnnotations.NamedEntityTagAnnotation.class, entry.type); } } else { if (verbose) { System.err.println( "Not annotating '" + m.group(g) + "': " + StringUtils.joinFields( m.groupNodes(g), CoreAnnotations.NamedEntityTagAnnotation.class) + " with " + entry.type + ", sentence is '" + StringUtils.joinWords(tokens, " ") + '\''); } } } }