Defining Protege class with expression of numerical data

前端 未结 2 608
失恋的感觉
失恋的感觉 2020-12-19 19:10

I am building a smart home ontology. I now have a class hierarchy like that:\"enter

I

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 19:31

    Hatim's answer may work for you, but I think it might be better not to use equivalent class axioms when you don't have to, and to avoid tying Mild Status to particular temperatures and humidities. After all, what it means for a Room to have a mild status is very different for what it means for a Sauna to have a mild status.

    I'd recommend using a General Class Axiom to say that:

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

    As a class axiom, that's:

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

    That's almost exactly what you can write in Protege:

    axiom in Protege

    Here's the ontology (in RDF/XML and in TTL) with that axiom:

    @prefix :       .
    @prefix rdfs:   .
    @prefix owl:    .
    @prefix xsd:    .
    @prefix rdf:    .
    
    :       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 .
    
    
      
      
      
      
        
          
            
              
            
            
              
                
              
            
          
        
        
          
          
            
              
            
            
              
                
                
                  
                    50
                  
                  
                    40
                  
                
              
            
          
          
            
              
            
            
              
                
                
                  
                    18
                  
                  
                    22
                  
                
              
            
          
        
      
    
    

提交回复
热议问题