public final class LanguageDetectorImpl extends Object implements LanguageDetector
This class is immutable and thus thread-safe.
Modifier and Type | Method and Description |
---|---|
com.google.common.base.Optional<LdLocale> |
detect(CharSequence text)
Returns the best detected language if the algorithm is very confident.
|
List<DetectedLanguage> |
getProbabilities(CharSequence text)
Returns all languages with at least some likeliness.
|
public com.google.common.base.Optional<LdLocale> detect(CharSequence text)
LanguageDetector
Note: you may want to use getProbabilities() instead. This here is very strict, and sometimes returns absent even though the first choice in getProbabilities() is correct.
detect
in interface LanguageDetector
text
- You probably want a TextObject
.public List<DetectedLanguage> getProbabilities(CharSequence text)
LanguageDetector
There is a configurable cutoff applied for languages with very low probability.
The way the algorithm currently works, it can be that, for example, this method returns a 0.99 for Danish and less than 0.01 for Norwegian, and still they have almost the same chance. It would be nice if this could be improved in future versions.
getProbabilities
in interface LanguageDetector
text
- You probably want a TextObject
.Copyright © 2022. All rights reserved.