Class LemmatizerAnnotator
- All Implemented Interfaces:
DocumentAnnotator
Lemmatizer to the document pipeline: reads Layers.SENTENCES,
Layers.TOKENS, and Layers.POS_TAGS and provides LEMMAS, one
annotation per token on the token's span.
Each sentence is lemmatized separately, the way the lemmatizer contract expects its
input, so lemmatization decisions never cross a sentence boundary. Token spans already
refer to the original document text, so only the token and tag sequences handed to the
lemmatizer are sliced per sentence; the produced lemma layer stays aligned with
Layers.TOKENS by position.
The adapter holds no per-call state; it is as thread-safe as the lemmatizer it wraps.
- Since:
- 3.0.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
LEMMAS
The lemma layer. It is aligned with the token layer by position, and each annotation carries the lemma of its token on that token's span. -
lemmatizer
-
-
Constructor Details
-
LemmatizerAnnotator
Initializes the adapter.- Parameters:
lemmatizer- The lemmatizer to delegate to. Must not benull.- Throws:
IllegalArgumentException- Thrown iflemmatizerisnull.
-
-
Method Details
-
annotate
Lemmatizes the document sentence by sentence and adds theLEMMASlayer.For every sentence, the tokens whose spans lie inside the sentence span are lemmatized as one sequence together with their tags, and each lemma is emitted on its token's span. The required layers must be present, but they may be empty: a document without sentences or tokens yields a present-but-empty lemma layer, and a sentence containing no tokens contributes nothing.
- Specified by:
annotatein interfaceDocumentAnnotator- Parameters:
document- The document to annotate. Must not benulland must carry theLayers.SENTENCESandLayers.TOKENSlayers and aLayers.POS_TAGSlayer with exactly one tag per token, with every token lying inside a sentence.- Returns:
- A new
Documentwith theLEMMASlayer added. Nevernull. - Throws:
IllegalArgumentException- Thrown ifdocumentisnull, the sentence layer, the token layer, or the tag layer is absent, the tag layer does not have exactly one tag per token, a token lies outside every sentence, or the lemmatizer does not return one lemma per token of a sentence.
-
requires
- Specified by:
requiresin interfaceDocumentAnnotator- Returns:
- The keys of the layers this annotator reads. Never
null.
-
provides
- Specified by:
providesin interfaceDocumentAnnotator- Returns:
- The keys of the layers this annotator adds. Never
null.
-
toString
Returns the adapter's simple class name, which names it in pipeline validation messages.
-