Open fabiankessler opened 10 years ago
Just tried 0.5 on android 'com.optimaize.languagedetector:language-detector:0.5'
I get Caused by: java.lang.ClassNotFoundException: Didn't find class "java.lang.Character$UnicodeScript"
when I try to recognize with
public class Translator {
private LanguageDetector languageDetector;
public Translator() {
try {
List<LanguageProfile> languageProfiles = new LanguageProfileReader().readAllBuiltIn();
languageDetector = LanguageDetectorBuilder.create(NgramExtractors.standard())
.withProfiles(languageProfiles)
.build();
} catch (IOException e) {
Log.e("AAA", "ERROR", e);
}
}
public LdLocale recognize(String text) {
TextObjectFactory textObjectFactory = text.length() > 10 ? forDetectingOnLargeText() : forIndexingCleanText();
Optional<LdLocale> locale = languageDetector.detect(textObjectFactory.forText(text));
return locale.isPresent() ? locale.get() : null;
}
}
translator = new Translator();
translate.recognize("this is a text really big that I am trying to write")
@fabiankessler You know why?
@danielgomezrico because on android the Character.UnicodeScript doesn't exist, but the RemoveMinorityScriptsTextFilter uses this class.
@epfisztner @caipivara Character.UnicodeScript has recently been added into Android API 24
https://developer.android.com/reference/java/lang/Character.UnicodeScript.html
As done here https://github.com/rmtheis/language-detection