理解语义网及其方法、语法、词汇和语言

发布于 2024-09-06 02:01:12 字数 326 浏览 9 评论 0原文

我刚刚了解了语义网及其功能系列,但我很难理解其中的一些内容,我希望有人可以向我解释。

据我所知,RDF 可以用多种语法编写。 RDF/XML、Turtle 等。

现在,我了解了 XML。它是如何呈现的以及如何解析它。然而,有些人用海龟语法编写,但他们如何解析这些信息呢?我似乎无法找到任何语言的单个库来将海龟语法编写的信息“提取”为另一种形式。 N3也是如此。如何使用?执行还是其他?

我似乎能够理解RDFa。它是一种将 RDF 实现为 XHTML 的方法。对我来说,这是将 RDF 实现为“某物”的一种方法。但我如何将其与tu​​rtle、N3 等进行比较呢?

提前致谢。

I have just been introduced to the semantic web and it's family of functions but I have a hard time understanding some of it, which I was hoping someone could explain to me.

As far as I've understood, RDF can be written in several syntaxes. RDF/XML, Turtle, etc.

Now, I understand XML. How it is presented and how it can be parsed. However, some people write in the turtle syntax, but how do they parse that information? I can't seem to find a single library for any language to "extract" the information written in a turtle syntax into another form. The same goes for N3. How can it be used? Executed or else?

I seem to be able to understand RDFa. That it is a way to implement RDF into XHTML. For me that is a way to implement RDF into "something". But how can I compare that to turtle, N3, or the like?

Thanks in advance.

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

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

发布评论

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

评论(2

2024-09-13 02:01:13

首先,要明确的是,当我们说“RDF”时,我们指的是(本质上)三元组的集合:

<subject1> <predicate1> <object1>
<subject2> <predicate2> <object2>
...

它是一个简单的数据库,而不是“可执行的”。

编写 RDF 的方法有很多种。 RDF/XML 是最常见的,但在您学习时并不是最明显的。 N-三元组是最简单的,你只需写出三元组:

<subject1> <predicate1> <object1> .
<subject2> <predicate2> <object2> .
...

Turtle 与 N-三元组类似,但有很多捷径。写起来很容易。例如,如果我们有:

<person> <age> 21 .
<person> <friend> <bob> .
<person> <friend> <alice> .
...

在海龟中,我们可以通过编写来避免重复:(

<person> <age> 21 ; 
         <friend> <bob> ,
         <alice> .

我已经将其写在多行中,以便您可以看到它看起来像三重版本,但遗漏了部分)

您会发现海龟解析器对于大多数 RDF 库。请参阅 Jena (java)、Redland (C)、RDFLib (python)、Trine (perl) 等。它们采用海龟并生成三元组,就像 RDF/XML 解析器和 RDFa 解析器一样。

一旦加载了 RDF,您就可以查询它、处理它,无论您对任何其他数据格式做什么。

RDFa 是一种奇怪的 RDF 格式,因为它嵌入在其他内容中(当转换为三元组时,其中大部分内容都会被丢弃)。 RDFa 的目的是让 RDF 更顺利地集成到 Web 中。同时拥有我的个人信息的 RDF 版本和 HTML 版本是重复的并且部署起来很繁琐。借助 RDFa,我可以拥有一份同时为浏览器和 rdf 用户提供服务的文档。

Firstly, to be clear, when we say 'RDF' we mean (at base) a collection of triples:

<subject1> <predicate1> <object1>
<subject2> <predicate2> <object2>
...

It's a simple database, not 'executable'.

There are many ways to write RDF. RDF/XML is the most common, but not the most obvious when you're learning. N-Triples is the simplest, you just write out the triples:

<subject1> <predicate1> <object1> .
<subject2> <predicate2> <object2> .
...

Turtle is like N-Triples, but with lots of short cuts. It's very easy to write. For example if we had:

<person> <age> 21 .
<person> <friend> <bob> .
<person> <friend> <alice> .
...

In turtle we can avoid the repetition by writing:

<person> <age> 21 ; 
         <friend> <bob> ,
         <alice> .

(I've written this out on multiple lines so you can see how it looks like the triple version, but with parts missed out)

You'll find turtle parsers for most RDF libraries. See Jena (java), Redland (C), RDFLib (python), Trine (perl) etc. They take turtle and produce triples, just like the RDF/XML parsers and RDFa parsers do.

Once you have your RDF loaded you can query it, process it, whatever you'd do with any other data format.

RDFa is a strange RDF format, since it's embedded in something else (most of which is thrown away when you convert to triples). The point of RDFa is to get RDF more smoothly integrated into the web. Having both an RDF version and HTML version of my personal information is repetitious and fiddly to deploy. With RDFa I can have one document which serves both browsers and rdf consumers.

撑一把青伞 2024-09-13 02:01:13

作为一个编程技能有限的人,我发现 PHP 的 ARC2 库 使 RDF 非常容易处理。该网站上有很好的文档和很好的示例供您入门。它包括所有常见格式的解析器,包括海龟,甚至会进行格式检测并选择正确的解析器(如果您不喜欢)。

解析 RDF 时,ARC 会生成两种不同类型的关联数组,这非常简单。这些结构的描述可以在此处找到。

我从没想过我会这么说,但 PHP + ARC 实际上让使用 RDF 变得......有趣。

As someone with limited programming skills, I found that the ARC2 libraries for PHP make RDF very easy to deal with. There is good documentation and great examples on the site to get started. It includes parsers for all of the common formats, including turtle, and will even do format detection and choose the correct parser if you don't feel like it.

When parsing RDF, ARC produces two different types of associative arrays which are quite straightforward. A description of those structures can be found here.

I never thought I would say it, but PHP + ARC actually made working with RDF...fun.

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