diff --git a/src/main/java/es/bsc/inb/nlp/gate/generic/component/util/AnnotationUtil.java b/src/main/java/es/bsc/inb/nlp/gate/generic/component/util/AnnotationUtil.java index f4579cf116e5698db31b57a5e819aec452a997bc..53d39ca9ae55eebed445bee9c6d1dbe48bb42754 100644 --- a/src/main/java/es/bsc/inb/nlp/gate/generic/component/util/AnnotationUtil.java +++ b/src/main/java/es/bsc/inb/nlp/gate/generic/component/util/AnnotationUtil.java @@ -88,6 +88,58 @@ public class AnnotationUtil { return closest; } + /** + * Return the closes entity with an intermediate POS. This rule apply to the right of the mayor entity. + * @param doc + * @param fields + * @param finding + * @param type + * @param left_limit + * @param right_limit + * @param avoid_token_between + * @return + */ + public static Annotation getClosestAnnotationWithPOSPriorityRight(AnnotationSet fields, Annotation finding, String type, Integer right_limit, String avoid_token_between, String POS) { + AnnotationSet annotations_type = fields.get(type); + Annotation closest = null; + Integer token_between_closest = 10000; + for (Annotation annotation_type : annotations_type) { + AnnotationSet token_between = null; + if (annotation_type.getStartNode().getOffset() > finding.getEndNode().getOffset()) { + //after the finding + token_between = fields.get("Token", finding.getEndNode().getOffset(), annotation_type.getStartNode().getOffset()); + if(token_between.size()<=right_limit && tokensIncludePOS(token_between, POS)) { + //review closest of rule + if(token_between!=null && token_between.size()