【发布时间】:2017-08-19 07:25:06
【问题描述】:
我尝试使用 WordNet 的 JWI 库,但我似乎总是遇到 IOException,尽管我发现了它。字典打不开。
wnhome = "C:/Program Files (x86)/WordNet/2.1";
path = wnhome + File.separator + "dict";
try {
url = new URL("file", null, path);
} catch (MalformedURLException e) {
e.printStackTrace();
}
IDictionary dict = new Dictionary(url);
try {
dict.open();
} catch (IOException ex) {
textView.setText("Failed");
}
textView.setText("" + dict.isOpen());
// look up first sense of the word "dog"
IIndexWord idxWord = dict.getIndexWord("dog", POS.NOUN);
IWordID wordID = idxWord.getWordIDs().get(0);
IWord word = dict.getWord(wordID);
textView.setText("Id = " + wordID);
textView.setText("Lemma = " + word.getLemma());
textView.setText("Gloss = " + word.getSynset().getGloss());
奇怪的一面是这些代码在 Netbeans 上完美运行。
【问题讨论】:
-
分享错误logcat..
标签: android android-studio dictionary nlp wordnet