计算JENA中DBPedia的两种资源之间的距离 [英] Calculating the distance between two resources of DBPedia in JENA

查看:51
本文介绍了计算JENA中DBPedia的两种资源之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图计算查询DBpedia后收到的两个资源之间的距离(DBpedia的图中边缘的数量). 例如:

I'm trying to calculate the distance (number of the edges in the DBpedia'graph) between two resources that I receive after querying DBpedia. 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();

这是字符串查询:

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...

推荐答案

您将无法在当前查询的QuerySolution上计算该距离.

You wont be able to calculate that distance on the QuerySolution resulting from your current query.

如果要计算这样的语义距离,则必须通过另一个SPARQL查询或在更新查询以本地检索所需信息之后进行.

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.

这篇关于计算JENA中DBPedia的两种资源之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆