File "<console>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/testing1.py", line 129, in rdf_description
store.add(self,(subject, predicate, object),context)
File "/usr/local/lib/python2.7/dist-packages/rdflib-3.2.0-py2.7.egg/rdflib/plugins/memory.py", line 298, in add
Store.add(self, triple, context, quoted)
File "/usr/local/lib/python2.7/dist-packages/rdflib-3.2.0-py2.7.egg/rdflib/store.py", line 177, in add
def add(self, (subject, predicate, object), context, quoted=False):
in
store.add(self, (subject, predicate, object), context, quoted=False)
问问题
410 次
1 回答
2
AFAIK - rdflib 不支持 4store。curl
但是您可以使用和 python 和 4store SPARQL Server轻松断言三元组。这里有一个例子:
import subprocess
command = ["curl","-s",
"-T","/some/file/with/triples",
"-H","Content-Type: application/x-turtle",
"http://localhost:port/data/http://graph.to/save/triples"]
p = subprocess.Popen(command,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output, err = p.communicate()
ret = p.poll()
if ret <> 0:
raise Exception, "Error asserting triples"
在本例中,内容类型是turtle,但您可以使用任何其他 RDF 序列化 ( ntriples
, rdfxml
)。
如果您不想处理子流程,您也可以将此调用转换为urllib/urllib2
函数。
4store SparqlServer 文档中有更多示例。并且,您可以选择使用任何Python 4store 客户端库。
于 2012-03-15T16:22:45.233 回答