MIT Java WordNet界面:获取WordNet词典编辑器类或超级类 [英] MIT Java WordNet Interface: Getting WordNet lexicographer classes or super-senses

查看:93
本文介绍了MIT Java WordNet界面:获取WordNet词典编辑器类或超级类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,需要了解一个单词的词义.我正在考虑使用WordNet,因为它具有自己的词典编辑器类,也称为超级感官.我刚刚下载了MIT JWI,并尝试查看该JWI是否支持它.手册没有说明返回该单词附带的任何词汇信息.

I have a project where I need to get the lexical meaning of a word. I am thinking of using WordNet because it has its own lexicographer classes also called super-senses. I just downloaded MIT JWI and trying to see if this JWI does support it. The manual doesn't say anything about returning any lexical information attached to the word.

import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream.GetField;
import java.net.URL;
import edu.mit.jwi.*;
import edu.mit.jwi.item.IIndexWord;
import edu.mit.jwi.item.ILexFile;
import edu.mit.jwi.item.ISenseKey;
import edu.mit.jwi.item.IWord;
import edu.mit.jwi.item.IWordID;
import edu.mit.jwi.item.POS;

public class MITJavaWordNetInterface {

    public static void main(String[] args) throws IOException{

        //construct URL to WordNet Dictionary directory on the computer
        String wordNetDirectory = "WordNet-3.0";
        String path = wordNetDirectory + 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());      
    }    
}

我设法运行了MIT提供的示例.关于如何获取使用MIT JWI或任何其他工具提交的单词的词法信息的任何线索或建议都将是不错的.一个有关如何调用该方法的示例也将不胜感激.

I managed to run the sample provided by MIT. Any clues or suggestions as to how I can get the lexical information on a word submitted either using MIT JWI or any other tools would be great. An example on how to call the method would also be greatly appreciated.

An example word: dog
Desired results: noun.animal

推荐答案

您应该能够使用上面提到的相同代码并添加几行

You should be able to use the same code mentioned above and add few more lines

    IIndexWord idxWord = dict.getIndexWord("dog", POS.NOUN);
    IWordID wordID = idxWord.getWordIDs().get(0);
    IWord word = dict.getWord(wordID);
    ISynset synset = word.getSynset();
    String LexFileName = synset.getLexicalFile().getName();
    System.out.println("Lexical Name : "+ LexFileName);

这篇关于MIT Java WordNet界面:获取WordNet词典编辑器类或超级类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆