尝试使用RDFlib运行SPARQL查询时的isinstance断言

时间:2013-06-16 21:41:46

标签: python rdf sparql rdflib

我正在尝试使用Python库RDFlib执行SPARQL查询,但是我收到了一个错误。错误似乎在SPARQL中,但我已经验证它并且它是有效的。

>>> import rdflib
>>> import rdfextras
>>> rdfextras.registerplugins()
>>> g=rdflib.Graph()
>>> g.parse("/home/file.rdf")
>>> sparql = "PREFIX wo:<http://purl.org/ontology/wo/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> select ?individual ?type where { ?individual rdf:type ?type . filter (?type in (wo:Kingdom))}"
>>> x = g.query(sparql)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/rdflib-3.4.0-py2.7.egg/rdflib/graph.py", line 1007, in query
    query_object, initBindings, initNs, **kwargs))
  File "/usr/lib/python2.7/site-packages/rdfextras-0.4-py2.7.egg/rdfextras/sparql/processor.py", line 49, in query
    loadContexts=loadContexts)
  File "/usr/lib/python2.7/site-packages/rdfextras-0.4-py2.7.egg/rdfextras/sparql/algebra.py", line 406, in TopEvaluate
    assert isinstance(expr,AlgebraExpression), repr(expr)
AssertionError: None
>>>

是什么导致了这个问题?

0 个答案:

没有答案