简体   繁体   English

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

[英]Create instances of unionOf with OWL/RDF/XML

I have this example of OWL below and I want to know how to start and create an instance (individuals) for "unionOf" 我在下面有这个OWL的示例,我想知道如何为“ unionOf”启动并创建一个实例(个人)

I want to know how to made instance of this 我想知道如何制作这个

<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>

I started like this but I stopped because I don't know which object i'm adding if I don't know the type of. 我是这样开始的,但是我停了下来,因为如果我不知道类型,就不知道要添加哪个对象。

Example, 例,

<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> 

I don't know now how to distinguish between individuals, is it the right way to do this with unionOf ?? 我现在不知道如何区分个人,这是用unionOf做到这一点的正确方法吗?

Regards. 问候。

Why do you need instances of a union class? 为什么需要工会类的实例?

While the rest of my answer will address how you can create instances of a union class, I do think that you should consider the reason that you're doing this. 尽管我的其余答案将解决如何创建联合类实例的问题,但我认为您应该考虑执行此操作的原因。 If this is related to your earlier question, uml Composition relationships to RDF and OWL , which seems likely, and you're trying to say that the range of a property is a union class, eg, 如果这与您先前的问题有关,则可能是uml与RDF和OWL的组合关系 ,这似乎是可能的,并且您试图说属性的范围是联合类,例如,

hasComponent rdfs:range (TypeA or TypeB) hasComponent rdfs:range(TypeA或TypeB)

you don't need to declare that some individual x is of type (TypeA or TypeB) in order to use it as the object of a hasComponent statement. 并不需要声明的是个别X为了使用它作为一个hasComponent声明的对象的类型(类型A或类型B)的。 On the contrary. 反之。 All the rdfs:range declaration does here is gives you the ability to observe a statement rdfs:range声明在这里所做的所有操作使您能够观察语句

y hasComponent x y hasComponent x

and to infer from it that 据此推断

x rdf:type (TypeA or TypeB) x rdf:type(TypeA或TypeB)

You don't need to declare any type on x in advance. 您无需预先在x上声明任何类型。 Domain and range declarations allow you to infer the types of things based on how they're used in assertions; 域和范围声明使您可以根据在断言中的使用方式来推断事物的类型。 they don't provide any sort of consistency enforcement or integrity constraints. 它们不提供任何形式的一致性实施或完整性约束。

How you can create them 如何创建它们

I'm not sure what exactly you're asking (whether you're trying to generate the RDF/XML serialization of some axioms, or what), but I think we can find a solution. 我不确定您到底要问什么(无论您是要生成某些公理的RDF / XML序列化还是什么),但是我认为我们可以找到解决方案。 Wsing Protégé, it's easy to create an individual and declare that it has as a type some union class. WingingProtégé,很容易创建一个个体并声明它具有某种联合类的类型。 Eg, we can assert that 例如,我们可以断言

x : A or B or C x:A B C

in Protégé: 在Protégé:

unionOf示例

We can take a look at the RDF serialization of this OWL ontology. 我们可以看一下该OWL本体的RDF序列化。 The Turtle serialization is the easiest to read, and the easiest to write, if you need to write this by hand for some reason: 如果出于某种原因需要手工编写,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 )
                ] .

If you really need this in RDF/XML, that's just another serialization of the RDF graph: 如果您确实需要在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>

You might also be interested in the non abbreviated serialization of that. 您可能还对非缩写序列化感兴趣。 It's more verbose, and less human readable, but it might be a bit easier to write by hand, if that's what you're doing: 它比较冗长,可读性较差,但是如果您要这样做的话,手工编写可能会更容易一些:

<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