我有名为employ
和employedBy
的对象属性,因为它们彼此相反。如何将这些属性提供给实例?我的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>
现在如何在此实例中描述employ
和employedBy
?假设Pozitron雇用约翰,约翰受雇于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>
答案 0 :(得分:6)
使用像Turtle这样的语法比RDF / XML更容易编写RDF。您提供的数据不足以让我们使用(例如,基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
是organization
employedBy
是person
john
有一个organizationName
Pozitron
。这些语法很容易修复。我们还可以在执行此操作时添加john employedBy Pozitron
和Pozitron 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 john
;你只能写一个而推理者会推断另一个。