[英]getting nouns and verbs from wordnet
I'm struggling to find whether a word is noun or verb etc 我正在努力寻找一个单词是名词还是动词等
I found the MIT Java Wordnet Interface there was a sample code like this, but when i use this i get error that Dictionary is abstract class and cannot be instantiated 我发现MIT Java Wordnet接口有一个这样的示例代码,但是当我使用它时,我得到了一个错误,即Dictionary是抽象类,无法实例化
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());
}
i also got another java interface to wordnet 我也有另一个Wordnet的Java接口
danbikel's interface danbikel的界面
but i dont get answer for the query 但我没有得到查询的答案
WordNet wn=new WordNet("/usr/share/wordnet");
Morphy m = new Morphy(wn);
System.out.println(m.morphStr("search","NOUN").length);
Always the string length is 0, what is the correct arguments for this method? 字符串长度始终为0,此方法的正确参数是什么? here is the javadoc of the method, what am i doing wrong?
这是该方法的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
I personally recommend Yawni , the new name for the old JWordNet project. 我个人推荐Yawni ,这是旧JWordNet项目的新名称。 To get all the parts-of-speech for a search word, you would call
FileBackedDictionary.synsets(yourQueryWord)
, then iterate through the returned Synset
s calling getPOS()
. 要获取搜索词的所有词性,您可以调用
FileBackedDictionary.synsets(yourQueryWord)
,然后遍历返回的Synset
并调用getPOS()
。
Have you solved your problem? 您解决了问题吗? I also used JWI before but the difference is that I declare my IDictionary variable as an static... but the rest it is almost the same.
之前我也使用过JWI,但不同之处是我将IDictionary变量声明为静态变量,但其余变量几乎相同。 To get the nouns you have to iterate using:
要获取名词,您必须使用以下命令进行迭代:
final Iterator itr=dict.getIndexWordIterator(POS.NOUN) While(itr.hasNext())...
最终迭代器itr = dict.getIndexWordIterator(POS.NOUN)While(itr.hasNext())...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.