Package opennlp.tools.sentdetect
Class SentenceDetectorAnnotator
java.lang.Object
opennlp.tools.sentdetect.SentenceDetectorAnnotator
- All Implemented Interfaces:
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.
The adapter holds no per-call state; it is as thread-safe as the detector it wraps.
- Since:
- 3.0.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSentenceDetectorAnnotator(SentenceDetector detector) Initializes the adapter. -
Method Summary
Modifier and TypeMethodDescriptionDetects sentences over the document text and adds theLayers.SENTENCESlayer, each sentence annotated with its covered text on its span.provides()toString()Returns the adapter's simple class name, which names it in pipeline validation messages.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface opennlp.tools.document.DocumentAnnotator
requires
-
Field Details
-
detector
-
-
Constructor Details
-
SentenceDetectorAnnotator
Initializes the adapter.- Parameters:
detector- The sentence detector to delegate to. Must not benull.- Throws:
IllegalArgumentException- Thrown ifdetectorisnull.
-
-
Method Details
-
annotate
Detects sentences over the document text and adds theLayers.SENTENCESlayer, each sentence annotated with its covered text on its span.- Specified by:
annotatein interfaceDocumentAnnotator- 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 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.
-