【问题标题】:Create instances of unionOf with OWL/RDF/XML使用 OWL/RDF/XML 创建 unionOf 实例
【发布时间】:2014-02-21 13:40:57
【问题描述】:

我在下面有这个 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 这样做是正确的方法吗??

问候。

【问题讨论】:

    标签: xml rdf owl


    【解决方案1】:

    为什么需要联合类的实例?

    虽然我的其余答案将解决如何创建联合类的实例,但我认为您应该考虑这样做的原因。如果这与您之前的问题 uml Composition relationships to RDF and OWL 相关,这似乎很可能,并且您试图说属性的范围是联合类,例如,

    hasComponent rdfs:range (TypeA 或 TypeB)

    您不需要为了将它用作 hasComponent 语句的对象,需要声明某个单独的 x 是类型(TypeA 或 TypeB)。相反。所有 rdfs:range 声明在这里所做的就是让您能够观察语句

    y hasComponent x

    并从中推断

    x rdf:type (TypeA 或 TypeB)

    您不需要提前在 x 上声明任何类型。域和范围声明允许您根据它们在断言中的使用方式推断事物的类型;它们不提供任何形式的一致性强制或完整性约束。

    如何创建它们

    我不确定您到底在问什么(您是在尝试生成某些公理的 RDF/XML 序列化,还是什么),但我认为我们可以找到解决方案。 Wsing Protégé,很容易创建一个个体并声明它具有某个联合类的类型。例如,我们可以断言

    x : A 或 B 或 C

    在门生中:

    我们可以看一下这个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>
    

    【讨论】:

    • 在直接编写/解析 RDF/XML 时可能有用的另一点信息是 OWL 2 和 RDF 之间的标准映射:w3.org/TR/owl2-mapping-to-rdf 也就是说,我建议为这些操作使用库,因为它们很复杂且容易出错。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 2013-07-16
    • 1970-01-01
    • 2013-08-08
    • 2012-05-03
    • 1970-01-01
    相关资源
    最近更新 更多