相同的sparql不返回相同的结果 [英] Same sparql not returning same results

查看:101
本文介绍了相同的sparql不返回相同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个不同的客户端上使用相同的sparql语句,但两者均未返回相同的结果.猫头鹰文件采用rdf语法,可以在此处进行访问. 这是sparql语句:

I'm using the same sparql statement using two different clients but both are not returning the same results. The owl file is in rdf syntax and can be accessed here. This is the sparql statement:

PREFIX wo:<http://purl.org/ontology/wo/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> select ?individual where { ?individual rdf:type wo:Class }

我正在使用顶部编织层和以下python程序来使用它:

I'm using it using top braid and the following python program:

>>> import rdflib
>>> import rdfextras
>>> rdfextras.registerplugins()
>>> g=rdflib.Graph()
>>> g.parse("index.owl")
<Graph identifier=N39ccd52985014f15b2fea90c3ffaedca (<class 'rdflib.graph.Graph'>)>
>>> PREFIX = "PREFIX wo:<http://purl.org/ontology/wo/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
>>> query = "select ?individual where { ?individual rdf:type wo:Class }"
>>> query = PREFIX + query
>>> result_set = g.query(query)
>>> len(result_set)
0

哪个将返回0

推荐答案

此查询构造一个包含所有三元组的图形,其中wo:Class用作主语,谓语或宾语:

This query constructs a graph containing all the triples in which wo:Class is used as a subject, predicate, or object:

PREFIX wo: <http://purl.org/ontology/wo/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
construct { ?s ?p ?o } 
where { 
  { ?s ?p wo:Class . bind( wo:Class as ?o ) } union
  { ?s wo:Class ?o . bind( wo:Class as ?p ) } union
  { wo:Class ?p ?o . bind( wo:Class as ?s ) }
}

我对您的数据进行了本地复制,得到的结果是(在Turtle中):

I made a local copy of your data and the results I get are (in Turtle):

@prefix vs:    <http://www.w3.org/2003/06/sw-vocab-status/ns#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix wo:    <http://purl.org/ontology/wo/> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .

wo:Class  a              owl:Class ;
        rdfs:comment     "A class is a scientific way to group related organisms together, some examples of classes being jellyfish, reptiles and sea urchins. Classes are big groups and contain within them smaller groupings called orders, families, genera and species."@en ;
        rdfs:label       "Class"@en ;
        rdfs:seeAlso     <http://www.bbc.co.uk/nature/class> , <http://en.wikipedia.org/wiki/Class_%28biology%29> ;
        rdfs:subClassOf  wo:TaxonRank ;
        vs:term_status   "testing" .

wo:class  rdfs:range  wo:Class .

您的数据中没有任何类型为wo:Class的个人.结果集应该为空.

There are no individuals of type wo:Class in your data. The result set ought to be empty.

这篇关于相同的sparql不返回相同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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