开发者

getType in wordnet java API

开发者 https://www.devze.com 2023-03-05 12:30 出处:网络
I am using wordnet java API. I have defin开发者_开发百科ed a WordNetDatabase database = WordNetDatabase.getFileInstance();

I am using wordnet java API. I have defin开发者_开发百科ed a

WordNetDatabase database = WordNetDatabase.getFileInstance();
Synset[] synsets = database.getSynsets(wordForm);

System.out.println("type " + synsets[i].getType());

when I do this print, I get value 1 for "new york".

I am trying to find the value is NOUN (or) Verb.... But I get this values as 1. what does 1 stand for?

It says here is of type: SynsetType.

Please let me now how I can find if the given word I give to lookup and the response is a noun (or) verb..


EDIT: This time I misread the documentation :) I suggest using this:

SynsetType type = synsets[i].getType();
if (type.equals(SynsetType.NOUN)) {
    // Code for nouns
} else if (type.equals(SynsetType.VERB) {
    // Code for verbs
} else {
    // Code for non-verb/nouns.
}
0

精彩评论

暂无评论...
验证码 换一张
取 消