我正在尝试计算查询 DBpedia 后收到的两个资源之间的距离(DBpedia'graph 中的边数)。例如:
Query query = QueryFactory.create(sparqlQueryString);
QueryExecution qexec =QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql",query);
try{
ResultSet results = qexec.execSelect();
for(; results.hasNext();) {
QuerySolution soln = results.nextSolution();
for(int i=0;i<solutionConcept.length;i++){
System.out.print(solutionConcept[i]+":"+soln.get(solutionConcept[i]).toString() +"; ");
}
System.out.println("\n");
}
} finally{
qexec.close();
这是字符串查询:
String s6= "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+
"PREFIX dbpedia: <http://dbpedia.org/resource/> "+
"PREFIX o: <http://dbpedia.org/ontology/> "+
"PREFIX dbprop: <http://dbpedia.org/property/>"+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" +
"select ?Player ?nation ?club "+
"where {?Player rdf:type o:SoccerPlayer; dbprop:birthPlace ?nation; dbprop:currentclub ?club.} LIMIT 10";
好吧,有没有办法计算两个球员、两个国家或两个俱乐部之间的边数(路径??)??非常感谢...