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

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

问题描述

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

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

Barack Obama -> president of -> USA

(我知道这不是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)是美国总统"链接到由: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 .

该关系本身现在已成为一个对象("Presidency"类的实例,标识符为: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. 我们在上面的示例中表达的是:关于巴拉克·奥巴马(Barack Obama)担任美国总统的声明在...至...之间是有效的."请注意,我们没有表示巴拉克·奥巴马实际上是美国总统!您当然仍然可以断言(单独添加原始的三元组和经过修饰的三元组),但这会造成进一步的复制/维护问题.
  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元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天全站免登陆