Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.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
FileNotFoundException,URL连接错误,Babelfy,Java_Java - Fatal编程技术网

FileNotFoundException,URL连接错误,Babelfy,Java

FileNotFoundException,URL连接错误,Babelfy,Java,java,Java,来自的此示例程序在一天内运行正常,第二天运行时出现以下错误: 线程“main”java.io.FileNotFoundException中的异常: 位于sun.net.www.protocol.http.HttpURLConnection.getInputStream0(未知源) 位于sun.net.www.protocol.http.HttpURLConnection.getInputStream(未知源) 在it.uniroma1.lcl.babelfy.babelfy.babelfy(ba

来自的此示例程序在一天内运行正常,第二天运行时出现以下错误:

线程“main”java.io.FileNotFoundException中的异常: 位于sun.net.www.protocol.http.HttpURLConnection.getInputStream0(未知源) 位于sun.net.www.protocol.http.HttpURLConnection.getInputStream(未知源) 在it.uniroma1.lcl.babelfy.babelfy.babelfy(babelfy.java:95) main(Example.java:19)

示例是Java程序的名称

代码如下:

import it.uniroma1.lcl.babelfy.Babelfy;
import it.uniroma1.lcl.babelfy.Babelfy.Matching;
import it.uniroma1.lcl.babelfy.Babelfy.AccessType;
import it.uniroma1.lcl.babelfy.data.Annotation;
import it.uniroma1.lcl.babelfy.data.BabelSynsetAnchor;
import it.uniroma1.lcl.babelnet.BabelNet;
import it.uniroma1.lcl.babelnet.BabelSense;
import it.uniroma1.lcl.babelnet.BabelSynset;
import it.uniroma1.lcl.jlt.util.Language;

public class Example 
{
public static void main(String[] args) throws Exception 
{
    Babelfy bfy = Babelfy.getInstance(AccessType.ONLINE);
    BabelNet bn = BabelNet.getInstance();
    String word=" ";
    String inputText = "He has a passion for music";
    Annotation annotations = bfy.babelfy(" ", inputText, Matching.EXACT, Language.EN);
    System.out.println("inputText: "+inputText+"\nannotations:");
    for(BabelSynsetAnchor annotation : annotations.getAnnotations())
    {
        word=annotation.getBabelSynset().getId();
        System.out.println(annotation.getAnchorText()+"\t"+word+"\t"+annotation.getBabelSynset());
        //BabelSynset by = bn.getSynsetFromId(("bn:03083790n"));
    for (BabelSense sense : bn.getSynsetFromId((word))) 
     {
        if(sense.getSource().toString().equals("WN"))
            System.out.println("Sense: " + sense.getLemma()+ "\tSource: " + sense.getSource().toString());
     }
    }

}   
}
我在Eclipse项目的构建路径中添加了0.9和1.0版本的Babelfy库


有人能找到错误的本质吗?

似乎Babelfy API已经过时了。它试图连接到

版本1.0仍然是当前版本,因此请删除您的0.9版本。Java可能会选择它找到的第一个版本,可能是0.9


删除0.9.jar后,您应该能够进行适当的API调用。

谢谢。不过我刚才才弄清楚。我得出了同样的解决办法。