単語が名詞か動詞かなどを見つけるのに苦労しています
MIT Java Wordnet Interface にこのようなサンプル コードがあることがわかりましたが、これを使用すると Dictionary is abstract class and cannot be instantiated というエラーが表示されます
public void testDictionary() throws IOException {
// construct the URL to the Wordnet dictionary directory
String wnhome = System.getenv("WNHOME");
String path = wnhome + File.separator + "dict";
URL url = new URL("file", null, path);
// construct the dictionary object and open it
IDictionary dict = new Dictionary(url);
dict.open();
// 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);
System.out.println("Id = " + wordID);
System.out.println("Lemma = " + word.getLemma());
System.out.println("Gloss = " + word.getSynset().getGloss());
}
wordnetへの別のJavaインターフェイスも取得しました
ダンビケルのインターフェース
しかし、私はクエリの答えを得ることができません
WordNet wn=new WordNet("/usr/share/wordnet");
Morphy m = new Morphy(wn);
System.out.println(m.morphStr("search","NOUN").length);
文字列の長さは常に 0 です。このメソッドの正しい引数は何ですか? これがメソッドのjavadocです。何が間違っていますか?
public String[] morphStr(String origstr, String pos)
Tries several techniques on origstr to find possible base forms (lemmas).
Specified by:
morphStr in interface MorphyRemote
Parameters:
origstr - word or collocation, separated either by whitespace, '_' or '-', to find lemma of
pos - part of speech of origstr
Returns:
array of possible lemmas for origstr, possibly of length 0 if no lemmas could be found