0

単語が名詞か動詞かなどを見つけるのに苦労しています

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
4

2 に答える 2

0

個人的には、古いJWordNetプロジェクトの新しい名前であるYawniをお勧めします。検索単語の品詞をすべて取得するには、を呼び出してから、返されたs呼び出しをFileBackedDictionary.synsets(yourQueryWord)繰り返します。SynsetgetPOS()

于 2010-10-04T19:21:11.360 に答える
0

問題は解決しましたか?以前は JWI も使用していましたが、IDictionary 変数を static として宣言している点が異なりますが、残りはほとんど同じです。名詞を取得するには、次を使用して反復する必要があります。

最終イテレータ itr=dict.getIndexWordIterator(POS.NOUN) While(itr.hasNext())...

于 2010-11-28T21:23:27.110 に答える