Package opennlp.tools.stemmer
Class StemmerAnnotator
java.lang.Object
opennlp.tools.stemmer.StemmerAnnotator
- All Implemented Interfaces:
DocumentAnnotator
Adapts a
Stemmer to the document pipeline: stems the token layer and provides
STEMS, one annotation per token on the token's span.
Stemming operates on the token surface alone, so this annotator requires only the token layer; no part-of-speech tags are involved.
The adapter holds no per-call state; it is as thread-safe as the stemmer it wraps.
- Since:
- 3.0.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
STEMS
The stem layer. It is aligned with the token layer by position, and each annotation carries the stem of its token on that token's span. -
stemmer
-
-
Constructor Details
-
StemmerAnnotator
Initializes the adapter.- Parameters:
stemmer- The stemmer to delegate to. Must not benull.- Throws:
IllegalArgumentException- Thrown ifstemmerisnull.
-
-
Method Details
-
annotate
Stems the token layer and adds theSTEMSlayer.The token layer must be present, but it may be empty: a document without tokens yields a present-but-empty stem layer.
- Specified by:
annotatein interfaceDocumentAnnotator- Parameters:
document- The document to annotate. Must not benulland must carry theLayers.TOKENSlayer.- Returns:
- A new
Documentwith theSTEMSlayer added. Nevernull. - Throws:
IllegalArgumentException- Thrown ifdocumentisnullor the token layer is absent.
-
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.
-