Python:使用 RDFLIB 绘制 Sesame 数据库图形

发布于 2024-11-05 19:19:17 字数 1162 浏览 0 评论 0原文

是否可以使用 RDFLIB 绘制 Sesame RDF 数据库的图形? 这是我尝试过的:

endpoint = "http://127.0.0.1:8080/openrdf-workbench/repositories/movies/explore?resource=%3Cfile%3A%2F%2Fmovies_export.rdf%3E"

from rdflib import Graph
g = Graph()
g.parse(endpoint) 

这是错误:

Traceback (most recent call last):
  File "C:\Software\rdflib\movieGraph.py", line 10, in <module>
    g.parse(endpoint)
  File "c:\python26_32bit\lib\site-packages\rdflib\graph.py", line 756, in parse

    parser = plugin.get(format, Parser)()
  File "c:\python26_32bit\lib\site-packages\rdflib\plugin.py", line 89, in get
    raise PluginException("No plugin registered for (%s, %s)" % (name, kind))
rdflib.plugin.PluginException: No plugin registered for (application/xml, <class
 'rdflib.parser.Parser'>)

我认为唯一的技巧是指定正确的 URL 以使 Sesame 返回 .rdf xml 布局。

问题作者:重新发布到 http://answers.semanticweb.com/questions/9414/python-using-rdflib-to-graph-a-sesame-database(参见那里的答案)

Is it possible to draw a graph of a Sesame RDF database using RDFLIB?
This is what I tried:

endpoint = "http://127.0.0.1:8080/openrdf-workbench/repositories/movies/explore?resource=%3Cfile%3A%2F%2Fmovies_export.rdf%3E"

from rdflib import Graph
g = Graph()
g.parse(endpoint) 

This is the error:

Traceback (most recent call last):
  File "C:\Software\rdflib\movieGraph.py", line 10, in <module>
    g.parse(endpoint)
  File "c:\python26_32bit\lib\site-packages\rdflib\graph.py", line 756, in parse

    parser = plugin.get(format, Parser)()
  File "c:\python26_32bit\lib\site-packages\rdflib\plugin.py", line 89, in get
    raise PluginException("No plugin registered for (%s, %s)" % (name, kind))
rdflib.plugin.PluginException: No plugin registered for (application/xml, <class
 'rdflib.parser.Parser'>)

I think the only trick is specifying a proper URL to cause Sesame to return a .rdf xml layout.

Author of question: reposted to http://answers.semanticweb.com/questions/9414/python-using-rdflib-to-graph-a-sesame-database (see answer there)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥有 2024-11-12 19:19:17

您的端点 URL 错误。它指向 Sesame Workbench,它不是 (SPARQL) 端点,而是客户端应用程序。任何 Sesame 数据库的 SPARQL 端点始终位于 Sesame 服务器上,并且等于存储库 URL。就您而言,可能是http://127.0.0.1:8080/openrdf-sesame/repositories/movies

看看您正在做的事情,我认为您不需要 SPARQL 端点,而只是想要导出完整的 Sesame 数据库。为此,您可以使用http://127.0.0.1:8080/openrdf-sesame/repositories/movies/statements。有关更多详细信息,请参阅 Sesame HTTP 通信协议

(答案是从我自己在另一个网站上的答案复制的,为了完整性而发布在此处)

Your endpoint URL is wrong. It points to the Sesame Workbench, which is not a (SPARQL) endpoint, but a client application. The SPARQL endpoint for any Sesame database is always on the Sesame server, and is equal to the repository URL. In your case, probably http://127.0.0.1:8080/openrdf-sesame/repositories/movies.

Looking at what you're doing, I think you do not need a SPARQL endpoint but just want an export of the complete Sesame database. For this, you can use http://127.0.0.1:8080/openrdf-sesame/repositories/movies/statements. See the Sesame HTTP communication protocol for more details.

(answer copied from my own answer on another site, posted here for completeness)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文