首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过麻省理工学院JWI找到wordnet同步集的派生形式?

如何通过麻省理工学院JWI找到wordnet同步集的派生形式?
EN

Stack Overflow用户
提问于 2014-05-31 02:20:08
回答 2查看 1.4K关注 0票数 2

当通过MIT (JWI)检索同步集的语义关系时,我根本无法获得派生相关的表单。我使用的是ISynset类方法getRelatedSynsets(IPointer p),但是列表只是返回空的。

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

代码语言:javascript
复制
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;
    }
}

我是做错什么了还是这是一种奇怪的行为?我已经开发了很多使用麻省理工学院JWI的类,并且在做了很多工作之后,我不想改变成另一个API。

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

更新:我也尝试过使用WordNET3.0,同样的事情也发生了。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-31 02:51:50

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

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

票数 3
EN

Stack Overflow用户

发布于 2014-05-31 02:57:11

正如@ others所指出的,Pointer.DERIVATIONALLY_RELATED似乎是一个词汇指针,而其他如Pointer.HYPERNYM和Pointer.HOLONYM则是语义指针。我在这个问题上写的这门课应该改写成下面这样的一篇。

代码语言:javascript
复制
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;
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23965781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档