私はこのライブラリを試しました。スタックオーバーフローに関する投稿の1つで提案されていますが、
libのjarをビルドパスに追加しましたが、言語のプロファイルでDetectorFactoryクラスを初期化できません。
これは、サンプルの1つで提案されているように、検出を処理するクラスです。
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/profilesの下に保存されます。クラスをインスタンス化しようとすると、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);
}