Package opennlp.tools.langdetect
Class ThreadSafeLanguageDetectorME
java.lang.Object
opennlp.tools.langdetect.ThreadSafeLanguageDetectorME
- All Implemented Interfaces:
Serializable
,AutoCloseable
,LanguageDetector
@ThreadSafe
public class ThreadSafeLanguageDetectorME
extends Object
implements LanguageDetector, AutoCloseable
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.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
String[]
predictLanguage
(CharSequence content) Predicts theLanguage
for the fullcontent
length.Language[]
predictLanguages
(CharSequence content) Predicts thelanguages
for the fullcontent
length.
-
Constructor Details
-
ThreadSafeLanguageDetectorME
Initializes aThreadSafeLanguageDetectorME
with the specifiedmodel
.- Parameters:
model
- A validLanguageDetectorModel
.
-
-
Method Details
-
predictLanguages
Description copied from interface:LanguageDetector
Predicts thelanguages
for the fullcontent
length.- Specified by:
predictLanguages
in interfaceLanguageDetector
- Parameters:
content
- The textual content to detect potentiallanguages
from.- Returns:
- the predicted languages
-
predictLanguage
Description copied from interface:LanguageDetector
Predicts theLanguage
for the fullcontent
length.- Specified by:
predictLanguage
in interfaceLanguageDetector
- Parameters:
content
- The textual content to detect potentiallanguages
from.- Returns:
- the language with the highest confidence
-
getSupportedLanguages
- Specified by:
getSupportedLanguages
in interfaceLanguageDetector
- Returns:
- Retrieves an array of language (codes) that are supported by a
LanguageDetector
.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-