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

    Constructors
    Constructor
    Description
    SentenceDetectorAnnotator(opennlp.tools.sentdetect.SentenceDetector detector)
    Initializes the adapter.
  • Method Summary

    Modifier and Type
    Method
    Description
    opennlp.tools.document.Document
    annotate(opennlp.tools.document.Document document)
    Detects sentences over the document text and adds the Layers.SENTENCES layer, each sentence annotated with its covered text on its span.
    Set<opennlp.tools.document.LayerKey<?>>
    Returns the adapter's simple class name, which names it in pipeline validation messages.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

    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 be null.
      Throws:
      IllegalArgumentException - Thrown if detector is null.
  • Method Details

    • annotate

      public opennlp.tools.document.Document annotate(opennlp.tools.document.Document document)
      Detects sentences over the document text and adds the Layers.SENTENCES layer, each sentence annotated with its covered text on its span.
      Specified by:
      annotate in interface opennlp.tools.document.DocumentAnnotator
      Parameters:
      document - The document to annotate. Must not be null.
      Returns:
      A new Document with the Layers.SENTENCES layer added. Never null.
      Throws:
      IllegalArgumentException - Thrown if document is null or already carries the Layers.SENTENCES layer.
    • provides

      public Set<opennlp.tools.document.LayerKey<?>> provides()
      Specified by:
      provides in interface opennlp.tools.document.DocumentAnnotator
    • toString

      public String toString()
      Returns the adapter's simple class name, which names it in pipeline validation messages.
      Overrides:
      toString in class Object
      Returns:
      the adapter's simple class name, which names it in pipeline validation messages