I am trying to use a Java library called langdetecthosted here . It could not be easier to use:
Detector detector;
String langDetected = "";
try {
String path = "C:/Users/myUser/Desktop/jars/langdetect/profiles";
DetectorFactory.loadProfile(path);
detector = DetectorFactory.create();
detector.append(text);
langDetected = detector.detect();
}
catch (LangDetectException e) {
throw e;
}
return langDetected;
Except in relation to the method DetectFactory.loadProfile. This library works fine when I give it the absolute path to the file, but in the end it seems to me that I need to pack the code and the langdetectcompanion directory profilesinto the same JAR file:
myapp.jar/
META-INF/
langdetect/
profiles/
af
bn
en
...etc.
com/
me/
myorg/
LangDetectAdaptor
I make sure that LangDetectAdaptorwhich is inside myapp.jaris supplied with both dependencies langdetect.jarand those jsonic.jarthat are necessary langdetectfor working at runtime. However, I am confused by what I need to pass in DetectFactory.loadProfileto work:
langdetect JAR profiles, JAR. profiles JAR ( ), langdetect.jar, ?
!
. , , langdetect profiles, , JAR. API, , , profiles , DetectFactory.loadProfiles().except("fr"), , .. " !