如何在4s店储存三缸


 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)

AFAIK-rdflib不支持4store。但是,您可以使用curl和python以及4store SPARQLServer轻松地断言三元组。这里有一个例子:

 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序列化(ntriplesrdfxml)。

如果您不想处理子流程,也可以将此调用转换为urllib/urllib2函数。

4store SparqlServer文档中还有更多示例。并且,您可以选择使用任何Python 4store客户端库。

相关内容

  • 没有找到相关文章

最新更新