【问题标题】:adding triples in 4store在 4store 中添加三元组
【发布时间】:2012-04-06 16:16:06
【问题描述】:

这里 url_add 是一个链接,其中包含我想存储在 4store 中的 rdf 三元组。但是如果我将 url_add 作为参数传递,它会生成相对 URIerror。

那么我只能将 url_add 作为参数传递的方式是什么。

response = store.add_from_uri('url_add')

Traceback(最近一次通话最后一次):

文件“”,第 1 行,在

文件“/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/testing1.py”,第 152 行,在

response = store.add_from_uri('url_add')

文件“/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/HTTP4Store/HTTP4Store.py”,第 74 行,在 add_from_uri 中

r_obj = self.rh.GET(uri, headers=headers)

文件“/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/HTTP4Store/utils.py”,第 53 行,在 GET 中

return self._request("%s" % (path), method="GET", headers=headers)

文件“/usr/local/lib/python2.7/dist-packages/django_gstudio-0.3.dev-py2.7.egg/gstudio/HTTP4Store/utils.py”,第92行,在_request中

resp, content = self.h.request(path, method, headers=headers, body=data)

文件“/usr/lib/python2.7/dist-packages/httplib2/init.py”,第 1297 行,在请求中 (scheme, authority, request_uri, defrag_uri) = urlnorm(uri)

文件“/usr/lib/python2.7/dist-packages/httplib2/init.py”,第 204 行,在 urlnorm raise RelativeURIError("只允许使用绝对 URI。uri = %s" % uri)

RelativeURIError:只允许使用绝对 URI。 uri = url_add

【问题讨论】:

    标签: python debian sparql 4store


    【解决方案1】:

    你的网址的价值是什么

    它抛出异常是因为您传递的是相对 url 而不是绝对的(您可能有类似“../../directory/filename.rdf”的东西

    如果您的 url 是 HTTP url,例如 (http://host/filename.rdf) 和 dereferenceable,那么您也可以使用 LOAD 指令作为 SPARQL 更新的一部分。因此,这仅仅意味着使用以下表达式执行 SPARQL 查询(与使用 4store 执行 SPARQL 查询的方式相同):

    LOAD <http://host/filename.rdf>
    INTO GRAPH <http://optional-name-of-graph>
    

    【讨论】:

    • 好的...实际上我有一个名为 rdf.py 的代码生成 rdf 代码..我想做的是直接将 dat 文件移动到 4store..
    猜你喜欢
    • 2019-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-02
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    相关资源
    最近更新 更多