public class JCoReAnnotationTools extends Object
| 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. the one (or just one, if
multiple exist) with the highest start-offset that completely overlaps focusAnnotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
getNearestOverlappingAnnotations(org.apache.uima.jcas.JCas aJCas,
org.apache.uima.jcas.tcas.Annotation focusAnnotation,
Class<T> cls)
Returns the nearest annotations of class cls to focusAnnotation, i.e. all annotations
overlapping focusAnnotation where between the leftest returned annotation and the next returned
annotation (that is, returned offsets 0 and 1, if there are multiple returned annotations) there is no other
annotation of type cls.
|
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, 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 overlapping tokens.
aJCas - focusAnnotation - 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 © 2016 JULIE Lab Jena, Germany. All rights reserved.