I have the following SPARQL query:
SELECT ?s ?p ?o
WHERE {
?sbj ?p ?obj .
?sbj (<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>+) <http://www.my.org/ontology.owl#Place> .
?sbj rdfs:label ?s .
?obj rdfs:label ?o .
}
Which make use of the Property Paths defined for SPARQL 1.1.
I'm trying to process this query with rdflib 3.4.0 and I receive the following exception message:
rayman@hal9100 ~/projects/scripts $ python places_owl2json.py
Traceback (most recent call last):
File "places_owl2json.py", line 107, in <module>
""")
File "/usr/local/lib/python2.7/dist-packages/rdflib/graph.py", line 1007, in query
query_object, initBindings, initNs, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/rdfextras/sparql/processor.py", line 49, in query
loadContexts=loadContexts)
File "/usr/local/lib/python2.7/dist-packages/rdfextras/sparql/algebra.py", line 406, in TopEvaluate
assert isinstance(expr,AlgebraExpression), repr(expr)
AssertionError: None
What's the problem? Thanks,
Riccardo
this seems to have been a bug in rdflib 3.4.0: i tried reproducing the error on rdflib 4.2.1-dev (current version) and it seems to work with the code below:
In [1]: from rdflib import *
INFO:rdflib:RDFLib Version: 4.2.1-dev
In [2]: g = Graph()
In [3]: g.query('''
...: SELECT ?s ?p ?o
...: WHERE {
...: ?sbj ?p ?obj .
...: ?sbj (<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2000/01/rdf-schema#subClassOf>+) <http://www.my.org/ontology.owl#Place> .
...: ?sbj rdfs:label ?s .
...: ?obj rdfs:label ?o .
...: }
...: ''')
Out[3]: <rdflib.plugins.sparql.processor.SPARQLResult at 0x1111dc410>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.