2013-05-16 71 views
1

我有以下SPARQL查詢:異常與SPARQL rdflib財產路徑

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

其中運用了SPARQL 1.1定義的屬性路徑。

我試圖處理此查詢與rdflib 3.4.0和我收到下面的異常消息:

[email protected] ~/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 

什麼問題? 謝謝,

裏卡多

回答

0

這似乎已經在rdflib 3.4.0中的錯誤:我試圖複製上rdflib 4.2.1-DEV(當前版本)的錯誤,它似乎與下面的代碼工作:

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>