WordNet とMIT JWI (WordNet にアクセスするための Java API)に関する非常に簡単な質問があります。ファイルを文字列の配列に読み込み、それを単語に分割しました。getPOS()を使用して、名詞のみを含む文字列の別の配列を取得するにはどうすればよいですか? ありがとう!
私が試したことの例:
公開クラス テスト {
public static void main(String[] args) {
String sentence1 = "The cat ate the fish";
String[] s1Split = sentence1.split(" ");
String wnhome = "C:/Program Files/WordNet/2.1";
String path = wnhome + File.separator + "dict";
URL url = new URL("file", null , path);
IDictionary dict = new Dictionary(url);
dict.open();
for (int i = 0; i <s1.length; i++) {
//this is where I got confused, wanted to use something like:
//Word w = dict.getIndexWord(s1[i], ..) but I need a POS argument,
//and I can't find another suitable method
//if w.getPOS() is a noun I would add it to a separate vector
}
}
}
編集:別のものを考えただけです-のようなものを使用するのは信頼w = dict.getIndexWord(s1[i], POS.NOUN)
できますか?名詞が存在しない場合、 w は null になりますか? これは試してみる価値があるでしょうか?
EDIT2: それで、私の質問は、文字列 (単語) を Wordnet オブジェクトに変換できる方法があるかどうかです。そのため、getPOS() を使用できますか?