简体   繁体   English

计算JENA中DBPedia的两种资源之间的距离

[英]Calculating the distance between two resources of DBPedia in JENA

I'm trying to calculate the distance (number of the edges in the DBpedia'graph) between two resources that I receive after querying DBpedia. 我试图计算查询DBpedia后收到的两个资源之间的距离(DBpedia'graph中的边数)。 For example: 例如:

     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();

and this is the string query: 这是字符串查询:

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";

well, is there a way to calculate the number of the edges ( the path??) between two players, or two nation , or two club???? 那么,有没有一种方法可以计算两个球员,两个国家或两个俱乐部之间的边数(路径?)? Thank you very much... 非常感谢你...

You wont be able to calculate that distance on the QuerySolution resulting from your current query. 您将无法在QuerySolution上计算当前查询产生的距离。

If you want to compute such a semantic distance you have to do it either through another SPARQL query or after updating your query to retrieve needed information locally. 如果要计算这样的语义距离,则必须通过另一个SPARQL查询或在更新查询以本地检索所需信息之后进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM