Package opennlp.tools.langdetect

# Class ThreadSafeLanguageDetectorME

java.lang.Object
opennlp.tools.langdetect.ThreadSafeLanguageDetectorME

All Implemented Interfaces:
  `AutoCloseable`, `opennlp.tools.langdetect.LanguageDetector`

@Deprecated(since="3.0.0") @ThreadSafe public class ThreadSafeLanguageDetectorME extends Object implements opennlp.tools.langdetect.LanguageDetector, AutoCloseable
Deprecated.
As of OPENNLP-1816, `LanguageDetectorME` is itself thread-safe. Use it directly instead.
A thread-safe version of the `LanguageDetectorME`. 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:
  - `LanguageDetector`
  - `LanguageDetectorME`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ThreadSafeLanguageDetectorME(LanguageDetectorModel model)`
  Deprecated.
  Initializes a `ThreadSafeLanguageDetectorME` with the specified `model`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Deprecated.
  `String[]`
  `getSupportedLanguages()`
  Deprecated.
  `opennlp.tools.langdetect.Language`
  `predictLanguage(CharSequence content)`
  Deprecated.
  `opennlp.tools.langdetect.Language[]`
  `predictLanguages(CharSequence content)`
  Deprecated.

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

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

- ## Constructor Details

  - ### ThreadSafeLanguageDetectorME

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

- ## Method Details

  - ### predictLanguages

    public opennlp.tools.langdetect.Language[] predictLanguages(CharSequence content)
    Deprecated.
    Specified by:
      `predictLanguages` in interface `opennlp.tools.langdetect.LanguageDetector`

  - ### predictLanguage

    public opennlp.tools.langdetect.Language predictLanguage(CharSequence content)
    Deprecated.
    Specified by:
      `predictLanguage` in interface `opennlp.tools.langdetect.LanguageDetector`

  - ### getSupportedLanguages

    public String[] getSupportedLanguages()
    Deprecated.
    Specified by:
      `getSupportedLanguages` in interface `opennlp.tools.langdetect.LanguageDetector`

  - ### close

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