2

通过 MIT Java Wordnet 接口 (JWI) 检索 Synset 的语义关系时,我根本无法获得派生相关的形式。我正在使用 ISynset 类方法getRelatedSynsets(IPointer p),但列表只是返回空。

作为一个简单的测试,我开发了一个类,它迭代 wordnet 的所有名词同义词集,并尝试找到任何暴露派生相关形式的同义词集。令人惊讶的是,代码找不到具有该关系的单个同义词集。这是代码:

public class DerivationallyTest {

    private static IDictionary dict = null;

    public static void main(String[] args) throws IOException {
        IDictionary dict = dicitionaryFactory();
        Iterator<ISynset> it = dict.getSynsetIterator(POS.NOUN);
        while(it.hasNext()){
            ISynset synset = it.next();
            if(synset.getRelatedSynsets(Pointer.DERIVATIONALLY_RELATED).size() > 0){
                System.out.println("FOUND ONE!!!");
            }
        }
    }



    public static IDictionary dicitionaryFactory() throws IOException{
        if(dict == null){
            System.out.println("Instanciando Dicionario...");
            // 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
            dict = new Dictionary(url); 
            dict.open();
        }
        return dict;
    }
}

我做错了什么还是这是一种实际的奇怪行为?我已经使用 MIT JWI 开发了很多类,并且不希望在完成大量工作后不得不更改为另一个 API。

我在 Ubuntu 12 LTS 下使用 Wordnet 3.1 和 MIT JWI 2.2.3

更新:我也尝试使用 Wordnet 3.0 并且发生了同样的事情。

4

2 回答 2

3

只有语义指针附加到同义词集。词法指针只附加到单词上。试试:IWord.getRelatedWords(IPointer ptr)

http://projects.csail.mit.edu/jwi/api/edu/mit/jwi/item/ISynset.html#getRelatedSynsets(edu.mit.jwi.item.IPointer)

于 2014-05-31T02:51:50.150 回答
1

正如@ethereous 所指出的,似乎Pointer.DERIVATIONALLY_RELATED 是一个词法指针,而其他像Pointer.HYPERNYM 和Pointer.HOLONYM 是语义指针。我在这个问题上写的课程应该被重写为类似下面的内容。

public class DerivationallyTest {

    private static IDictionary dict = null;

    public static void main(String[] args) throws IOException {
        IDictionary dict = dicitionaryFactory();
        Iterator<ISynset> it = dict.getSynsetIterator(POS.NOUN);
        while(it.hasNext()){
            ISynset synset = it.next();
            //HERE COMES THE CHANGE!!!! (the ".getWords().get(0).getRelatedWords()")
            if(synset.getWords().get(0).getRelatedWords(Pointer.DERIVATIONALLY_RELATED).size()>0){
                System.out.println("FOUND ONE!!!");
            }
        }
    }



    public static IDictionary dicitionaryFactory() throws IOException{
        if(dict == null){
            System.out.println("Instanciando Dicionario...");
            // 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
            dict = new Dictionary(url); 
            dict.open();
        }
        return dict;
    }
}
于 2014-05-31T02:57:11.350 回答