SWI-Prolog:如何使用 semweb/rdf_db 库加载 rdf 三元组?

发布于 2024-09-02 04:45:42 字数 473 浏览 3 评论 0原文

我有一个 n 三元组格式的 rdf 文件(file.trp),其中每一行都是一个格式良好的三元组:

“subject predicate object”。

我尝试使用semweb/rdf_db中的rdf_load将其加载到内存中,但失败了。这是我尝试过的:

?- rdf_load('file.trp').

?- rdf_load('file.trp', [format(triples)]).

跟踪显示目标失败于:

rdf_db:rdf_load_stream/3

which 调用

rdf_load_db_/3

可能在外部库中定义的内容。

手册说它支持 xml 和三元组。但它只加载 rdf xml 文件。我怎样才能加载这样的rdf三重文件?

谢谢, 李

I have a rdf file (file.trp) in n-triples format, where each line is a well-formed triple:

"subject predicate object ."

I tried to use rdf_load in semweb/rdf_db to load it into memory, but failed. Here is what I tried:

?- rdf_load('file.trp').

?- rdf_load('file.trp', [format(triples)]).

The trace shows that the goal fails at:

rdf_db:rdf_load_stream/3

which calls

rdf_load_db_/3

which is probably defined in a foreign library.

the manual says it supports xml and triples. But it only loads rdf xml files. How can I load such rdf triple file?

Thanks,
Li

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

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

发布评论

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

评论(2

一场信仰旅途 2024-09-09 04:45:42

该库(semweb/rdf_db)可以使用多个插件进行扩展以支持其他功能
输入(URL、压缩、不同的三重格式)。值得注意的是:

  • 加载库(semweb/rdf_turtle)使其读取 .ttl(Turtle)
  • 加载库(semweb/rdf_zlib_plugin)使其处理 .gz 文件(压缩)
  • 加载库(semweb/rdf_http_plugin)使其从 http:// URL
  • 加载库(semweb/rdf_ntriples)使其加载 ntriples 格式
    (仅在最新开发版本 6.3.8 中提供)。

The library(semweb/rdf_db) can be extended with several plugins to support additional
inputs (URLs, compressed, different triple formats). Notably:

  • Loading library(semweb/rdf_turtle) makes it read .ttl (Turtle)
  • Loading library(semweb/rdf_zlib_plugin) makes it process .gz files (compressed)
  • Loading library(semweb/rdf_http_plugin) makes it load from http:// URLs
  • Loading library(semweb/rdf_ntriples) makes it load the ntriples format
    (this is only provided with the latest development version; 6.3.8).
演多会厌 2024-09-09 04:45:42

手册 表明谓词rdf_load/2支持RDF/XML 或者,它是“内部快速加载和缓存格式”,这可能不是 n-triples 格式。

首先,您需要导入以下内容才能使用此谓词:

:- use_module(library(semweb/rdf_db)).

其次,我认为您需要将三元组转换为此谓词可读的适当格式,例如 RDF/XML,并使用这样的调用:

 rdf_load('file.xml', [format(xml)]).

您可以使用这个 在线转换器,用于在 n-三元组和 RDF/XML 格式(以及其他格式)之间进行转换。

The manual suggests that the predicate rdf_load/2 supports either the RDF/XML or, it's 'internal quick load and cache format', which is probably not the n-triples format.

Firstly, you'll need to import the following to make use of this predicate anyhow:

:- use_module(library(semweb/rdf_db)).

Secondly, I think you'll need to convert your triples into an appropriate format which is readable by this predicate, such as RDF/XML, and use the call like this:

 rdf_load('file.xml', [format(xml)]).

You can use this online converter for converting between n-triples and RDF/XML format (amongst others).

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