我正在执行Babelfy计划:
以下是代码:
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("3697a512-bfd4-427e-846d-9eb60f98c3bb",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());
}
}
}
}
这是错误引发的错误:
Exception in thread "main" java.io.FileNotFoundException: http://babelfy.org/rest?text=He%20has%20a%20passion%20for%20music&key=3697a512-bfd4-427e-846d-9eb60f98c3bb&partMatching=false&lang=EN&format=json
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at it.uniroma1.lcl.babelfy.Babelfy.babelfy(Babelfy.java:95)
at Example.main(Example.java:19)
除了FileNotFoundException,为什么还有' 0'在错误中:
sun.net.www.protocol.http.HttpURLConnection.getInputStream0(未知来源)
这是否意味着其他什么?