You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to use this language-detection library for my project, but got a problem.
I think this is so basic to you, but I'm rather new to Java.
The problem is that I cannot compile it.
The example code you made worked well, but a test code using it (see below) didn't work.
I got this error message:
"test.java:26: error: unreported exception LangDetectException; must be caught or declared to be thrown
LangDetect.init("./profiles");
^
test.java:27: error: unreported exception LangDetectException; must be caught or declared to be thrown
String dd=LangDetect.detect("Hellow world");
^
2 errors."
Thank you for your great work.
I need to use this language-detection library for my project, but got a problem.
I think this is so basic to you, but I'm rather new to Java.
The problem is that I cannot compile it.
The example code you made worked well, but a test code using it (see below) didn't work.
I got this error message:
"test.java:26: error: unreported exception LangDetectException; must be caught or declared to be thrown
LangDetect.init("./profiles");
^
test.java:27: error: unreported exception LangDetectException; must be caught or declared to be thrown
String dd=LangDetect.detect("Hellow world");
^
2 errors."
And here is the test code.
package com.cybozu.labs.langdetect;
import java.util.ArrayList;
import com.cybozu.labs.langdetect.Detector;
import com.cybozu.labs.langdetect.DetectorFactory;
import com.cybozu.labs.langdetect.Language;
class LangDetect{
public static void init(String profileDirectory) throws LangDetectException {
DetectorFactory.loadProfile(profileDirectory);
}
public static 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();
}
}
class testLD{
public static void main(String[] args){
LangDetect.init("./profiles");
String dd=LangDetect.detect("Hellow world");
System.out.println(dd);
}
}
Would you please let me know how to use it?
Thank you.
The text was updated successfully, but these errors were encountered: