0

我正在尝试使用 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
>>>

是什么导致了这个问题?

4

0 回答 0