public final class JCasUtil extends Object
JCas.| Modifier and Type | Method and Description |
|---|---|
static boolean |
contains(org.apache.uima.jcas.JCas jCas,
org.apache.uima.cas.text.AnnotationFS coveringAnnotation,
Class<? extends org.apache.uima.jcas.tcas.Annotation> type)
Check if the given annotation contains any annotation of the given type.
|
static <T extends org.apache.uima.jcas.cas.TOP> |
exists(org.apache.uima.jcas.JCas aJCas,
Class<T> aType)
Test if a JCas contains an annotation of the given type.
|
static org.apache.uima.cas.Type |
getAnnotationType(org.apache.uima.jcas.JCas jCas,
Class<?> type)
Get the CAS type for the given JCas wrapper class type making sure it inherits from
Annotation. |
static org.apache.uima.cas.Type |
getType(org.apache.uima.jcas.JCas jCas,
Class<?> type)
Get the CAS type for the given JCas wrapper class type.
|
static org.apache.uima.jcas.JCas |
getView(org.apache.uima.jcas.JCas jcas,
String viewName,
boolean create)
Convenience method to get the specified view or create a new view if the requested view does
not exist.
|
static org.apache.uima.jcas.JCas |
getView(org.apache.uima.jcas.JCas jcas,
String viewName,
org.apache.uima.jcas.JCas fallback)
Convenience method to get the specified view or a default view if the requested view does not
exist.
|
static <T extends org.apache.uima.jcas.tcas.Annotation,S extends org.apache.uima.jcas.tcas.Annotation> |
indexCovered(org.apache.uima.jcas.JCas jCas,
Class<T> type,
Class<S> coveredType)
Create an index for quickly lookup up the annotations covered by a particular annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation,S extends org.apache.uima.jcas.tcas.Annotation> |
indexCovering(org.apache.uima.jcas.JCas jCas,
Class<T> type,
Class<S> coveringType)
Create an index for quickly lookup up the annotations covering a particular annotation.
|
static <T extends org.apache.uima.cas.text.AnnotationFS> |
iterator(org.apache.uima.cas.text.AnnotationFS container,
Class<T> type,
boolean ambiguous,
boolean strict)
Convenience method to get a sub-iterator for the specified type.
|
static <T extends org.apache.uima.jcas.cas.TOP> |
iterator(org.apache.uima.jcas.JCas jCas,
Class<T> type)
Get an iterator over the given feature structure type.
|
static <T extends org.apache.uima.jcas.cas.TOP> |
select(org.apache.uima.jcas.cas.FSArray array,
Class<T> type)
Convenience method select all feature structure from the given type from an array.
|
static <T extends org.apache.uima.jcas.cas.TOP> |
select(org.apache.uima.jcas.cas.FSList list,
Class<T> type)
Convenience method select all feature structure from the given type from a list.
|
static <T extends org.apache.uima.jcas.cas.TOP> |
select(org.apache.uima.jcas.JCas jCas,
Class<T> type)
Convenience method to iterator over all features structures of a given type.
|
static Collection<org.apache.uima.jcas.cas.TOP> |
selectAll(org.apache.uima.jcas.JCas jCas)
Convenience method to iterator over all features structures.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectBetween(Class<T> type,
org.apache.uima.cas.text.AnnotationFS ann1,
org.apache.uima.cas.text.AnnotationFS ann2)
Get a list of annotations of the given annotation type located between two annotations.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectBetween(org.apache.uima.jcas.JCas jCas,
Class<T> type,
org.apache.uima.cas.text.AnnotationFS ann1,
org.apache.uima.cas.text.AnnotationFS ann2)
Get a list of annotations of the given annotation type located between two annotations.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectByIndex(org.apache.uima.jcas.JCas jCas,
Class<T> cls,
int index)
This method exists simply as a convenience method for unit testing.
|
static <T extends org.apache.uima.cas.text.AnnotationFS> |
selectCovered(Class<T> type,
org.apache.uima.cas.text.AnnotationFS coveringAnnotation)
Get a list of annotations of the given annotation type constrained by a 'covering' annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectCovered(org.apache.uima.jcas.JCas jCas,
Class<T> type,
org.apache.uima.cas.text.AnnotationFS coveringAnnotation)
Get a list of annotations of the given annotation type constrained by a 'covering' annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectCovered(org.apache.uima.jcas.JCas jCas,
Class<T> type,
int begin,
int end)
Get a list of annotations of the given annotation type constrained by a 'covering' annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectCovering(Class<T> type,
org.apache.uima.cas.text.AnnotationFS coveredAnnotation)
Get a list of annotations of the given annotation type constraint by a certain annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectCovering(org.apache.uima.jcas.JCas jCas,
Class<T> type,
org.apache.uima.cas.text.AnnotationFS coveredAnnotation)
Get a list of annotations of the given annotation type constraint by a certain annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectCovering(org.apache.uima.jcas.JCas jCas,
Class<T> type,
int begin,
int end)
Get a list of annotations of the given annotation type constraint by a certain annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectFollowing(Class<T> aType,
org.apache.uima.cas.text.AnnotationFS annotation,
int count)
Returns the n annotations following the given annotation
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectFollowing(org.apache.uima.jcas.JCas aJCas,
Class<T> aType,
org.apache.uima.cas.text.AnnotationFS annotation,
int count)
Returns the n annotations following the given annotation
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectPreceding(Class<T> aType,
org.apache.uima.cas.text.AnnotationFS annotation,
int count)
Returns the n annotations preceding the given annotation
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectPreceding(org.apache.uima.jcas.JCas aJCas,
Class<T> aType,
org.apache.uima.cas.text.AnnotationFS annotation,
int count)
Returns the n annotations preceding the given annotation
|
static <T extends org.apache.uima.jcas.cas.TOP> |
selectSingle(org.apache.uima.jcas.JCas jCas,
Class<T> type)
Get the single instance of the specified type from the JCas.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectSingleRelative(Class<T> aType,
org.apache.uima.cas.text.AnnotationFS annotation,
int index)
Return an annotation preceding or following of a given reference annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
selectSingleRelative(org.apache.uima.jcas.JCas aJCas,
Class<T> aType,
org.apache.uima.cas.text.AnnotationFS annotation,
int index)
Return an annotation preceding or following of a given reference annotation.
|
static <T extends org.apache.uima.jcas.tcas.Annotation> |
subiterate(org.apache.uima.jcas.JCas jCas,
Class<T> type,
org.apache.uima.cas.text.AnnotationFS container,
boolean ambiguous,
boolean strict)
Convenience method to iterator over all annotations of a given type occurring within the scope
of a provided annotation (sub-iteration).
|
static <T extends org.apache.uima.cas.text.AnnotationFS> |
toText(Iterable<T> iterable)
Fetch the text covered by the specified annotations and return it as a list of strings.
|
public static <T extends org.apache.uima.jcas.tcas.Annotation> Iterable<T> subiterate(org.apache.uima.jcas.JCas jCas, Class<T> type, org.apache.uima.cas.text.AnnotationFS container, boolean ambiguous, boolean strict)
T - the iteration type.jCas - a JCas.container - the containing annotation.type - the type.ambiguous - If set to false, resulting iterator will be unambiguous.strict - Controls if annotations that overlap to the right are considered in or out.AnnotationIndex.subiterator(AnnotationFS, boolean, boolean),
Order of selected feature structurespublic static <T extends org.apache.uima.jcas.cas.TOP> Iterator<T> iterator(org.apache.uima.jcas.JCas jCas, Class<T> type)
T - the JCas type.jCas - a JCas.type - a type.public static <T extends org.apache.uima.cas.text.AnnotationFS> Iterator<T> iterator(org.apache.uima.cas.text.AnnotationFS container, Class<T> type, boolean ambiguous, boolean strict)
T - the iteration type.container - the containing annotation.type - the type.ambiguous - If set to false, resulting iterator will be unambiguous.strict - Controls if annotations that overlap to the right are considered in or out.public static org.apache.uima.cas.Type getType(org.apache.uima.jcas.JCas jCas,
Class<?> type)
jCas - the JCas containing the type system.type - the JCas wrapper class type.public static org.apache.uima.cas.Type getAnnotationType(org.apache.uima.jcas.JCas jCas,
Class<?> type)
Annotation.jCas - the JCas containing the type system.type - the JCas wrapper class type.public static <T extends org.apache.uima.jcas.cas.TOP> Collection<T> select(org.apache.uima.jcas.cas.FSArray array, Class<T> type)
T - the JCas type.array - a feature structure array.type - the type.public static <T extends org.apache.uima.jcas.cas.TOP> Collection<T> select(org.apache.uima.jcas.cas.FSList list, Class<T> type)
T - the JCas type.list - a feature structure list.type - the type.public static <T extends org.apache.uima.jcas.cas.TOP> Collection<T> select(org.apache.uima.jcas.JCas jCas, Class<T> type)
T - the iteration type.jCas - the JCas containing the type system.type - the type.public static Collection<org.apache.uima.jcas.cas.TOP> selectAll(org.apache.uima.jcas.JCas jCas)
jCas - the JCas containing the type system. the type.public static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectBetween(Class<T> type, org.apache.uima.cas.text.AnnotationFS ann1, org.apache.uima.cas.text.AnnotationFS ann2)
T - the JCas type.type - a UIMA type.ann1 - the first boundary annotation.ann2 - the second boundary annotation.Subiterator,
Order of selected feature structurespublic static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectBetween(org.apache.uima.jcas.JCas jCas, Class<T> type, org.apache.uima.cas.text.AnnotationFS ann1, org.apache.uima.cas.text.AnnotationFS ann2)
T - the JCas type.jCas - a JCas containing the annotation.type - a UIMA type.ann1 - the first boundary annotation.ann2 - the second boundary annotation.Subiterator,
Order of selected feature structurespublic static <T extends org.apache.uima.cas.text.AnnotationFS> List<T> selectCovered(Class<T> type, org.apache.uima.cas.text.AnnotationFS coveringAnnotation)
T - the JCas type.type - a UIMA type.coveringAnnotation - the covering annotation.Subiterator,
Order of selected feature structurespublic static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectCovered(org.apache.uima.jcas.JCas jCas, Class<T> type, org.apache.uima.cas.text.AnnotationFS coveringAnnotation)
T - the JCas type.jCas - a JCas containing the annotation.type - a UIMA type.coveringAnnotation - the covering annotation.Subiterator,
Order of selected feature structurespublic static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectCovered(org.apache.uima.jcas.JCas jCas, Class<T> type, int begin, int end)
Note: this is significantly slower than using
selectCovered(JCas, Class, AnnotationFS). It is possible to use
selectCovered(jCas, cls, new Annotation(jCas, int, int)), but that will allocate memory
in the jCas for the new annotation. If you do that repeatedly many times, memory may fill up.
T - the JCas type.jCas - a JCas containing the annotation.type - a UIMA type.begin - begin offset.end - end offset.public static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectCovering(Class<T> type, org.apache.uima.cas.text.AnnotationFS coveredAnnotation)
Note: this is REALLY SLOW! You don't want to use this. Instead, consider using
indexCovering(JCas, Class, Class) or a ContainmentIndex.
T - the JCas type.type - a UIMA type.coveredAnnotation - the covered annotation.public static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectCovering(org.apache.uima.jcas.JCas jCas, Class<T> type, org.apache.uima.cas.text.AnnotationFS coveredAnnotation)
Note: this is REALLY SLOW! You don't want to use this. Instead, consider using
indexCovering(JCas, Class, Class) or a ContainmentIndex.
T - the JCas type.jCas - a CAS.type - a UIMA type.coveredAnnotation - the covered annotation.public static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectCovering(org.apache.uima.jcas.JCas jCas, Class<T> type, int begin, int end)
Note: this is REALLY SLOW! You don't want to use this. Instead, consider using
indexCovering(JCas, Class, Class) or a ContainmentIndex.
T - the JCas type.jCas - a CAS.type - a UIMA type.begin - begin offset.end - end offset.public static <T extends org.apache.uima.jcas.tcas.Annotation,S extends org.apache.uima.jcas.tcas.Annotation> Map<T,Collection<S>> indexCovering(org.apache.uima.jcas.JCas jCas, Class<T> type, Class<S> coveringType)
selectCovering(JCas, Class, int, int) because the overhead of
scanning the CAS occurs only when the index is build. Subsequent lookups to the index are fast.T - the covered JCAs type.S - the covering JCas type.jCas - a JCas.type - type to create the index for - this is used in lookups.coveringType - type of covering annotations.public static <T extends org.apache.uima.jcas.tcas.Annotation,S extends org.apache.uima.jcas.tcas.Annotation> Map<T,Collection<S>> indexCovered(org.apache.uima.jcas.JCas jCas, Class<T> type, Class<S> coveredType)
selectCovered(JCas, Class, int, int) because the overhead of
scanning the CAS occurs only when the index is build. Subsequent lookups to the index are fast.T - the covering JCas type.S - the covered JCas type.jCas - a JCas.type - type to create the index for - this is used in lookups.coveredType - type of covered annotations.public static boolean contains(org.apache.uima.jcas.JCas jCas,
org.apache.uima.cas.text.AnnotationFS coveringAnnotation,
Class<? extends org.apache.uima.jcas.tcas.Annotation> type)
jCas - a JCas containing the annotation.coveringAnnotation - the covering annotation.type - a UIMA type.public static <T extends org.apache.uima.jcas.tcas.Annotation> T selectByIndex(org.apache.uima.jcas.JCas jCas,
Class<T> cls,
int index)
It is intentional that this method only allows annotation types. The CAS indexing mechanisms are not well defined for non-annotation types. There are no reliably, built-in indexes for non-annotation types.
T - JCas wrapper type.jCas - a JCas containing the annotation.cls - a UIMA type.index - this can be either positive (0 corresponds to the first annotation of a type) or
negative (-1 corresponds to the last annotation of a type.)public static <T extends org.apache.uima.jcas.cas.TOP> T selectSingle(org.apache.uima.jcas.JCas jCas,
Class<T> type)
T - JCas wrapper type.jCas - a JCas containing the annotation.type - a UIMA type.public static <T extends org.apache.uima.jcas.tcas.Annotation> T selectSingleRelative(Class<T> aType, org.apache.uima.cas.text.AnnotationFS annotation, int index)
T - the JCas type.aType - a type.annotation - anchor annotationindex - relative position to access. A negative value selects a preceding annotation while a
positive number selects a following annotation.IndexOutOfBoundsException - if the relative index points beyond the type index bounds.public static <T extends org.apache.uima.jcas.tcas.Annotation> T selectSingleRelative(org.apache.uima.jcas.JCas aJCas,
Class<T> aType,
org.apache.uima.cas.text.AnnotationFS annotation,
int index)
T - the JCas type.aJCas - a JCas.aType - a type.annotation - anchor annotationindex - relative position to access. A negative value selects a preceding annotation while a
positive number selects a following annotation.IndexOutOfBoundsException - if the relative index points beyond the type index bounds.public static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectPreceding(Class<T> aType, org.apache.uima.cas.text.AnnotationFS annotation, int count)
T - the JCas type.aType - a type.annotation - anchor annotationcount - number of annotations to collectpublic static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectPreceding(org.apache.uima.jcas.JCas aJCas, Class<T> aType, org.apache.uima.cas.text.AnnotationFS annotation, int count)
T - the JCas type.aJCas - a JCas.aType - a type.annotation - anchor annotationcount - number of annotations to collectpublic static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectFollowing(Class<T> aType, org.apache.uima.cas.text.AnnotationFS annotation, int count)
T - the JCas type.aType - a type.annotation - anchor annotationcount - number of annotations to collectpublic static <T extends org.apache.uima.jcas.tcas.Annotation> List<T> selectFollowing(org.apache.uima.jcas.JCas aJCas, Class<T> aType, org.apache.uima.cas.text.AnnotationFS annotation, int count)
T - the JCas type.aJCas - a JCas.aType - a type.annotation - anchor annotationcount - number of annotations to collectpublic static <T extends org.apache.uima.jcas.cas.TOP> boolean exists(org.apache.uima.jcas.JCas aJCas,
Class<T> aType)
T - the annotation type.aJCas - a JCas.aType - a annotation class.true if there is at least one annotation of the given type in the JCas.public static org.apache.uima.jcas.JCas getView(org.apache.uima.jcas.JCas jcas,
String viewName,
org.apache.uima.jcas.JCas fallback)
null.jcas - a JCasviewName - the requested view.fallback - the default view if the requested view does not exist.IllegalStateException - if the JCas wrapper cannot be obtained.public static org.apache.uima.jcas.JCas getView(org.apache.uima.jcas.JCas jcas,
String viewName,
boolean create)
jcas - a JCasviewName - the requested view.create - the view is created if it does not exist.IllegalStateException - if the JCas wrapper cannot be obtained.public static <T extends org.apache.uima.cas.text.AnnotationFS> List<String> toText(Iterable<T> iterable)
T - UIMA JCas type.iterable - annotation container.Copyright © 2012–2014 The Apache Software Foundation. All rights reserved.