Modifier and Type | Method and Description |
---|---|
static boolean |
contains(JCas jCas,
AnnotationFS coveringAnnotation,
Class<? extends Annotation> type)
Check if the given annotation contains any annotation of the given type.
|
static <T extends TOP> |
exists(JCas aJCas,
Class<T> aType)
Test if a JCas contains an annotation of the given type.
|
static Type |
getAnnotationType(JCas jCas,
Class<?> type)
Get the CAS type for the given JCas wrapper class type making sure it inherits from
Annotation . |
static Type |
getType(JCas jCas,
Class<?> type)
Get the CAS type for the given JCas wrapper class type.
|
static JCas |
getView(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 JCas |
getView(JCas jcas,
String viewName,
JCas fallback)
Convenience method to get the specified view or a default view if the requested view does not
exist.
|
static <T extends Annotation,S extends Annotation> |
indexCovered(JCas jCas,
Class<? extends T> type,
Class<? extends S> coveredType)
Create an index for quickly lookup up the annotations covered by a particular annotation.
|
static <T extends Annotation,S extends Annotation> |
indexCovering(JCas jCas,
Class<? extends T> type,
Class<? extends S> coveringType)
Create an index for quickly lookup up the annotations covering a particular annotation.
|
static <T extends AnnotationFS> |
iterator(AnnotationFS container,
Class<T> type,
boolean ambiguous,
boolean strict)
Convenience method to get a sub-iterator for the specified type.
|
static <T extends TOP> |
iterator(JCas jCas,
Class<T> type)
Deprecated.
Use
jcas.select(type).iterator() |
static <T extends TOP> |
select(FSArray array,
Class<T> type)
Convenience method select all feature structure from the given type from an array.
|
static <T extends TOP> |
select(FSList list,
Class<T> type)
Convenience method select all feature structure from the given type from a list.
|
static <T extends TOP> |
select(JCas jCas,
Class<T> type)
Convenience method to iterator over all features structures of a given type.
|
static Collection<TOP> |
selectAll(JCas jCas)
Convenience method to iterator over all features structures.
|
static <T extends Annotation> |
selectAt(JCas jCas,
Class<T> type,
int aBegin,
int aEnd)
Get all annotations of the given type at the specified offsets.
|
static <T extends Annotation> |
selectBetween(Class<T> type,
AnnotationFS ann1,
AnnotationFS ann2)
Get a list of annotations of the given annotation type located between two annotations.
|
static <T extends Annotation> |
selectBetween(JCas jCas,
Class<T> type,
AnnotationFS ann1,
AnnotationFS ann2)
Get a list of annotations of the given annotation type located between two annotations.
|
static <T extends Annotation> |
selectByIndex(JCas jCas,
Class<T> cls,
int index)
This method exists simply as a convenience method for unit testing.
|
static <T extends AnnotationFS> |
selectCovered(Class<T> type,
AnnotationFS coveringAnnotation)
Get a list of annotations of the given annotation type constrained by a 'covering' annotation.
|
static <T extends Annotation> |
selectCovered(JCas jCas,
Class<T> type,
AnnotationFS coveringAnnotation)
Get a list of annotations of the given annotation type constrained by a 'covering' annotation.
|
static <T extends Annotation> |
selectCovered(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 Annotation> |
selectCovering(Class<T> type,
AnnotationFS coveredAnnotation)
Get a list of annotations of the given annotation type constraint by a certain annotation.
|
static <T extends Annotation> |
selectCovering(JCas jCas,
Class<T> type,
AnnotationFS coveredAnnotation)
Get a list of annotations of the given annotation type constraint by a certain annotation.
|
static <T extends Annotation> |
selectCovering(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 Annotation> |
selectFollowing(Class<T> aType,
AnnotationFS annotation,
int count)
Returns the n annotations following the given annotation
|
static <T extends Annotation> |
selectFollowing(JCas aJCas,
Class<T> aType,
AnnotationFS annotation,
int count)
Returns the n annotations following the given annotation
|
static <T extends Annotation> |
selectOverlapping(Class<T> aType,
AnnotationFS aBoundaryAnnotation)
Get a list of annotations of the given annotation type overlapping the given annotation.
|
static <T extends Annotation> |
selectOverlapping(JCas aJCas,
Class<T> aType,
AnnotationFS aBoundaryAnnotation)
Get a list of annotations of the given annotation type overlapping the given annotation.
|
static <T extends Annotation> |
selectOverlapping(JCas aJCas,
Class<T> aType,
int aBegin,
int aEnd)
Get a list of annotations of the given annotation type overlapping the given span.
|
static <T extends Annotation> |
selectPreceding(Class<T> aType,
AnnotationFS annotation,
int count)
Returns the n annotations preceding the given annotation
|
static <T extends Annotation> |
selectPreceding(JCas aJCas,
Class<T> aType,
AnnotationFS annotation,
int count)
Returns the n annotations preceding the given annotation
|
static <T extends TOP> |
selectSingle(JCas jCas,
Class<T> type)
Get the single instance of the specified type from the JCas.
|
static <T extends Annotation> |
selectSingleAt(JCas jCas,
Class<T> type,
int aBegin,
int aEnd)
Get a single annotations of the given type at the specified offsets.
|
static <T extends Annotation> |
selectSingleRelative(Class<T> aType,
AnnotationFS annotation,
int index)
Return an annotation preceding or following of a given reference annotation.
|
static <T extends Annotation> |
selectSingleRelative(JCas aJCas,
Class<T> aType,
AnnotationFS aAnchor,
int aPosition)
Return an annotation preceding or following of a given reference annotation.
|
static <T extends Annotation> |
subiterate(JCas jCas,
Class<T> type,
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 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 Annotation> Iterable<T> subiterate(JCas jCas, Class<T> type, 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 structures@Deprecated public static <T extends TOP> Iterator<T> iterator(JCas jCas, Class<T> type)
jcas.select(type).iterator()
T
- the JCas type.jCas
- a JCas.type
- a type.public static <T extends AnnotationFS> Iterator<T> iterator(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 Type getType(JCas jCas, Class<?> type)
jCas
- the JCas containing the type system.type
- the JCas wrapper class type.public static Type getAnnotationType(JCas jCas, Class<?> type)
Annotation
.jCas
- the JCas containing the type system.type
- the JCas wrapper class type.public static <T extends TOP> List<T> select(FSArray array, Class<T> type)
T
- the JCas type.array
- a feature structure array.type
- the type.public static <T extends TOP> List<T> select(FSList list, Class<T> type)
T
- the JCas type.list
- a feature structure list.type
- the type.public static <T extends TOP> Collection<T> select(JCas jCas, Class<T> type)
T
- the iteration type.jCas
- the JCas containing the type system.type
- the type.public static <T extends Annotation> List<T> selectAt(JCas jCas, Class<T> type, int aBegin, int aEnd)
T
- the type of annotations to fetch.jCas
- the CAS containing the annotations.type
- the type of annotations to fetch.aBegin
- the begin offset.aEnd
- the end offset.public static <T extends Annotation> T selectSingleAt(JCas jCas, Class<T> type, int aBegin, int aEnd)
T
- the type of annotations to fetch.jCas
- the CAS containing the annotations.type
- the type of annotations to fetch.aBegin
- the begin offset.aEnd
- the end offset.public static Collection<TOP> selectAll(JCas jCas)
jCas
- the JCas containing the type system. the type.public static <T extends Annotation> List<T> selectBetween(Class<T> type, AnnotationFS ann1, 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 Annotation> List<T> selectBetween(JCas jCas, Class<T> type, AnnotationFS ann1, 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 AnnotationFS> List<T> selectCovered(Class<T> type, AnnotationFS coveringAnnotation)
The covering annotation is never returned itself, even if it is of the queried-for type or a subtype of that type.
The method only returns properly covered annotations, that is annotations where the begin/end offsets are equal to the 'covering' annotation or where both the begin/end are included in the span of the 'covering' annotation. Partially overlapping annotations are not returned.
T
- the JCas type.type
- a UIMA type.coveringAnnotation
- the covering annotation.Subiterator
,
Order of selected feature structurespublic static <T extends Annotation> List<T> selectCovered(JCas jCas, Class<T> type, AnnotationFS coveringAnnotation)
The covering annotation is never returned itself, even if it is of the queried-for type or a subtype of that type.
The method only returns properly covered annotations, that is annotations where the begin/end offsets are equal to the 'covering' annotation or where both the begin/end are included in the span of the 'covering' annotation. Partially overlapping annotations are not returned.
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 Annotation> List<T> selectCovered(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.
The method only returns properly covered annotations, that is annotations where the begin/end offsets are equal to the given begin/end or where both the begin/end are included in the span of the given span. Partially overlapping annotations are not returned.
T
- the JCas type.jCas
- a JCas containing the annotation.type
- a UIMA type.begin
- begin offset.end
- end offset.public static <T extends Annotation> List<T> selectCovering(Class<T> type, AnnotationFS coveredAnnotation)
The method only returns properly covering annotations, that is annotations where the begin/end offsets are equal to the begin/end of the given annotation or where given 'covered' annotation is properly contained within the span of the 'covering' annotation. Partially overlapping annotations are not returned.
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 Annotation> List<T> selectCovering(JCas jCas, Class<T> type, AnnotationFS coveredAnnotation)
The method only returns properly covering annotations, that is annotations where the begin/end offsets are equal to the begin/end of the given annotation or where given 'covered' annotation is properly contained within the span of the 'covering' annotation. Partially overlapping annotations are not returned.
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 Annotation> List<T> selectCovering(JCas jCas, Class<T> type, int begin, int end)
The method only returns properly covering annotations, that is annotations where the begin/end offsets are equal to the given begin/end to or where given span is properly contained within the span of the 'covering' annotation. Partially overlapping annotations are not returned.
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 Annotation,S extends Annotation> Map<T,List<S>> indexCovering(JCas jCas, Class<? extends T> type, Class<? extends 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.
The method only returns properly covering annotations, that is annotations where the begin/end offsets are equal to the begin/end of the given annotation or where given 'covered' annotation is properly contained within the span of the 'covering' annotation. Partially overlapping annotations are not returned.
When querying for the annotations covering a given annotation, the given annotation itself is never returned, even if it is of the queried type.
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 Annotation,S extends Annotation> Map<T,List<S>> indexCovered(JCas jCas, Class<? extends T> type, Class<? extends 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.
The order of entries in the map is not defined. However, lists of covered annotations in
the map are guaranteed to be in the same order as in the UIMA default annotation index.
The method only returns properly covered annotations, that is annotations where the begin/end offsets are equal to the 'covering' annotation or where both the begin/end are included in the span of the 'covering' annotation. Partially overlapping annotations are not returned.
When querying for the annotations covered by a given annotation, the given annotation itself is never returned, even if it is of the queried type.
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 <T extends Annotation> List<T> selectOverlapping(Class<T> aType, AnnotationFS aBoundaryAnnotation)
aType
- a UIMA type.aBoundaryAnnotation
- the covering annotation.public static <T extends Annotation> List<T> selectOverlapping(JCas aJCas, Class<T> aType, AnnotationFS aBoundaryAnnotation)
aJCas
- a CAS.aType
- a UIMA type.aBoundaryAnnotation
- the covering annotation.public static <T extends Annotation> List<T> selectOverlapping(JCas aJCas, Class<T> aType, int aBegin, int aEnd)
aJCas
- a CAS.aType
- a UIMA type.aBegin
- begin offset.aEnd
- end offset.public static boolean contains(JCas jCas, AnnotationFS coveringAnnotation, Class<? extends Annotation> type)
jCas
- a JCas containing the annotation.coveringAnnotation
- the covering annotation.type
- a UIMA type.public static <T extends Annotation> T selectByIndex(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 TOP> T selectSingle(JCas jCas, Class<T> type)
T
- JCas wrapper type.jCas
- a JCas containing the annotation.type
- a UIMA type.public static <T extends Annotation> T selectSingleRelative(Class<T> aType, 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 Annotation> T selectSingleRelative(JCas aJCas, Class<T> aType, AnnotationFS aAnchor, int aPosition)
T
- the JCas type.aJCas
- a JCas.aType
- type of the annotation to be returned.aAnchor
- anchor annotationaPosition
- relative position to access. A negative value selects a preceding annotation while a
positive number selects a following annotation.IndexOutOfBoundsException
- if the relative position points beyond the type index bounds.IllegalArgumentException
- if the relative position is 0
and the anchor type does not subsume the
selected type.public static <T extends Annotation> List<T> selectPreceding(Class<T> aType, AnnotationFS annotation, int count)
T
- the JCas type.aType
- a type.annotation
- anchor annotationcount
- number of annotations to collectpublic static <T extends Annotation> List<T> selectPreceding(JCas aJCas, Class<T> aType, 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 Annotation> List<T> selectFollowing(Class<T> aType, AnnotationFS annotation, int count)
T
- the JCas type.aType
- a type.annotation
- anchor annotationcount
- number of annotations to collectpublic static <T extends Annotation> List<T> selectFollowing(JCas aJCas, Class<T> aType, 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 TOP> boolean exists(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 JCas getView(JCas jcas, String viewName, 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 JCas getView(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 AnnotationFS> List<String> toText(Iterable<T> iterable)
T
- UIMA JCas type.iterable
- annotation container.Copyright © 2012–2021 The Apache Software Foundation. All rights reserved.