5

我正在创建一个 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" .

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

4

1 回答 1

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" ] ] .
于 2014-07-22T16:15:54.790 回答