0
我試過this庫,在堆棧溢出的職位之一建議,機器人自動檢測語言
我添加的lib的jar到我的構建路徑,但我不能初始化DetectorFactory類與語言的配置文件。
這是類處理的檢測,如在其樣品中的一個提示:
class LanguageDetector {
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<Language> detectLangs(String text) throws LangDetectException {
Detector detector = DetectorFactory.create();
detector.append(text);
return detector.getProbabilities();
}
}
簡檔被存儲在myProject的/簡檔的所有語言。 試圖將類實例崩潰我的應用程序沒有任何有用的消息logcat的
調用類():
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
context = this.getActivity().getApplicationContext();
/* LanguageDetector detector = null;
try {
detector.init("/waggle/profiles");
} catch (LangDetectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
new GetDataTask().execute(context);
}
你好,我不知道什麼路徑傳遞爲p 'LanguageDetector.init(「/ waggle/profiles」)中的rofiile。你能幫我嗎 ? – AndyN
我得到'FileNotFoundException' – AndyN
我複製了配置文件文件夾並將其粘貼到res文件夾中並設置其路徑,但現在它顯示錯誤com.cybozu.labs.langdetect.LangDetectException:未找到配置文件: –