public final class LanguageIdentifier
- Object
- LanguageIdentifier
Identifies possible languages entirely on device. Results are ranked by
descending backend confidence and filtered by
LanguageOptions.getMinimumConfidence().Nested types
class LanguageIdentifier.Session | Reusable owner of a native language-identification backend. |
Methods
Inherited methods
Method details
isSupported
public static boolean isSupported()Returns
whether automatic language identification is available
isSupported
public static boolean isSupported(LanguageOptions options)Parameters
optionsLanguageOptions- backend selection, or
nullfor defaults
Returns
whether the selected backend is available on this target
open
public static LanguageIdentifier.Session open(LanguageOptions options)Opens a reusable language-identification session. Reusing a session
avoids repeatedly creating the native recognizer when classifying many
strings. Close it when no more identifications are pending.
Parameters
optionsLanguageOptions- backend and confidence options, or
null
Returns
a reusable session that owns one native language backend
Throws
UnsupportedOperationException- if the selected backend is absent
identify
public static AsyncResource<LanguageCandidate[]> identify(String text, LanguageOptions options)Identifies possible languages off the EDT without uploading text. The
option values are copied before the backend starts, so later mutations
of the supplied object cannot alter the pending identification.
Cancelling the returned resource suppresses late result callbacks; the
temporary backend is released after its pending native work settles.
Parameters
textString- non-null text to classify
optionsLanguageOptions- backend and confidence options, or
null
Returns
asynchronous ranked candidates; may be empty for undetermined text