Class StemmerAnnotator
java.lang.Object
opennlp.tools.stemmer.StemmerAnnotator
- All Implemented Interfaces:
opennlp.tools.document.DocumentAnnotator
public final class StemmerAnnotator
extends Object
implements opennlp.tools.document.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.
- Since:
- 3.0.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStemmerAnnotator(opennlp.tools.stemmer.Stemmer stemmer) Initializes the adapter. -
Method Summary
Modifier and TypeMethodDescriptionopennlp.tools.document.Documentannotate(opennlp.tools.document.Document document) Stems the token layer and adds theSTEMSlayer.Set<opennlp.tools.document.LayerKey<?>> provides()Set<opennlp.tools.document.LayerKey<?>> requires()toString()Returns the adapter's simple class name, which names it in pipeline validation messages.
-
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.
-
-
Constructor Details
-
StemmerAnnotator
public StemmerAnnotator(opennlp.tools.stemmer.Stemmer stemmer) Initializes the adapter.- Parameters:
stemmer- The stemmer to delegate to. Must not benull.- Throws:
IllegalArgumentException- Thrown ifstemmerisnull.
-
-
Method Details
-
annotate
public opennlp.tools.document.Document annotate(opennlp.tools.document.Document document) 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 interfaceopennlp.tools.document.DocumentAnnotator- 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 interfaceopennlp.tools.document.DocumentAnnotator
-
provides
- Specified by:
providesin interfaceopennlp.tools.document.DocumentAnnotator
-
toString
-