Class Layers
layer keys for the results the toolkit produces itself.
This class is a convenience, not a registry: the key space stays open, and any producer may define further keys in its own package. New capabilities must never require an addition here to function.
Namespace rule: every key the toolkit itself defines carries the
opennlp: id prefix. An extension defines its keys under its own prefix, and
a bare id without a prefix is legal for an application-local layer, so ids from
independent producers cannot collide. Toolkit keys are created through
key(String, Class) and documentKey(String, Class), which apply the
prefix, so no producer spells it.
Gold versus predicted: a corpus may carry a hand-annotated version of a layer
beside a produced one. The convention is a gold: id prefix on the same key
scheme, for example gold:opennlp:tokens beside opennlp:tokens.
Because adding a layer is once-only, competing versions of a layer always live under
distinct keys and never replace each other.
Placement rule: this class holds only the keys of the core linguistic layers every pipeline shares (sentences, tokens, tags, entities). A capability-specific layer's key lives on the annotator that provides it, for example the lemma layer's key on its adapter, so adding a capability never touches this class.
- Since:
- 3.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionNamed entities; each annotation covers one mention and carries the entity type as its value.Part-of-speech tags; one annotation per token, aligned withTOKENSby position, carrying the tag.Sentence boundaries; each annotation covers one sentence and carries its text.Token boundaries; each annotation covers one token and carries its text. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> LayerKey<T> documentKey(String name, Class<T> type) Creates adocument-scopedkey in the toolkit'sopennlp:namespace, for a whole-document value the toolkit itself produces.static <T> LayerKey<T> Creates apositionalkey in the toolkit'sopennlp:namespace, for a layer the toolkit itself produces.
-
Field Details
-
SENTENCES
-
TOKENS
-
POS_TAGS
-
ENTITIES
-
-
Method Details
-
key
Creates apositionalkey in the toolkit'sopennlp:namespace, for a layer the toolkit itself produces.- Type Parameters:
T- The type of the annotation values.- Parameters:
name- The layer name without a namespace, for exampletokens. Must not benull, blank, or contain':'.type- The class of the annotation values stored under the key. Must not benull.- Returns:
- A key whose id is the name under the
opennlp:prefix. Nevernull. - Throws:
IllegalArgumentException- Thrown ifnameisnull, blank, or contains':', ortypeisnull.
-
documentKey
Creates adocument-scopedkey in the toolkit'sopennlp:namespace, for a whole-document value the toolkit itself produces.- Type Parameters:
T- The type of the annotation values.- Parameters:
name- The layer name without a namespace, for examplelanguage. Must not benull, blank, or contain':'.type- The class of the annotation values stored under the key. Must not benull.- Returns:
- A document-scoped key whose id is the name under the
opennlp:prefix. Nevernull. - Throws:
IllegalArgumentException- Thrown ifnameisnull, blank, or contains':', ortypeisnull.
-