如何在 RDF 中表达关于关系的附加信息(时间、概率)? [英] How can I express additional information (time, probability) about a relation in RDF?

查看:18
本文介绍了如何在 RDF 中表达关于关系的附加信息(时间、概率)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以将任何关系表示为 RDF 三元组,如下所示:

I know that I can represent any relation as a RDF triplet as in:

巴拉克奥巴马 ->-> 总裁美国

(我知道这不是 RDF,我只是在说明)

(I am aware that this is not RDF, I am just illustrating)

但是我如何添加有关此关系的其他信息,例如时间维度?我的意思是他正处于他的第二个总统任期,任何时期都只会持续一段时间.而且,在他的总统任期之后和之前怎么样?

But how do I add additional information about this relation, like for example the time dimension? I mean he is in his second presidential period and any period last only for a lapse of time. And, how about after and before his presidential periods?

推荐答案

有几个选项可以做到这一点.我将举例说明一些更受欢迎的.

There are several options to do this. I'll illustrate some of the more popular ones.

在 RDF 中,命名图是 RDF 数据集的子集,它们被分配了一个特定的标识符(图名").在大多数 RDF 数据库中,这是通过向 RDF 三元组添加第四个元素,将其从三元组变成四元组"(有时也称为三元组的上下文")来实现的.

In RDF, named graphs are subsets of an RDF dataset that are assigned a specific identifier (the "graph name"). In most RDF databases, this is implemented by adding a fourth element to the RDF triple, turning it from a triple into a "quad" (sometimes it's also called the 'context' of the triple).

您可以使用这种机制来表达关于某个语句集合的信息.例如(对 RDF 使用伪 N-Quads 语法):

You can use this mechanism to express information about a certain collection of statements. For example (using pseudo N-Quads syntax for RDF):

:i1 a :TimePeriod .
:i1 :begin "2009-01-20T00:00:00Z"^^xsd:dateTime .
:i1 :end "2017-01-20T00:00:00Z"^^xsd:dateTime .

:barackObama :presidentOf :USA :i1 .

注意最后一条语句中的第四个元素:它将语句Barack Obama is President of the USA"链接到由 :i 标识的命名图.

Notice the fourth element in the last statement: it links the statement "Barack Obama is president of the USA" to the named graph identified by :i.

命名图方法在您有数据同时表达多个语句的情况下特别有用.当然也可以将它用于关于单个语句的数据(如上例所示),但如果以这种方式使用它可能很快变得麻烦(每个不同的时间段都需要自己命名的图形).

The named graphs approach is particularly useful in situations where you have data to express about several statements at once. It is of course also possible to use it for data about individual statements (as the above example illustrates), though it may quickly become cumbersome if used in that fashion (every distinct time period will need its own named graph).

另一种方法是将关系本身建模为对象.巴拉克奥巴马"和美国"之间的关系不仅仅是一个是另一个的总统,而是一个在特定日期之间另一个的总统.在 RDF 中表达这一点(正如 Joshua Taylor 在他的评论中也说明的那样):

An alternative approach is to model the relation itself as an object. The relation between "Barack Obama" and "USA" is not just that one is the president of the other, but that one is president of the other between certain dates. To express this in RDF (as Joshua Taylor also illustrated in his comment):

:barackObama :hasRole :president_44 .
:president_44 a :Presidency ;
         :of :USA ;
         :begin "2009-01-20T00:00:00Z"^^xsd:dateTime ;
         :end "2017-01-20T00:00:00Z"^^xsd:dateTime .

关系本身现在变成了一个对象(总统"类的一个实例,标识符为 :president_44).

The relation itself has now become an object (an instance of the "Presidency" class, with identifier :president_44).

与使用命名图相比,这种方法更适合断言有关单个语句的数据.一个可能的缺点是在 SPARQL 中查询关系变得有点复杂.

Compared to using named graphs, this approach is much more tailored to asserting data about individual statements. A possible downside is that it becomes a bit more complex to query the relation in SPARQL.

不确定这种方法实际上仍然算作流行",但 RDF 具体化是历史上 W3C 认可的断言关于语句的语句"的方法.在这种方法中,我们将语句本身变成了一个对象:

Not sure this approach actually still counts as "popular", but RDF reification is the historically W3C-sanctioned approach to asserting "statements about statements". In this approach we turn the statement itself into an object:

 :obamaPresidency a rdf:Statement ;
         rdf:subject :barackObama ;
         rdf:predicate :presidentOf ;
         rdf:object :USA ;
         :trueBetween [
                :begin "2009-01-20T00:00:00Z"^^xsd:dateTime ;
                :end "2017-01-20T00:00:00Z"^^xsd:dateTime .
         ] .

在这种情况下有几个很好的理由不使用 RDF 具体化,但是:

There's several good reasons not to use RDF reification in this case, however:

  1. 这在概念上有点奇怪.我们想要表达的知识是关于关系的时间方面的,但是使用RDF具体化我们是在谈论语句.
  2. 我们在上面的例子中表达的是:关于巴拉克奥巴马担任美国总统的声明在……和……之间是有效的".请注意,我们没有表示巴拉克·奥巴马实际上是美国总统!当然,您仍然可以单独断言(只需添加原始三元组和具体化的三元组),但这会造成进一步的重复/维护问题.
  3. 在 SPARQL 查询中使用起来很痛苦.
  1. it's conceptually a bit strange. The knowledge that we want to express is about the temporal aspect of the relation, but using RDF reification we are saying something about the statement.
  2. What we have expressed in the above example is: "the statement about Barack Obama being president of the USA is valid between ... and ...". Note that we have not expressed that Barack Obama actually is the president of the USA! You could of course still assert that separately (by just adding the original triple as well as the reified one), but this creates a further duplication/maintenance problem.
  3. It is a pain to use in SPARQL queries.

正如 Joshua 在他的评论中所指出的,W3C 关于定义 N-ary RDF 关系的说明值得一看,因为它更深入地了解这些(和其他)方法.

As Joshua also indicated in his comment, the W3C Note on defining N-ary RDF relations is useful to look at, as it goes into more depth about these (and other) approaches.

这篇关于如何在 RDF 中表达关于关系的附加信息(时间、概率)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆