ntc-langdetect is a library Language Detector using Apache OpenNLP
<dependency>
<groupId>com.streetcodevn</groupId>
<artifactId>ntc-langdetect</artifactId>
<version>1.0.0</version>
</dependency>
# Build
mvn package
or
mvn -Dmaven.test.skip=true package
# Clean
mvn clean install
LangDetect ld = new LangDetect();
String s = "anh yêu em";
// Get the most probable language
Language bestLanguage = ld.langDetect(s);
System.out.println("bestLanguage: " + bestLanguage.toString());
// or
Language bestLanguage = ld.getLdME().predictLanguage(s);
System.out.println("bestLanguage: " + bestLanguage.toString());
This code is under the Apache License v2.