Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何通过MIT JWI找到wordnet语法集的派生相关形式?_Java_Semantics_Jwi - Fatal编程技术网

Java 如何通过MIT JWI找到wordnet语法集的派生相关形式?

Java 如何通过MIT JWI找到wordnet语法集的派生相关形式?,java,semantics,jwi,Java,Semantics,Jwi,当通过MIT Java Wordnet接口(JWI)检索语法集的语义关系时,我无法得到派生相关的形式。我使用的是ISynset类方法getRelatedSynsets(ipointerp),但列表返回的只是空的 作为一个简单的测试,我开发了一个类,它迭代wordnet的所有名词语法集,并试图找到任何暴露派生相关形式的语法集。令人惊讶的是,代码找不到具有这种关系的单个语法集。代码如下: public class DerivationallyTest { private static ID

当通过MIT Java Wordnet接口(JWI)检索语法集的语义关系时,我无法得到派生相关的形式。我使用的是ISynset类方法
getRelatedSynsets(ipointerp)
,但列表返回的只是空的

作为一个简单的测试,我开发了一个类,它迭代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;
    }
}
公共类派生测试{
私有静态IDictionary dict=null;
公共静态void main(字符串[]args)引发IOException{
IDictionary dict=dictionary工厂();
迭代器it=dict.getSynsetIterator(POS.NOUN);
while(it.hasNext()){
ISynset synset=it.next();
if(synset.getRelatedSynsets(Pointer.derively_-RELATED).size()>0){
System.out.println(“找到一个!!!”;
}
}
}
公共静态IDictionary DictionaryFactory()引发IOException{
if(dict==null){
System.out.println(“InstanceAndo Diciario…”);
//构造Wordnet字典目录的URL
字符串wnhome=System.getenv(“wnhome”);
字符串路径=wnhome+File.separator+“dict”;
URL=新URL(“文件”,null,路径);
//构造dictionary对象并打开它
dict=新字典(url);
dict.open();
}
返回命令;
}
}
是我做错了什么,还是这真的是一种奇怪的行为?我已经使用MITJWI开发了很多类,在som做了很多工作之后,我不希望不得不更改为另一个API

我在Ubuntu12LTS下使用WordNet3.1和MITJWI2.2.3


更新:我也尝试了Wordnet 3.0,同样的情况也发生了。

只有语义指针附加到语法集。词汇指针只附加到单词上。Try:IWord.getRelatedWords(IPInter ptr)


只有语义指针附加到语法集。词汇指针只附加到单词上。Try:IWord.getRelatedWords(IPInter ptr)


正如@Ethereal所指出的,似乎Pointer.derively_RELATED是一个词汇指针,而Pointer.hyperonym和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;
    }
}
公共类派生测试{
私有静态IDictionary dict=null;
公共静态void main(字符串[]args)引发IOException{
IDictionary dict=dictionary工厂();
迭代器it=dict.getSynsetIterator(POS.NOUN);
while(it.hasNext()){
ISynset synset=it.next();
//变化来了!!!!(“.getWords().get(0.getRelatedWords()”)
if(synset.getWords().get(0).getRelatedWords(指针.派生相关).size()>0){
System.out.println(“找到一个!!!”;
}
}
}
公共静态IDictionary DictionaryFactory()引发IOException{
if(dict==null){
System.out.println(“InstanceAndo Diciario…”);
//构造Wordnet字典目录的URL
字符串wnhome=System.getenv(“wnhome”);
字符串路径=wnhome+File.separator+“dict”;
URL=新URL(“文件”,null,路径);
//构造dictionary对象并打开它
dict=新字典(url);
dict.open();
}
返回命令;
}
}

正如@Ethereal所指出的,似乎Pointer.derively_RELATED是一个词汇指针,而其他类似Pointer.hypername和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;
    }
}
公共类派生测试{
私有静态IDictionary dict=null;
公共静态void main(字符串[]args)引发IOException{
IDictionary dict=dictionary工厂();
迭代器it=dict.getSynsetIterator(POS.NOUN);
while(it.hasNext()){
ISynset synset=it.next();
//变化来了!!!!(“.getWords().get(0.getRelatedWords()”)
if(synset.getWords().get(0).getRelatedWords(指针.派生相关).size()>0){
System.out.println(“找到一个!!!”;
}
}
}
公共静态IDictionary DictionaryFactory()引发IOException{
if(dict==null){
System.out.println(“InstanceAndo Diciario…”);
//构造Wordnet字典目录的URL
字符串wnhome=System.getenv(“wnhome”);
字符串路径=wnhome+File.separator+“dict”;
URL=新URL(“文件”,null,路径);
//构造dictionary对象并打开它
dict=新字典(url);
dict.open();
}
返回命令;
}
}

我不确定该指针类型是否与syn集合关联,或者仅与单词/单词索引关联。我会调查这是一个词汇指针吗?如果是这样,请尝试IWord.getRelatedWords(IPInter ptr)是的,它是。这是一个来自指针类的静态公共atribute,它实现了IPointer接口。我尝试了IWord.getRelatedWords(指针、派生相关),确实得到了结果。似乎这个指针只和你说的词有关。酷,那就是你的答案。词法指针不附加到synset,而是附加到单词:我不确定指针类型是否与synset关联,或者仅与单词/单词索引关联。我会调查这是一个词汇指针吗?如果是这样,请尝试IWord.getRelatedWords(IPInter ptr)是的,它是。这是一个来自指针类的静态公共atribute,它实现了IPointer接口。我尝试了IWord.getRelatedWords(指针、派生相关),确实得到了结果。好像