Package opennlp.tools.sentdetect

# Class ThreadSafeSentenceDetectorME

java.lang.Object
opennlp.tools.sentdetect.ThreadSafeSentenceDetectorME

All Implemented Interfaces:
  `AutoCloseable`, `opennlp.tools.ml.Probabilistic`, `opennlp.tools.sentdetect.SentenceDetector`

@Deprecated(since="3.0.0") @ThreadSafe public class ThreadSafeSentenceDetectorME extends Object implements opennlp.tools.sentdetect.SentenceDetector, opennlp.tools.ml.Probabilistic, AutoCloseable
Deprecated.
As of OPENNLP-1816, `SentenceDetectorME` is itself thread-safe. Use it directly instead.
A thread-safe version of `SentenceDetectorME`. Using it is completely transparent. You can use it in a single-threaded context as well, it only incurs a minimal overhead.

Note:
This implementation uses a `ThreadLocal`. Although the implementation is lightweight because the model is not duplicated, if you have many long-running threads, you may run into memory problems.

Be careful when using this in a Jakarta EE application, for example.

The user is responsible for clearing the `ThreadLocal` via calling `close()`.

See Also:
  - `Probabilistic`
  - `SentenceDetector`
  - `SentenceDetectorME`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ThreadSafeSentenceDetectorME(String language)`
  Deprecated.
  Initializes a `ThreadSafeSentenceDetectorME` by downloading a default model for a given `language`.
  `ThreadSafeSentenceDetectorME(SentenceModel model)`
  Deprecated.
  Initializes a `ThreadSafeSentenceDetectorME` with the specified `model`.
  `ThreadSafeSentenceDetectorME(SentenceModel model, Dictionary abbDict)`
  Deprecated.
  Instantiates a `ThreadSafeSentenceDetectorME` with an existing `SentenceModel`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Deprecated.
  `double[]`
  `getSentenceProbabilities()`
  Deprecated.
  Use `probs()` instead.
  `double[]`
  `probs()`
  Deprecated.
  `String[]`
  `sentDetect(CharSequence s)`
  Deprecated.
  `opennlp.tools.util.Span[]`
  `sentPosDetect(CharSequence s)`
  Deprecated.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ThreadSafeSentenceDetectorME

    public ThreadSafeSentenceDetectorME(String language) throws IOException
    Deprecated.
    Initializes a `ThreadSafeSentenceDetectorME` by downloading a default model for a given `language`.
    Parameters:
      `language` - An ISO conform language code.
    Throws:
      `IOException` - Thrown if the model could not be downloaded or saved.

  - ### ThreadSafeSentenceDetectorME

    public ThreadSafeSentenceDetectorME(SentenceModel model)
    Deprecated.
    Initializes a `ThreadSafeSentenceDetectorME` with the specified `model`.
    Parameters:
      `model` - A valid `SentenceModel`.

  - ### ThreadSafeSentenceDetectorME

    public ThreadSafeSentenceDetectorME(SentenceModel model, Dictionary abbDict)
    Deprecated.
    Instantiates a `ThreadSafeSentenceDetectorME` with an existing `SentenceModel`.
    Parameters:
      `model` - The `SentenceModel` to be used.
      `abbDict` - The `Dictionary` to be used. It must fit the language of the `model`.

- ## Method Details

  - ### sentDetect

    public String[] sentDetect(CharSequence s)
    Deprecated.
    Specified by:
      `sentDetect` in interface `opennlp.tools.sentdetect.SentenceDetector`

  - ### sentPosDetect

    public opennlp.tools.util.Span[] sentPosDetect(CharSequence s)
    Deprecated.
    Specified by:
      `sentPosDetect` in interface `opennlp.tools.sentdetect.SentenceDetector`

  - ### getSentenceProbabilities

    @Deprecated public double[] getSentenceProbabilities()
    Deprecated.
    Use `probs()` instead.

  - ### probs

    public double[] probs()
    Deprecated.
    Specified by:
      `probs` in interface `opennlp.tools.ml.Probabilistic`

  - ### close

    public void close()
    Deprecated.
    Specified by:
      `close` in interface `AutoCloseable`