[英]Create instances of unionOf with OWL/RDF/XML
我在下面有這個OWL的示例,我想知道如何為“ unionOf”啟動並創建一個實例(個人)
我想知道如何制作這個
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#" >
<owl:Class rdf:ID="house" />
<owl:Class rdf:ID="room" />
<owl:Class rdf:ID="kitchen" />
<owl:Class rdf:ID="garden" />
<owl:Class rdf:ID="table" />
<owl:Class rdf:ID="chair" />
<owl:ObjectProperty rdf:about="house_composedBy">
<rdfs:domain rdf:resource="#house"/>
<rdfs:range>
<owl:Class>
<owl:unionOf rdf:parseType="Collection">
<owl:Class rdf:about="room" />
<owl:Class rdf:about="kitchen" />
<owl:Class rdf:about="garden" />
</owl:unionOf>
</owl:Class>
</rdfs:range>
</owl:ObjectProperty>
我是這樣開始的,但是我停了下來,因為如果我不知道類型,就不知道要添加哪個對象。
例,
<u:house rdf:ID="p_house01">
<u:house_composedBy about="room01" />
<u:house_composedBy about="room02" />
<u:house_composedBy about="kitchen" />
<u:house_composedBy about="garden" />
</u:house>
我現在不知道如何區分個人,這是用unionOf做到這一點的正確方法嗎?
問候。
盡管我的其余答案將解決如何創建聯合類實例的問題,但我認為您應該考慮執行此操作的原因。 如果這與您先前的問題有關,則可能是uml與RDF和OWL的組合關系 ,這似乎是可能的,並且您試圖說屬性的范圍是聯合類,例如,
hasComponent rdfs:range(TypeA或TypeB)
你並不需要聲明的是個別X為了使用它作為一個hasComponent聲明的對象的類型(類型A或類型B)的。 反之。 rdfs:range聲明在這里所做的所有操作使您能夠觀察語句
y hasComponent x
並據此推斷
x rdf:type(TypeA或TypeB)
您無需預先在x上聲明任何類型。 域和范圍聲明使您可以根據在斷言中的使用方式來推斷事物的類型。 它們不提供任何形式的一致性實施或完整性約束。
我不確定您到底要問什么(無論您是要生成某些公理的RDF / XML序列化還是什么),但是我認為我們可以找到解決方案。 WingingProtégé,很容易創建一個個體並聲明它具有某種聯合類的類型。 例如,我們可以斷言
x:A 或 B 或 C
在Protégé:
我們可以看一下該OWL本體的RDF序列化。 如果出於某種原因需要手工編寫,Turtle序列化是最容易閱讀和最容易編寫的:
@prefix : <http://www.example.org/unionof-example#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
## Ontology declaration
<http://www.example.org/unionof-example>
a owl:Ontology .
## Three classes
:A a owl:Class .
:B a owl:Class .
:C a owl:Class .
## x is a thing, a named individual, and
## an (A or B or C).
:x a owl:Thing , owl:NamedIndividual ;
a [ a owl:Class ;
owl:unionOf ( :A :B :C )
] .
如果您確實需要在RDF / XML中使用它,那只是RDF圖的另一個序列化:
<rdf:RDF
xmlns="http://www.example.org/unionof-example#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.example.org/unionof-example"/>
<owl:Class rdf:about="http://www.example.org/unionof-example#A"/>
<owl:Class rdf:about="http://www.example.org/unionof-example#B"/>
<owl:Class rdf:about="http://www.example.org/unionof-example#C"/>
<owl:Thing rdf:about="http://www.example.org/unionof-example#x">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<rdf:type>
<owl:Class>
<owl:unionOf rdf:parseType="Collection">
<owl:Class rdf:about="http://www.example.org/unionof-example#A"/>
<owl:Class rdf:about="http://www.example.org/unionof-example#B"/>
<owl:Class rdf:about="http://www.example.org/unionof-example#C"/>
</owl:unionOf>
</owl:Class>
</rdf:type>
</owl:Thing>
</rdf:RDF>
您可能還對非縮寫序列化感興趣。 它比較冗長,可讀性較差,但是如果您要這樣做的話,手工編寫可能會更容易一些:
<rdf:RDF
xmlns="http://www.example.org/unionof-example#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >
<rdf:Description rdf:about="http://www.example.org/unionof-example#A">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A0">
<rdf:first rdf:resource="http://www.example.org/unionof-example#B"/>
<rdf:rest rdf:nodeID="A1"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.org/unionof-example#B">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A2">
<rdf:first rdf:resource="http://www.example.org/unionof-example#A"/>
<rdf:rest rdf:nodeID="A0"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.org/unionof-example#C">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A3">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
<owl:unionOf rdf:nodeID="A2"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A1">
<rdf:first rdf:resource="http://www.example.org/unionof-example#C"/>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.org/unionof-example">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.org/unionof-example#x">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<rdf:type rdf:nodeID="A3"/>
</rdf:Description>
</rdf:RDF>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.