Class LayerKey<T>
java.lang.Object
opennlp.tools.document.LayerKey<T>
- Type Parameters:
T- The type of the annotation values stored under this key.
Identifies one annotation layer of a
Document and carries the type of that
layer's annotation values, so reading a layer back is statically typed.
The key space is deliberately open: any producer may define new keys in its own
package, and the container never enumerates them. Two keys are equal when their id,
their value type, and their LayerKey.Scope are equal, so independently created
constants for the same layer interoperate. Standard keys for the toolkit's own
results live in Layers.
A key declares its LayerKey.Scope: a positional key
guarantees a span on every annotation, and a document-scoped
key carries whole-document values without spans, for example a language id or a
category distribution. The scope is declared per key, never per annotation, so
consumers of a positional layer never null-check a span.
- Since:
- 3.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow the annotations of a layer relate to the document text. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> LayerKey<T> Creates adocument-scopedLayerKeyfor values that describe the document as a whole, for example a language id, a category distribution, or provenance.booleaninthashCode()id()static <T> LayerKey<T> Creates aLayerKey.scope()toString()type()
-
Method Details
-
of
Creates aLayerKey.- Type Parameters:
T- The type of the annotation values.- Parameters:
id- The layer identifier, for exampleopennlp:tokens. Keys defined by the toolkit carry theopennlp:prefix, an extension uses its own prefix, and a bare id is legal for an application-local layer. Must not benullor blank.type- The class of the annotation values stored under the key. Must not benull.- Returns:
- A
positionalLayerKey. Nevernull. - Throws:
IllegalArgumentException- Thrown ifidisnullor blank, ortypeisnull.
-
document
Creates adocument-scopedLayerKeyfor values that describe the document as a whole, for example a language id, a category distribution, or provenance. Annotations under such a key carry no span.- Type Parameters:
T- The type of the annotation values.- Parameters:
id- The layer identifier, following the same prefix rules asof(String, Class). Must not benullor blank.type- The class of the annotation values stored under the key. Must not benull.- Returns:
- A document-scoped
LayerKey. Nevernull. - Throws:
IllegalArgumentException- Thrown ifidisnullor blank, ortypeisnull.
-
id
- Returns:
- The layer identifier. Never
null.
-
type
-
scope
- Returns:
- The declared scope of the layer. Never
null.
-
equals
-
hashCode
-
toString
-