I am trying to build a program that will take a sentence from user and return the language of the text to the user.
When I run my application, I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: net/arnx/jsonic/JSONException
Does this mean I have to download jsonic and add it as a jar file to my application?
import java.util.ArrayList;
import com.cybozu.labs.langdetect.Detector;
import com.cybozu.labs.langdetect.DetectorFactory;
import com.cybozu.labs.langdetect.Language;
import java.util.Scanner;
import com.cybozu.labs.langdetect.LangDetectException;
public class LangDetectSample {
public void init(String profileDirectory) throws LangDetectException {
DetectorFactory.loadProfile(profileDirectory);
}
public String detect(String text) throws LangDetectException {
Detector detector = DetectorFactory.create();
detector.append(text);
return detector.detect();
}
public ArrayList detectLangs(String text) throws LangDetectException {
Detector detector = DetectorFactory.create();
detector.append(text);
return detector.getProbabilities();
}
public static void main(String[] args) throws LangDetectException {
LangDetectSample detector = new LangDetectSample();
Scanner scanner = new Scanner(System.in);
System.out.print("Enter text: ");
String input = scanner.nextLine();
String language = detector.detect(input);
System.out.print(language);
}
}