繁体   English   中英

使用OWL / RDF / XML创建unionOf的实例

[英]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é:

unionOf示例

我们可以看一下该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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM