public interface AnnotationSet extends Iterable<Annotation>
An AnnotationSet
acts as the storage mechanism for annotations associated with a document. It
provides methods for adding, removing, and navigating the annotations. In particular, a AnnotationSet
defines sequential methods of accessing annotations (next(Annotation, AnnotationType)
, previous(Annotation, AnnotationType)
), based on criteria select(Predicate)
and select(Span,
Predicate)
, and by id get(long)
.
Annotation sets also keep track of completed annotation types, i.e. those processed using a Pipeline
.
This allows the pipeline to ignore further attempts to annotate a type that is marked complete. In addition to being
marked complete, information about the annotator is stored.
Modifier and Type | Method and Description |
---|---|
void |
add(Annotation annotation)
Adds an annotation to the set
|
boolean |
contains(Annotation annotation)
Checks if an annotation is in the set or not
|
Annotation |
get(long id)
Gets the annotation for the given id
|
String |
getAnnotationProvider(AnnotatableType type)
Gets information on what annotator provided the annotation of the given type
|
Set<AnnotatableType> |
getCompleted()
Gets completed annotations.
|
boolean |
isCompleted(AnnotatableType type)
Gets if the given annotation type is completed or not
|
Annotation |
next(Annotation annotation,
AnnotationType type)
Gets the first annotation after a given one of the same type
|
Annotation |
previous(Annotation annotation,
AnnotationType type)
Gets the first annotation before a given one of the same type
|
void |
remove(Annotation annotation)
Removes an annotation from the document
|
default List<Annotation> |
removeAll(AnnotationType type)
Removes all annotations of a given type and marks that type as not completed.
|
List<Annotation> |
select(Predicate<? super Annotation> criteria)
Selects all annotations of a given annotation type and matching a given criteria.
|
List<Annotation> |
select(Span span,
Predicate<? super Annotation> criteria)
Selects all annotations of a given annotation type within a given range and matching a given criteria.
|
void |
setIsCompleted(AnnotatableType type,
boolean isCompleted,
String annotatorInformation)
Sets the given annotation type as being completed or not
|
int |
size()
The number of annotations in the set
|
forEach, iterator, spliterator
List<Annotation> select(Span span, Predicate<? super Annotation> criteria)
Selects all annotations of a given annotation type within a given range and matching a given criteria.
span
- the range in which to search form annotationscriteria
- the criteria that an annotation must matchList<Annotation> select(Predicate<? super Annotation> criteria)
Selects all annotations of a given annotation type and matching a given criteria.
criteria
- the criteria that an annotation must matchvoid setIsCompleted(AnnotatableType type, boolean isCompleted, String annotatorInformation)
type
- the annotation typeisCompleted
- True if the annotation is completed, False if not.annotatorInformation
- the annotator informationboolean isCompleted(AnnotatableType type)
type
- the annotation typeString getAnnotationProvider(AnnotatableType type)
type
- The annotation typeSet<AnnotatableType> getCompleted()
default List<Annotation> removeAll(AnnotationType type)
type
- the typeAnnotation get(long id)
id
- The id of the annotationboolean contains(Annotation annotation)
annotation
- The annotation to checkvoid remove(Annotation annotation)
annotation
- The annotation to detachvoid add(Annotation annotation)
annotation
- The annotation to attachAnnotation next(Annotation annotation, AnnotationType type)
annotation
- The annotation we want the next fortype
- the type of the next annotation wantedAnnotation previous(Annotation annotation, AnnotationType type)
annotation
- The annotation we want the previous fortype
- the type of the previous annotation wantedint size()
Copyright © 2016. All rights reserved.