为http://schema.org/workLocation创建三元组

时间:2014-07-22 15:29:25

标签: schema.org turtle-rdf

我正在创建一个Turtle文件,其中包含schema:Person类型的特定个体的三元组。

我被困在为人的架构定义三元组:workLocation。根据文档,schema:workLocation的范围包括schema:Place,一个地方可以有schema:address,其类型应为schema:PostalAddress。我创建了以下内容:

@prefix schema: <http://schema.org/> .
<http://www.example.com/ns/person/1> a schema:Person ;
                                     schema:givenName "XXX" ;
                                     schema:familyName "XXXX" ;
                                     schema:addressCountry "USA" .

这是描述地址的正确方法吗?如何指定人员的工作地点?

1 个答案:

答案 0 :(得分:4)

让我们的工作三倍,然后我们可以考虑是否有办法清理演示文稿。首先,您开始使用前缀声明并标识类型为person的资源:

@prefix schema: <http://schema.org/> .
@prefix : <http://stackoverflow.com/q/24891549/1281433/> .

:person1 a schema:Person .

接下来,您要添加工作地点。嗯,工作地点将是一个东西,并将有PlaceContactPoint类型。让我们假设它是一个地方。然后我们添加:

:person1 schema:workLocation :place62 .
:place62 a schema:Place .

现在,地点可以通过schema:address属性:

与PostalAddress相关联
:place62 schema:address :address89 .
:address89 a schema:PostalAddress .

现在,我们可能会使用很多属性来描述PostalAddress。在这种情况下,我们可能会有(使用该页面中的示例值):

:address89 schema:addressLocality "Mountain View" .
:address89 schema:addressRegion "CA" .
:address89 schema:postalCode "94043" .
:address89 schema:streetAddress "1600 Amphitheathre Pkwy" .

现在邮政地址也适用于ContactPoint的属性,因此您可能也需要其中的一些,但您可以以相同的方式定义它们。所以现在你有了这些数据:

@prefix schema: <http://schema.org/> .
@prefix : <http://stackoverflow.com/q/24891549/1281433/> .

:person1 a schema:Person .
:person1 schema:workLocation :place62 .
:place62 a schema:Place .
:place62 schema:address :address89 .
:address89 a schema:PostalAddress .
:address89 schema:addressLocality "Mountain View" .
:address89 schema:addressRegion "CA" .
:address89 schema:postalCode "94043" .
:address89 schema:streetAddress "1600 Amphitheathre Pkwy" .

除非您要重复使用地点和地址(如果您在同一位置描述了一堆人员,您可能会这样做),您可能可以使用空白节点而不是URI节点。这样做,并使用Turtle提供的一些语法糖,最终得到:

@prefix schema: <http://schema.org/> .
@prefix : <http://stackoverflow.com/q/24891549/1281433/> .

:person1 a schema:Person ;
         schema:workLocation [ a schema:Place ;
                               schema:address [ a schema:PostalAddress ;
                                                schema:addressLocality "Mountain View" ;
                                                schema:addressRegion "CA" ;
                                                schema:postalCode "94043" ;
                                                schema:streetAddress "1600 Amphitheathre Pkwy" ] ] .