-1

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 }

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

Which is returning 0

Noor
  • 19,638
  • 38
  • 136
  • 254
  • I dont' seem to be able to reproduce this. When I run your query against your data, I get 0 results. Are you sure you don't mean `wo` to be `owl`, and be `http://www.w3.org/2002/07/owl#`? – Joshua Taylor Nov 16 '13 at 20:48
  • Maybe I retract that comment; in the data, I _do_ see ``, so there _is_ a class `wo:Class` that is an `owl:Class`. – Joshua Taylor Nov 16 '13 at 20:53
  • Please show the results of your query in the first and second case. Looking at your data, there _is_ a class `wo:Class`, so there could be individuals that have that type, but the data doesn't appear to have any; it seems like the result set _should_ be empty. Of course, since the data isn't posted here, just linked, we can't be sure that it's not changing behind the scenes on us, either. Unless you can provide a _minimal_ RDF file (small enough that you could post it here, so that we can reproduce the problem) that demonstrates the problem, this isn't really reproducible. – Joshua Taylor Nov 16 '13 at 20:56
  • Some of your comments on my answer really help to clarify the question, so I'm copying them here: "Also, it is not possible not to get results, because in Index.owl, there is an imports ; In in the imported file, located at bbc.co.uk/nature/life/Bird.rdf, you can see, Birds .... " – Joshua Taylor Nov 17 '13 at 03:12
  • There's no reason to expect an _RDF_ library to do anything special with an `owl:imports` triple. `owl:imports` is an _OWL_ construct, and only has special meaning in OWL. It would have been useful to point out in the original question that you're getting results from graphs _other_ than the one that you linked to. – Joshua Taylor Nov 17 '13 at 03:13
  • In response to "is not possible not to get results": it's _very_ possible to not get results, and in this case it makes sense. The _RDF data_ (which is what SPARQL is concerned with, rather than any additional OWL meaning it might encode) doesn't have results to give. – Joshua Taylor Nov 17 '13 at 03:14

1 Answers1

0

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 ) }
}

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 .

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

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • If possible try to use topbraid, you will get results – Noor Nov 17 '13 at 02:24
  • Also, it is not possible not to get results, because in Index.owl, there is an imports – Noor Nov 17 '13 at 02:24
  • In in the imported file, located at http://www.bbc.co.uk/nature/life/Bird.rdf, you can see, Birds .... – Noor Nov 17 '13 at 02:25
  • The `owl:imports` is an OWL construct; it doesn't have any particular meaning for a purely _RDF_ application. If you need to process OWL and imports, then you might want to check whether rdflib has any OWL extensions for handling OWL. For what it's worth, it would have been useful to point out in the original question that the file that you linked to _didn't actually contain_ any of the triples you were interested in. – Joshua Taylor Nov 17 '13 at 03:11