Record Class Annotation<T>
java.lang.Object
java.lang.Record
opennlp.tools.document.Annotation<T>
- Type Parameters:
T- The type of the annotation value.- Record Components:
span- The location of the annotation in the original text, ornullfor a value under a document-scoped key.value- The annotation value. Must not benull.
One annotation of a
Document: a typed value anchored to a Span of the
document's original text, or a span-less value under a
document-scoped key.
The span always refers to the text the document was created with, never to a normalized or otherwise derived form, so any annotation can be highlighted in what the caller supplied. Whether a span is present is decided by the layer key's scope, not per annotation: the container rejects a span-less annotation under a positional key and a spanned annotation under a document-scoped key. Annotations that need to reference other annotations, for example a dependency arc naming its head token, do so by the index of the target annotation within its layer, never by object identity.
- Since:
- 3.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static <T> Annotation<T> of(T value) Creates a span-less annotation for adocument-scopedlayer.span()Returns the value of thespanrecord component.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Annotation
Validates the annotation.- Throws:
IllegalArgumentException- Thrown ifvalueisnull.
-
-
Method Details
-
of
Creates a span-less annotation for adocument-scopedlayer.- Type Parameters:
T- The type of the annotation value.- Parameters:
value- The annotation value. Must not benull.- Returns:
- An
Annotationwithout a span. Nevernull. - Throws:
IllegalArgumentException- Thrown ifvalueisnull.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
span
-
value
-