使用数值数据表达式定义Protege类

时间:2015-03-24 08:53:56

标签: rdf jena semantic-web owl ontology

我正在建立一个智能家庭本体。我现在有一个类层次结构:enter image description here

我想给' RoomStatus'的子类定义。例如,我想定义当室温在18-22摄氏度范围内且湿度在40-50%范围内时,房间温和状态。我试图在Protege中使用类表达式编辑器,但它不起作用。

我怎样才能实现这个定义? 提前谢谢!

2 个答案:

答案 0 :(得分:3)

Hatim's answer可能适合你,但我认为最好不要在你不必使用时使用同等的阶级公理,并避免将温和状态与特定的温度和湿度联系起来。毕竟,房间具有温和身份意味着什么对于桑拿浴具有温和状态意味着什么。

我建议使用General Class Axiom来表示:

  

如果房间温度和湿度在指定范围内,,房间​​状态为温和。

作为阶级公理,那是:

  

房间(hasTemperature 某些整数[≥18,≤22])(hasHumidity some 整数[≥40,≤50]) subClassOf (hasStatus Mild_Status)

这几乎就是你在Protege中所写的内容:

axiom in Protege

这里的本体论(在RDF / XML和TTL中)有这个公理:

@prefix :      <https://stackoverflow.com/q/29228328/1281433/> .
@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#> .

:       a       owl:Ontology .

:Room   a       owl:Class .
:Status  a      owl:Class .
:Mild_Status  a  owl:NamedIndividual , :Status .

:hasStatus  a   owl:ObjectProperty .

:hasTemperature  a  owl:DatatypeProperty .
:hasHumidity  a  owl:DatatypeProperty .

[ a                   owl:Class ;
  rdfs:subClassOf     [ a               owl:Restriction ;
                        owl:hasValue    :Mild_Status ;
                        owl:onProperty  :hasStatus
                      ] ;
  owl:intersectionOf  ( :Room _:b2 _:b3 )
] .

_:b3    a                   owl:Restriction ;
        owl:onProperty      :hasTemperature ;
        owl:someValuesFrom  [ a                     rdfs:Datatype ;
                              owl:onDatatype        xsd:integer ;
                              owl:withRestrictions  ( _:b0 _:b4 )
                            ] .
_:b0    xsd:minInclusive  18 .
_:b4    xsd:maxInclusive  22 .

_:b2    a                   owl:Restriction ;
        owl:onProperty      :hasHumidity ;
        owl:someValuesFrom  [ a                     rdfs:Datatype ;
                              owl:onDatatype        xsd:integer ;
                              owl:withRestrictions  ( _:b5 _:b1 )
                            ] .
_:b1    xsd:minInclusive  40 .
_:b5    xsd:maxInclusive  50 .
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns="https://stackoverflow.com/q/29228328/1281433/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
  <owl:Ontology rdf:about="https://stackoverflow.com/q/29228328/1281433/"/>
  <owl:Class rdf:about="https://stackoverflow.com/q/29228328/1281433/Room"/>
  <owl:Class rdf:about="https://stackoverflow.com/q/29228328/1281433/Status"/>
  <owl:Class>
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onProperty>
          <owl:ObjectProperty rdf:about="https://stackoverflow.com/q/29228328/1281433/hasStatus"/>
        </owl:onProperty>
        <owl:hasValue>
          <owl:NamedIndividual rdf:about="https://stackoverflow.com/q/29228328/1281433/Mild_Status">
            <rdf:type rdf:resource="https://stackoverflow.com/q/29228328/1281433/Status"/>
          </owl:NamedIndividual>
        </owl:hasValue>
      </owl:Restriction>
    </rdfs:subClassOf>
    <owl:intersectionOf rdf:parseType="Collection">
      <owl:Class rdf:about="https://stackoverflow.com/q/29228328/1281433/Room"/>
      <owl:Restriction>
        <owl:onProperty>
          <owl:DatatypeProperty rdf:about="https://stackoverflow.com/q/29228328/1281433/hasHumidity"/>
        </owl:onProperty>
        <owl:someValuesFrom>
          <rdfs:Datatype>
            <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
            <owl:withRestrictions rdf:parseType="Collection">
              <rdf:Description>
                <xsd:maxInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
                >50</xsd:maxInclusive>
              </rdf:Description>
              <rdf:Description>
                <xsd:minInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
                >40</xsd:minInclusive>
              </rdf:Description>
            </owl:withRestrictions>
          </rdfs:Datatype>
        </owl:someValuesFrom>
      </owl:Restriction>
      <owl:Restriction>
        <owl:onProperty>
          <owl:DatatypeProperty rdf:about="https://stackoverflow.com/q/29228328/1281433/hasTemperature"/>
        </owl:onProperty>
        <owl:someValuesFrom>
          <rdfs:Datatype>
            <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
            <owl:withRestrictions rdf:parseType="Collection">
              <rdf:Description>
                <xsd:minInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
                >18</xsd:minInclusive>
              </rdf:Description>
              <rdf:Description>
                <xsd:maxInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
                >22</xsd:maxInclusive>
              </rdf:Description>
            </owl:withRestrictions>
          </rdfs:Datatype>
        </owl:someValuesFrom>
      </owl:Restriction>
    </owl:intersectionOf>
  </owl:Class>
</rdf:RDF>

答案 1 :(得分:1)

你可以使用Protege的类表达式编辑器来完成它,但是有一些步骤要遵循:

  1. 您创建了#Mild_status并将其设为subClassof #RoomStatus(您可以在编辑器中看到它)

  2. 您必须定义两个数据属性的域和范围(#centigrade和#humidity),例如,将#RoomStatus作为域,将xml数据类型作为整数范围。所有这些都可以通过Protege来完成。

  3. 最后,使用类表达式编辑器:你必须声明#Mild_status等同于:

    RoomStatus
     and (centigrade some integer[> 18])
     and (centigrade some integer[< 22])
     and (humidity some integer[> 40])
     and (humidity some integer[<50])
    

    如果要将此表达式用于实例检索推理:您必须注意并非所有的reasoners都支持数据范围推理。 Pellet支持这种表达,但我认为Fact ++没有。