저도 같은 문제가 발생했다
파일 여기에
public class WSDBabelfy {
public static void main (String args[]){
String inputText = "BabelNet is both a multilingual encyclopedic dictionary and a semantic network";
BabelfyConstraints constraints = new BabelfyConstraints();
SemanticAnnotation a = new SemanticAnnotation(new TokenOffsetFragment(0, 0), "<the key>",
"http://dbpedia.org/resource/BabelNet", SemanticAnnotation.Source.OTHER);
constraints.addAnnotatedFragments(a);
BabelfyParameters bp = new BabelfyParameters();
bp.setAnnotationResource(BabelfyParameters.SemanticAnnotationResource.BN);
bp.setMCS(BabelfyParameters.MCS.ON_WITH_STOPWORDS);
bp.setScoredCandidates(BabelfyParameters.ScoredCandidates.ALL);
Babelfy bfy = new Babelfy(bp);
List<SemanticAnnotation> bfyAnnotations = bfy.babelfy(inputText, Language.EN, constraints);
//bfyAnnotations is the result of Babelfy.babelfy() call
for (SemanticAnnotation annotation : bfyAnnotations)
{
//splitting the input text using the CharOffsetFragment start and end anchors
String frag = inputText.substring(annotation.getCharOffsetFragment().getStart(),
annotation.getCharOffsetFragment().getEnd() + 1);
System.out.println(frag + "\t" + annotation.getBabelSynsetID());
System.out.println("\t" + annotation.getBabelNetURL());
System.out.println("\t" + annotation.getDBpediaURL());
System.out.println("\t" + annotation.getSource());
}
}
}
그리고, config
폴더가에 잘 프로젝트의 루트? 또한 아래 예제 (또는 IDE)와 같이 classpath
에 포함 시키시겠습니까?
java -classpath lib/*:babelfy-online-1.0.jar:config it.uniroma1.lcl.babelfy.demo.BabelfyDemo
나는 보통 클래스 경로에 모든 것을 만들기 위해이 링크 "https://stackoverflow.com/questions/6104551/java-setting-classpath"를 사용합니다. 하지만 나는 Classaeth에서 어디에 써야하는지 잘 모릅니다. 힌트를주세요. – Raha1986
IntelliJ IDEA와 같은 IDE를 사용하고 있습니까? 게다가 위에서 언급 한 라인을 실행하는 것은 classpath에 필요한 모든 것을 포함한다 : (1)'lib /'의 모든'.jar' 파일; (2) 프로젝트의 루트에 'babelfy-online-1.0.jar'이 있다고 가정합니다. (3)'config /'폴더에 2 개의 등록 정보 파일이 있습니다. – Marc