!7 lib 1400180 // github.com/optimaize/language-detector import com.optimaize.langdetect.*; import com.optimaize.langdetect.i18n.*; import com.optimaize.langdetect.ngram.*; import com.optimaize.langdetect.profiles.*; import com.optimaize.langdetect.text.*; p-exp { new LanguageProfileReader profileReader; //L languageProfiles = profileReader.readAllBuiltIn(); L languageProfiles = ll(profileReader.readBuiltIn(LdLocale.fromString("de")), profileReader.readBuiltIn(LdLocale.fromString("en"))); LanguageDetector languageDetector = LanguageDetectorBuilder.create(NgramExtractors.standard()) .withProfiles(languageProfiles) .build(); // create a text object factory TextObjectFactory textObjectFactory = CommonTextObjectFactories.forDetectingOnLargeText(); // query for (S text : ll("hello world", "hallo welt")) { TextObject textObject = textObjectFactory.forText(text); LdLocale lang = languageDetector.detect(textObject).orElse(null); print(text + " => " + lang); } }