Class LanguageIdentifier
java.lang.Object
com.codename1.ai.language.LanguageIdentifier
Identifies possible languages entirely on device. Results are ranked by
descending backend confidence and filtered by
LanguageOptions.getMinimumConfidence().-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classReusable owner of a native language-identification backend. -
Method Summary
Modifier and TypeMethodDescriptionstatic AsyncResource<LanguageCandidate[]> identify(String text, LanguageOptions options) Identifies possible languages off the EDT without uploading text.static booleanstatic booleanisSupported(LanguageOptions options) static LanguageIdentifier.Sessionopen(LanguageOptions options) Opens a reusable language-identification session.
-
Method Details
-
isSupported
public static boolean isSupported()- Returns:
- whether automatic language identification is available
-
isSupported
- Parameters:
options- backend selection, ornullfor defaults- Returns:
- whether the selected backend is available on this target
-
open
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:
options- backend and confidence options, ornull- Returns:
- a reusable session that owns one native language backend
- Throws:
UnsupportedOperationException- if the selected backend is absent
-
identify
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:
text- non-null text to classifyoptions- backend and confidence options, ornull- Returns:
- asynchronous ranked candidates; may be empty for undetermined text
-