/** * Append to replacement list the matched group with the specified group name * @param match Current matched sequence * @param list replacement list */ public void append(SequenceMatchResult<T> match, List list) { list.addAll(match.groupNodes(groupName)); } }
/** * Append to replacement list the matched group with the specified group id * @param match Current matched sequence * @param list replacement list */ public void append(SequenceMatchResult<T> match, List list) { list.addAll(match.groupNodes(group)); } }
public Value evaluate(Env env, Object... args) { if (args != null && args.length > 0) { if (args[0] instanceof SequenceMatchResult) { SequenceMatchResult mr = (SequenceMatchResult) args[0]; Object v = get(); if (v instanceof String) { // TODO: depending if TYPE_STRING, use string version... return new PrimitiveValue<>(TYPE_TOKENS, mr.groupNodes((String) v)); } else if (v instanceof Integer) { return new PrimitiveValue<>(TYPE_TOKENS, mr.groupNodes((Integer) v)); } else { throw new UnsupportedOperationException("String match result must be referred to by group id"); } } else if (args[0] instanceof MatchResult) { MatchResult mr = (MatchResult) args[0]; Object v = get(); if (v instanceof Integer) { String str = mr.group((Integer) get()); return new PrimitiveValue<>(TYPE_STRING, str); } else { throw new UnsupportedOperationException("String match result must be referred to by group id"); } } } return null; } public Expression assign(Expression expr) {
if (verbose) { logger.info("Not annotating (common word) '" + str + "': " + StringUtils.joinFields(m.groupNodes(g), CoreAnnotations.NamedEntityTagAnnotation.class) + " with " + entry.getTypeDescription() + ", sentence is '" + StringUtils.joinWords(tokens, " ") + "'"); if (verbose) { logger.info("Not annotating '" + m.group(g) + "': " + StringUtils.joinFields(m.groupNodes(g), CoreAnnotations.NamedEntityTagAnnotation.class) + " with " + entry.getTypeDescription() + ", sentence is '" + StringUtils.joinWords(tokens, " ") + "'");
/** * Append to replacement list the matched group with the specified group name * @param match Current matched sequence * @param list replacement list */ public void append(SequenceMatchResult<T> match, List list) { list.addAll(match.groupNodes(groupName)); } }
/** * Append to replacement list the matched group with the specified group id * @param match Current matched sequence * @param list replacement list */ public void append(SequenceMatchResult<T> match, List list) { list.addAll(match.groupNodes(group)); } }
/** * Append to replacement list the matched group with the specified group name * @param match Current matched sequence * @param list replacement list */ public void append(SequenceMatchResult<T> match, List list) { list.addAll(match.groupNodes(groupName)); } }
/** * Append to replacement list the matched group with the specified group id * @param match Current matched sequence * @param list replacement list */ public void append(SequenceMatchResult<T> match, List list) { list.addAll(match.groupNodes(group)); } }
/** * Append to replacement list the matched group with the specified group name * @param match Current matched sequence * @param list replacement list */ public void append(SequenceMatchResult<T> match, List list) { list.addAll(match.groupNodes(groupName)); } }
/** * Append to replacement list the matched group with the specified group id * @param match Current matched sequence * @param list replacement list */ public void append(SequenceMatchResult<T> match, List list) { list.addAll(match.groupNodes(group)); } }
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; } }
public Value evaluate(Env env, Object... args) { if (args != null && args.length > 0) { if (args[0] instanceof SequenceMatchResult) { SequenceMatchResult mr = (SequenceMatchResult) args[0]; Object v = get(); if (v instanceof String) { // TODO: depending if TYPE_STRING, use string version... return new PrimitiveValue<>(TYPE_TOKENS, mr.groupNodes((String) v)); } else if (v instanceof Integer) { return new PrimitiveValue<>(TYPE_TOKENS, mr.groupNodes((Integer) v)); } else { throw new UnsupportedOperationException("String match result must be referred to by group id"); } } else if (args[0] instanceof MatchResult) { MatchResult mr = (MatchResult) args[0]; Object v = get(); if (v instanceof Integer) { String str = mr.group((Integer) get()); return new PrimitiveValue<>(TYPE_STRING, str); } else { throw new UnsupportedOperationException("String match result must be referred to by group id"); } } } return null; } public Expression assign(Expression expr) {
public Value evaluate(Env env, Object... args) { if (args != null && args.length > 0) { if (args[0] instanceof SequenceMatchResult) { SequenceMatchResult mr = (SequenceMatchResult) args[0]; Object v = get(); if (v instanceof String) { // TODO: depending if TYPE_STRING, use string version... return new PrimitiveValue<List>(TYPE_TOKENS, mr.groupNodes((String) v)); } else if (v instanceof Integer) { return new PrimitiveValue<List>(TYPE_TOKENS, mr.groupNodes((Integer) v)); } else { throw new UnsupportedOperationException("String match result must be referred to by group id"); } } else if (args[0] instanceof MatchResult) { MatchResult mr = (MatchResult) args[0]; Object v = get(); if (v instanceof Integer) { String str = mr.group((Integer) get()); return new PrimitiveValue<String>(TYPE_STRING, str); } else { throw new UnsupportedOperationException("String match result must be referred to by group id"); } } } return null; } public Expression assign(Expression expr) {
public Value evaluate(Env env, Object... args) { if (args != null && args.length > 0) { if (args[0] instanceof SequenceMatchResult) { SequenceMatchResult mr = (SequenceMatchResult) args[0]; Object v = get(); if (v instanceof String) { // TODO: depending if TYPE_STRING, use string version... return new PrimitiveValue<>(TYPE_TOKENS, mr.groupNodes((String) v)); } else if (v instanceof Integer) { return new PrimitiveValue<>(TYPE_TOKENS, mr.groupNodes((Integer) v)); } else { throw new UnsupportedOperationException("String match result must be referred to by group id"); } } else if (args[0] instanceof MatchResult) { MatchResult mr = (MatchResult) args[0]; Object v = get(); if (v instanceof Integer) { String str = mr.group((Integer) get()); return new PrimitiveValue<>(TYPE_STRING, str); } else { throw new UnsupportedOperationException("String match result must be referred to by group id"); } } } return null; } public Expression assign(Expression expr) {
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, " ") + "'"); } } } }
if (verbose) { logger.info("Not annotating (common word) '" + str + "': " + StringUtils.joinFields(m.groupNodes(g), CoreAnnotations.NamedEntityTagAnnotation.class) + " with " + entry.getTypeDescription() + ", sentence is '" + StringUtils.joinWords(tokens, " ") + "'"); if (verbose) { logger.info("Not annotating '" + m.group(g) + "': " + StringUtils.joinFields(m.groupNodes(g), CoreAnnotations.NamedEntityTagAnnotation.class) + " with " + entry.getTypeDescription() + ", sentence is '" + StringUtils.joinWords(tokens, " ") + "'");