public class JCoReAnnotationTools extends Object
getOverlappingAnnotation(JCas, String, int, int) do not have a
direct correspondent, however, and might still be useful.| Constructor and Description |
|---|
JCoReAnnotationTools() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getAnnotationAtMatchingOffsets(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls) |
static org.apache.uima.jcas.tcas.Annotation |
getAnnotationAtOffset(org.apache.uima.jcas.JCas aJCas,
String fullAnnotationClassName,
int startOffset,
int endOffset)
returns an annotation of the type fullEntityClassName which has exactly
the specified offset
|
static org.apache.uima.jcas.tcas.Annotation |
getAnnotationByClassName(org.apache.uima.jcas.JCas aJCas,
String fullAnnotationClassName)
returns an annotation object (de.julielab.jcore.types.annotation) of the
type specified by fullEntityClassName.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getIncludedAnnotations(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
Returns, in ascending order, all annotations of type cls that
are completely included - perhaps with having the same begin and/or end
as the focusAnnotation - in focusAnnotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getIncludingAnnotation(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
Returns the leftmost annotation of type cls that completely
includes focusAnnotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getLastOverlappingAnnotation(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
Returns the annotation with the highest end offset of type cls
overlapping focusAnnotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getNearestIncludingAnnotation(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
Returns the nearest annotation of class cls to
focusAnnotation, i.e.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getNearestOverlappingAnnotations(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focus,
Class<T> cls)
Returns the nearest annotations of class cls to
focusAnnotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getNearestOverlappingAnnotations(org.apache.uima.jcas.JCas aJCas,
int begin,
int end,
Class<T> cls)
Convenience method that internally calls
getNearestOverlappingAnnotations(JCas, Annotation, Class). |
static org.apache.uima.jcas.tcas.Annotation |
getOverlappingAnnotation(org.apache.uima.jcas.JCas aJCas,
String fullAnnotationClassName,
int startOffset,
int endOffset)
returns an annotation of the type fullEntityClassName which overlaps an
or is overlapped by an annotation of the same type at the given offset
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getPartiallyOverlappingAnnotation(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
Returns the leftmost annotation of type cls that overlaps
focusAnnotation.
|
static org.apache.uima.jcas.tcas.Annotation |
getPartiallyOverlappingAnnotation(org.apache.uima.jcas.JCas aJCas,
String fullAnnotationClassName,
int startOffset,
int endOffset)
returns an annotation of the type fullEntityClassName which partially
overlaps an or is overlapped by an annotation of the same type at the
given offset
|
public static org.apache.uima.jcas.tcas.Annotation getAnnotationByClassName(org.apache.uima.jcas.JCas aJCas,
String fullAnnotationClassName)
throws ClassNotFoundException,
SecurityException,
NoSuchMethodException,
IllegalArgumentException,
InstantiationException,
IllegalAccessException,
InvocationTargetException
aJCas - the jcas to which to link this annotation objectfullAnnotationClassName - the full class name of the new annotation objectClassNotFoundExceptionSecurityExceptionNoSuchMethodExceptionIllegalArgumentExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetExceptionpublic static org.apache.uima.jcas.tcas.Annotation getAnnotationAtOffset(org.apache.uima.jcas.JCas aJCas,
String fullAnnotationClassName,
int startOffset,
int endOffset)
throws SecurityException,
IllegalArgumentException,
ClassNotFoundException,
NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException
aJCas - the cas to search infullAnnotationClassName - the full class name of the specific annotation typestartOffset - endOffset - SecurityExceptionIllegalArgumentExceptionClassNotFoundExceptionNoSuchMethodExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetExceptionpublic static <T extends org.apache.uima.jcas.tcas.Annotation> T getAnnotationAtMatchingOffsets(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
public static org.apache.uima.jcas.tcas.Annotation getOverlappingAnnotation(org.apache.uima.jcas.JCas aJCas,
String fullAnnotationClassName,
int startOffset,
int endOffset)
throws SecurityException,
IllegalArgumentException,
ClassNotFoundException,
NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException
aJCas - The cas to search inullAnnotationClassName - The full class name of the specific annotation typestartOffset - endOffset - SecurityExceptionIllegalArgumentExceptionClassNotFoundExceptionNoSuchMethodExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetExceptionpublic static org.apache.uima.jcas.tcas.Annotation getPartiallyOverlappingAnnotation(org.apache.uima.jcas.JCas aJCas,
String fullAnnotationClassName,
int startOffset,
int endOffset)
throws SecurityException,
IllegalArgumentException,
ClassNotFoundException,
NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException
aJCas - The cas to search infullAnnotationClassName - The full class name of the specific annotation typestartOffset - endOffset - SecurityExceptionIllegalArgumentExceptionClassNotFoundExceptionNoSuchMethodExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetExceptionpublic static <T extends org.apache.uima.jcas.tcas.Annotation> T getPartiallyOverlappingAnnotation(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
The two annotations may overlap in any way (partial, nested, inclusion, exact match). This algorithm has O(n) runtime with n being the number of annotations in the annotation index.
*TODO: A start offset parameter could be introduced from where to start looking. This way, when iterating over a number of different focusAnnotations in ascending order, one would have only to check from focusAnnotation to focusAnnotation and not always from the very beginning of the annotation index. Same thing for getIncludingAnnotation().
aJCas - focusAnnotation - cls - public static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> getIncludedAnnotations(org.apache.uima.jcas.JCas aJCas, org.apache.uima.jcas.tcas.Annotation focusAnnotation, Class<T> cls)
aJCas - focusAnnotation - cls - public static <T extends org.apache.uima.jcas.tcas.Annotation> T getIncludingAnnotation(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
This algorithm has O(n) runtime with n being the number of annotations in the annotation index.
TODO: A start offset parameter could be introduced from where to start looking. This way, when iterating over a number of different focusAnnotations in ascending order, one would have only to check from focusAnnotation to focusAnnotation and not always from the very beginning of the annotation index. Same thing for getPartiallyOverlappingAnnotation().
aJCas - focusAnnotation - cls - public static <T extends org.apache.uima.jcas.tcas.Annotation> T getNearestIncludingAnnotation(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
This method has nice performance properties when it is known that the annotation looked for is near, e.g. finding the nearest token or sentence.
aJCas - focusAnnotation - cls - public static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> getNearestOverlappingAnnotations(org.apache.uima.jcas.JCas aJCas, int begin, int end, Class<T> cls)
getNearestOverlappingAnnotations(JCas, Annotation, Class). This
method creates a dummy focus annotation with the given offsets, adds it
to CAS indexes, receives the overlapping annotations and removes the
focus annotation from indexes again.
This method has nice performance properties when it is known that the annotation looked for is near, e.g. finding overlapping tokens.
aJCas - CAS with the annotations.begin - Focus begin.end - Focus end.cls - The class of the sought annotations.public static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> getNearestOverlappingAnnotations(org.apache.uima.jcas.JCas aJCas, org.apache.uima.jcas.tcas.Annotation focus, Class<T> cls)
a.begin > focus.begin but still overlapping focus
plus the annotation with a.begin <= focus.begin.
This method has nice performance properties when it is known that the annotation looked for is near, e.g. finding overlapping tokens.
aJCas - The CAS with annotations.focus - The focus annotation to get overlapping annotations for.cls - public static <T extends org.apache.uima.jcas.tcas.Annotation> T getLastOverlappingAnnotation(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
This method is very similar to
getNearestOverlappingAnnotations(JCas, Annotation, Class).
Actually, the last result element of
getNearestOverlappingAnnotations(JCas, Annotation, Class) equals
the returned annotation from this method.
aJCas - focusAnnotation - cls - Copyright © 2018 JULIE Lab Jena, Germany. All rights reserved.