Class SentenceDetectorAnnotator
java.lang.Object
opennlp.tools.sentdetect.SentenceDetectorAnnotator
- All Implemented Interfaces:
opennlp.tools.document.DocumentAnnotator
public final class SentenceDetectorAnnotator
extends Object
implements opennlp.tools.document.DocumentAnnotator
Adapts a
SentenceDetector to the document pipeline: provides
Layers.SENTENCES from the document text.
The wrapped detector stays the primary API for single-task use; this adapter calls it like any other caller would.
- Since:
- 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionSentenceDetectorAnnotator(opennlp.tools.sentdetect.SentenceDetector detector) Initializes the adapter. -
Method Summary
Modifier and TypeMethodDescriptionopennlp.tools.document.Documentannotate(opennlp.tools.document.Document document) Detects sentences over the document text and adds theLayers.SENTENCESlayer, each sentence annotated with its covered text on its span.Set<opennlp.tools.document.LayerKey<?>> provides()toString()Returns the adapter's simple class name, which names it in pipeline validation messages.Methods inherited from interface opennlp.tools.document.DocumentAnnotator
requires
-
Constructor Details
-
SentenceDetectorAnnotator
public SentenceDetectorAnnotator(opennlp.tools.sentdetect.SentenceDetector detector) Initializes the adapter.- Parameters:
detector- The sentence detector to delegate to. Must not benull.- Throws:
IllegalArgumentException- Thrown ifdetectorisnull.
-
-
Method Details
-
annotate
public opennlp.tools.document.Document annotate(opennlp.tools.document.Document document) Detects sentences over the document text and adds theLayers.SENTENCESlayer, each sentence annotated with its covered text on its span.- Specified by:
annotatein interfaceopennlp.tools.document.DocumentAnnotator- Parameters:
document- The document to annotate. Must not benull.- Returns:
- A new
Documentwith theLayers.SENTENCESlayer added. Nevernull. - Throws:
IllegalArgumentException- Thrown ifdocumentisnullor already carries theLayers.SENTENCESlayer.
-
provides
- Specified by:
providesin interfaceopennlp.tools.document.DocumentAnnotator
-
toString
-