@Test public void testGetNearestOverlappingAnnotations2() throws Exception { JCas jcas = JCasFactory.createJCas("de.julielab.jcore.types.jcore-all-types"); jcas.setDocumentText("aaa aabb bbbb baa aa"); Token t1 = new Token(jcas, 0, 3); t1.addToIndexes(); Token t2 = new Token(jcas, 4, 8); t2.addToIndexes(); Token t3 = new Token(jcas, 9, 13); t3.addToIndexes(); Token t4 = new Token(jcas, 14, 18); t4.addToIndexes(); Token t5 = new Token(jcas, 19, 21); t5.addToIndexes(); EntityMention em = new EntityMention(jcas, 6, 15); em.addToIndexes(); List<Token> result = JCoReAnnotationTools.getNearestOverlappingAnnotations(jcas, em, Token.class); assertEquals(t2, result.get(0)); assertEquals(t3, result.get(1)); assertEquals(t4, result.get(2)); assertEquals(3, result.size()); }
public static <T extends Annotation> List<T> getNearestOverlappingAnnotations(JCas aJCas, int begin, int end, Class<T> cls) { Annotation focusAnnotation = new Annotation(aJCas, begin, end); focusAnnotation.addToIndexes(); try { return getNearestOverlappingAnnotations(aJCas, focusAnnotation, cls); } finally { focusAnnotation.removeFromIndexes(); } }
JCoReAnnotationTools { public static <T extends Annotation> List<T> getNearestOverlappingAnnotations(JCas aJCas, int begin, int end, Class<T> cls) { Annotation focusAnnotation = new Annotation(aJCas, begin, end); focusAnnotation.addToIndexes(); try { return getNearestOverlappingAnnotations(aJCas, focusAnnotation, cls); } finally { focusAnnotation.removeFromIndexes(); } } }
JCoReAnnotationTools { public static <T extends Annotation> List<T> getNearestOverlappingAnnotations(JCas aJCas, int begin, int end, Class<T> cls) { Annotation focusAnnotation = new Annotation(aJCas, begin, end); focusAnnotation.addToIndexes(); try { return getNearestOverlappingAnnotations(aJCas, focusAnnotation, cls); } finally { focusAnnotation.removeFromIndexes(); } }  }
JCoReAnnotationTools { public static <T extends Annotation> List<T> getNearestOverlappingAnnotations(JCas aJCas, int begin, int end, Class<T> cls) { Annotation focusAnnotation = new Annotation(aJCas, begin, end); focusAnnotation.addToIndexes(); try { return getNearestOverlappingAnnotations(aJCas, focusAnnotation, cls); } finally { focusAnnotation.removeFromIndexes(); } }  static Annotation getAnnotationByClassName(JCas aJCas, String fullAnnotationClassName); static Annotation getAnnotationAtOffset(JCas aJCas, String fullAnnotationClassName, int startOffset,
                                                   int endOffset); @SuppressWarnings("unchecked") static T getAnnotationAtMatchingOffsets(JCas aJCas, Annotation focusAnnotation,
                                                                          Class<T> cls); static Annotation getOverlappingAnnotation(JCas aJCas, String fullAnnotationClassName, int startOffset,
                                                      int endOffset); static Annotation getPartiallyOverlappingAnnotation(JCas aJCas, String fullAnnotationClassName,
                                                               int startOffset, int endOffset); @SuppressWarnings("unchecked") static T getPartiallyOverlappingAnnotation(JCas aJCas, Annotation focusAnnotation,
                                                                             Class<T> cls); @SuppressWarnings("unchecked") static List<T> getIncludedAnnotations(JCas aJCas, Annotation focusAnnotation,
                                                                        Class<T> cls); @SuppressWarnings("unchecked") static T getIncludingAnnotation(JCas aJCas, Annotation focusAnnotation,
                                                                  Class<T> cls); @SuppressWarnings("unchecked") static T getNearestIncludingAnnotation(JCas aJCas, Annotation focusAnnotation,
                                                                         Class<T> cls); static List<T> getNearestOverlappingAnnotations(JCas aJCas, int begin, int end,
                                                                                  Class<T> cls); @SuppressWarnings("unchecked") static List<T> getNearestOverlappingAnnotations(JCas aJCas, Annotation focus,
                                                                                  Class<T> cls); @SuppressWarnings("unchecked") static T getLastOverlappingAnnotation(JCas aJCas, Annotation focusAnnotation,
                                                                        Class<T> cls); }
JCoReAnnotationTools { public static <T extends Annotation> List<T> getNearestOverlappingAnnotations(JCas aJCas, int begin, int end, Class<T> cls) { Annotation focusAnnotation = new Annotation(aJCas, begin, end); focusAnnotation.addToIndexes(); try { return getNearestOverlappingAnnotations(aJCas, focusAnnotation, cls); } finally { focusAnnotation.removeFromIndexes(); } }  static Annotation getAnnotationByClassName(JCas aJCas, String fullAnnotationClassName); static Annotation getAnnotationAtOffset(JCas aJCas, String fullAnnotationClassName, int startOffset,
                                                   int endOffset); @SuppressWarnings("unchecked") static T getAnnotationAtMatchingOffsets(JCas aJCas, Annotation focusAnnotation,
                                                                          Class<T> cls); static Annotation getOverlappingAnnotation(JCas aJCas, String fullAnnotationClassName, int startOffset,
                                                      int endOffset); static Annotation getPartiallyOverlappingAnnotation(JCas aJCas, String fullAnnotationClassName,
                                                               int startOffset, int endOffset); @SuppressWarnings("unchecked") static T getPartiallyOverlappingAnnotation(JCas aJCas, Annotation focusAnnotation,
                                                                             Class<T> cls); @SuppressWarnings("unchecked") static List<T> getIncludedAnnotations(JCas aJCas, Annotation focusAnnotation,
                                                                        Class<T> cls); @SuppressWarnings("unchecked") static T getIncludingAnnotation(JCas aJCas, Annotation focusAnnotation,
                                                                  Class<T> cls); @SuppressWarnings("unchecked") static T getNearestIncludingAnnotation(JCas aJCas, Annotation focusAnnotation,
                                                                         Class<T> cls); static List<T> getNearestOverlappingAnnotations(JCas aJCas, int begin, int end,
                                                                                  Class<T> cls); @SuppressWarnings("unchecked") static List<T> getNearestOverlappingAnnotations(JCas aJCas, Annotation focus,
                                                                                  Class<T> cls); @SuppressWarnings("unchecked") static T getLastOverlappingAnnotation(JCas aJCas, Annotation focusAnnotation,
                                                                        Class<T> cls);  }