Original library: https://developers.google.com/ml-kit/language/identification
Usage: https://developers.google.com/ml-kit/language/identification/android
Supported languages: https://developers.google.com/ml-kit/language/identification/langid-support
With ML Kit's on-device language identification API, you can determine the language of a string of text.
Language identification can be useful when working with user-provided text, which often doesn't come with any language information.

Install with SDK Manager:
Add this to manifest:
Usage: https://developers.google.com/ml-kit/language/identification/android
Supported languages: https://developers.google.com/ml-kit/language/identification/langid-support
With ML Kit's on-device language identification API, you can determine the language of a string of text.
Language identification can be useful when working with user-provided text, which often doesn't come with any language information.


MlKitLanguageId
Author: Author: Google - B4a Wrapper: Pendrush
Version: 1.0
- MlKitLanguageId
- Events:
- OnError (Error As String)
- OnSuccess (Language As String)
- OnSuccessAll (Languages As Map)
- Functions:
- IdentifyLanguage (InputText As String, SetConfidenceThreshold As Float)
If the call succeeds, a BCP-47 language code is passed to the OnSuccess event, indicating the language of the text.
If no language is confidently detected, the code 'und' (undetermined) is passed.
SetConfidenceThreshold - From 0.01 to 1
MlKitLanguageId1.IdentifyLanguage("Hello", 0.01)- IdentifyPossibleLanguages (InputText As String, SetConfidenceThreshold As Float)
To get the confidence values of a string's most likely languages, pass the string to the IdentifyPossibleLanguages() method.
From each object, you can get the language's BCP-47 code and the confidence that the string is in that language.
Note that these values indicate the confidence that the entire string is in the given language.
ML Kit doesn't identify multiple languages in a single string.
SetConfidenceThreshold - From 0.01 to 1
MlKitLanguageId1.IdentifyPossibleLanguages("Hello", 0.01)- Initialize (EventName As String)
Initialize MlKitLanguageId
MlKitLanguageId1.Initialize("MlKitLanguageId1")- IsInitialized As Boolean
Install with SDK Manager:
B4X:
com.google.mlkit:language-id
com.google.mlkit:common
androidx.lifecycle:lifecycle-common
com.google.android.gms:play-services-tasks
com.google.firebase:firebase-encoders
com.google.firebase:firebase-encoders-json
Add this to manifest:
B4X:
AddApplicationText(<provider
android:name="com.google.mlkit.common.internal.MlKitInitProvider"
android:authorities="${applicationId}.mlkitinitprovider"
android:exported="false"
android:initOrder="99" />
<service
android:name="com.google.mlkit.common.internal.MlKitComponentDiscoveryService"
android:exported="false" >
<meta-data
android:name="com.google.firebase.components:com.google.mlkit.nl.languageid.LanguageIdRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.mlkit.common.internal.CommonComponentRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>)
Attachments
Last edited: