gpt4 book ai didi

rdf - 如何用 OWL-RDF/XML 语法向实例描述包含 inverseOf 的属性?

转载 作者:行者123 更新时间:2023-12-02 08:39:15 24 4
gpt4 key购买 nike

我有名为 employemployedBy 的对象属性,因为它们彼此相反。如何将这些属性赋予实例?我的 employ 属性:

<owl:ObjectProperty rdf:ID="employ">
<rdf:type rdf:resource="http://rdf.pozitron.com/organizations/" />
<rdfs:domain rdf:resource="http://rdf.pozitron.com/organizations/"/>
<rdfs:range rdf:resource="http://rdf.pozitron.com/people/"/>
</owl:ObjectProperty>

我的 employedBy 属性:

<owl:ObjectProperty rdf:ID="employedBy">
<rdf:type rdf:resource="http://rdf.pozitron.com/people/" />
<owl:inverseOf rdf:resource="#Employ" />
<rdfs:domain rdf:resource="http://rdf.pozitron.com/people/"/>
<rdfs:range rdf:resource="http://rdf.pozitron.com/organizations/"/>
</owl:ObjectProperty>

现在如何描述此实例中的employemployedBy?假设 Pozitron 雇佣了 john,而 john 被 Pozitron 雇佣。

<rdf:Description rdf:about="http://rdf.pozitron.com/people/john">
<rdf:type rdf:resource="http://rdf.pozitron.com/people/"/>
<person:personName>John</person:personName>
<organization:organizationName>Pozitron</organization:organizationName>
</rdf:Description>

最佳答案

用像 Turtle 这样的语法编写 RDF 要比用 RDF/XML 容易得多。您提供的数据不足以让我们使用(例如,基本 URI 未定义)。这是包含您的数据的完整 RDF/XML 文档(注意 ex 命名空间):

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:person="http://rdf.pozitron.com/people/"
xmlns:organization="http://rdf.pozitron.com/organizations/"
xml:base="http://example.org/"
xmlns:ex="http://example.org/#">
<owl:ObjectProperty rdf:ID="employ">
<rdf:type rdf:resource="http://rdf.pozitron.com/organizations/" />
<rdfs:domain rdf:resource="http://rdf.pozitron.com/organizations/"/>
<rdfs:range rdf:resource="http://rdf.pozitron.com/people/"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:ID="employedBy">
<rdf:type rdf:resource="http://rdf.pozitron.com/people/" />
<owl:inverseOf rdf:resource="#Employ" />
<rdfs:domain rdf:resource="http://rdf.pozitron.com/people/"/>
<rdfs:range rdf:resource="http://rdf.pozitron.com/organizations/"/>
</owl:ObjectProperty>
<rdf:Description rdf:about="http://rdf.pozitron.com/people/john">
<rdf:type rdf:resource="http://rdf.pozitron.com/people/"/>
<person:personName>John</person:personName>
<organization:organizationName>Pozitron</organization:organizationName>
</rdf:Description>
</rdf:RDF>

在Turtle中,是这样的,暴露了几个问题:

@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org/#> .
@prefix person: <http://rdf.pozitron.com/people/> .
@prefix organization: <http://rdf.pozitron.com/organizations/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

ex:employedBy
a person: , owl:ObjectProperty ;
rdfs:domain person: ;
rdfs:range organization: ;
owl:inverseOf ex:Employ .

person:john
a person: ;
organization:organizationName
"Pozitron" ;
person:personName "John" .

ex:employ
a owl:ObjectProperty , organization: ;
rdfs:domain organization: ;
rdfs:range person: .

这里的问题是:

  • employedBy 的逆运算是 Employ,但没有该名称的属性,只有 employ
  • 属性 employ 是一个组织
  • 属性 employedBy 是一个
  • john 有一个 organizationName
  • 没有组织 Pozitron

这些在这个语法中很容易修复。在执行此操作时,我们还可以添加 john employedBy PozitronPozitron employ john 的三元组。我们最终得到:

@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org/#> .
@prefix person: <http://rdf.pozitron.com/people/> .
@prefix organization: <http://rdf.pozitron.com/organizations/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

ex:employedBy
a owl:ObjectProperty ;
rdfs:domain person: ;
rdfs:range organization: ;
owl:inverseOf ex:employ .

organization:Pozitron
a organization: ;
organization:organizationName
"Pozitron" ;
ex:employ person:john .

person:john
a person: ;
person:personName "John" ;
ex:employedBy organization:Pozitron .

ex:employ
a owl:ObjectProperty ;
rdfs:domain organization: ;
rdfs:range person: .

通过将其转换回来,我们也可以看到它在 RDF/XML 中的样子:

<rdf:RDF
xmlns:ex="http://example.org/#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:person="http://rdf.pozitron.com/people/"
xmlns:organization="http://rdf.pozitron.com/organizations/"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >
<rdf:Description rdf:about="http://example.org/#employedBy">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
<rdfs:domain rdf:resource="http://rdf.pozitron.com/people/"/>
<rdfs:range rdf:resource="http://rdf.pozitron.com/organizations/"/>
<owl:inverseOf rdf:resource="http://example.org/#employ"/>
</rdf:Description>
<rdf:Description rdf:about="http://rdf.pozitron.com/organizations/Pozitron">
<rdf:type rdf:resource="http://rdf.pozitron.com/organizations/"/>
<organization:organizationName>Pozitron</organization:organizationName>
<ex:employ rdf:resource="http://rdf.pozitron.com/people/john"/>
</rdf:Description>
<rdf:Description rdf:about="http://rdf.pozitron.com/people/john">
<rdf:type rdf:resource="http://rdf.pozitron.com/people/"/>
<person:personName>John</person:personName>
<ex:employedBy rdf:resource="http://rdf.pozitron.com/organizations/Pozitron"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/#employ">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
<rdfs:domain rdf:resource="http://rdf.pozitron.com/organizations/"/>
<rdfs:range rdf:resource="http://rdf.pozitron.com/people/"/>
</rdf:Description>
</rdf:RDF>

如果您使用的是可以处理逆属性的 OWL 推理机,您真的不需要同时编写 john employedBy Pozitron Pozitron employ约翰;你可以只写一个,推理器将推断出另一个。

关于rdf - 如何用 OWL-RDF/XML 语法向实例描述包含 inverseOf 的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18099630/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com