用数值数据的表达式定义 Protege class

Defining Protege class with expression of numerical data

我正在打造智能家居ontology。我现在有一个像这样的 class 层次结构:

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

如何实现这个定义? 提前致谢!

您可以使用 Protege 的 class 表达式编辑器来完成,但需要遵循一些步骤:

  1. 您创建了#Mild_status 并使其成为#RoomStatus 的子Class(您的操作正如我在您的编辑器中看到的那样)

  2. 您必须定义两个数据属性(#centigrade 和#humidity)的域和范围,例如,域为 Class #RoomStatus,范围为 xml 数据类型整数。这一切都可以用 Protege 来完成。

最后,使用 class 表达式编辑器:您必须断言 #Mild_status 等同于:

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

如果你想使用这个表达式进行实例检索推理:你必须知道并不是所有的推理器都支持数据范围推理。 Pellet 支持这种表达式,但我认为 Fact++ 不支持。

可能对你有用,但我认为最好不要在不需要时使用等效的 class 公理,并避免将温和状态与特定温度和湿度。毕竟,房间的温和状态与桑拿房的温和状态是非常不同的。

我建议使用通用 Class 公理来表示:

If a Room has a temperature and a humidity within the specified ranges, then the Room has a mild status.

作为 class 公理,即:

Room and (hasTemperature some integer[≥18,≤22]) and (hasHumidity some integer[≥40,≤50]) subClassOf (hasStatus value Mild_Status)

这几乎就是您可以在 Protege 中编写的内容:

这是具有该公理的 ontology(在 RDF/XML 和 TTL 中):

@prefix :      < .
@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=""
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
  <owl:Ontology rdf:about=""/>
  <owl:Class rdf:about="Room"/>
  <owl:Class rdf:about="Status"/>
  <owl:Class>
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onProperty>
          <owl:ObjectProperty rdf:about="hasStatus"/>
        </owl:onProperty>
        <owl:hasValue>
          <owl:NamedIndividual rdf:about="Mild_Status">
            <rdf:type rdf:resource="Status"/>
          </owl:NamedIndividual>
        </owl:hasValue>
      </owl:Restriction>
    </rdfs:subClassOf>
    <owl:intersectionOf rdf:parseType="Collection">
      <owl:Class rdf:about="Room"/>
      <owl:Restriction>
        <owl:onProperty>
          <owl:DatatypeProperty rdf:about="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="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>