如何推断这样的"间接"用OWL或SWRL断言?

时间:2018-06-13 09:31:50

标签: owl protege swrl

知识

如果昨晚下雨,草坪今天很潮湿

事实

我们今天早上发现草坪湿了

推断

昨晚下雨了

这属于SWRL吗?

我应该阅读或检查以便轻松理解这些内容?

1 个答案:

答案 0 :(得分:0)

我已经弄明白了,我粘贴了一个乌龟语法文件。

为此,我们必须制作一些Object (Predict) Properties

hasFact
previousDay
nextDay (inverseOf previousDay)

然后添加一些Individuals,如:

的URI: 潮湿,下雨,今天,昨天

昨天断断续续的昨天和今天已经确定湿了,接下来转到swrl tab添加这个规则。

hasFact(?today, wet) ^ previousDay(?today, ?yesterday) -> hasFact(?yesterday, rain)

开始推理它会起作用。

the examples involving aggregates in the user guide



@prefix : <http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31> .

<http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31> rdf:type owl:Ontology .

#################################################################
#    Annotation properties
#################################################################

###  http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled
<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> rdf:type owl:AnnotationProperty .


#################################################################
#    Object Properties
#################################################################

###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#hasFact
:hasFact rdf:type owl:ObjectProperty .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#nextDay
:nextDay rdf:type owl:ObjectProperty ;
         owl:inverseOf :previousDay .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#previousDay
:previousDay rdf:type owl:ObjectProperty .


#################################################################
#    Data properties
#################################################################

###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#hasValue
:hasValue rdf:type owl:DatatypeProperty ;
          rdfs:range [ rdf:type rdfs:Datatype ;
                       owl:oneOf [ rdf:type rdf:List ;
                                   rdf:first "rain" ;
                                   rdf:rest [ rdf:type rdf:List ;
                                              rdf:first "wet" ;
                                              rdf:rest rdf:nil
                                            ]
                                 ]
                     ] .


#################################################################
#    Classes
#################################################################

###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#Day
:Day rdf:type owl:Class .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#ItRainsLastNight
:ItRainsLastNight rdf:type owl:Class ;
                  owl:equivalentClass [ rdf:type owl:Restriction ;
                                        owl:onProperty :previousDay ;
                                        owl:someValuesFrom [ rdf:type owl:Restriction ;
                                                             owl:onProperty :hasFact ;
                                                             owl:hasValue :rain
                                                           ]
                                      ] ;
                  rdfs:subClassOf :Phenomenon .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#Phenomenon
:Phenomenon rdf:type owl:Class .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#Today
:Today rdf:type owl:Class ;
       rdfs:subClassOf :Day .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#Weather
:Weather rdf:type owl:Class .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#Yesterday
:Yesterday rdf:type owl:Class ;
           rdfs:subClassOf :Day .


#################################################################
#    Individuals
#################################################################

###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#rain
:rain rdf:type owl:NamedIndividual ,
               :Weather ;
      :hasValue "rain"^^xsd:string .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#today2018614
:today2018614 rdf:type owl:NamedIndividual ,
                       :Today ;
              :hasFact :wet ;
              :previousDay :yesterday2018613 .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#wet
:wet rdf:type owl:NamedIndividual ,
              :Phenomenon ;
     :hasValue "wet"^^xsd:string .


###  http://www.semanticweb.org/monsterstep/ontologies/2018/5/untitled-ontology-31#yesterday2018613
:yesterday2018613 rdf:type owl:NamedIndividual ,
                           :Yesterday .


#################################################################
#    Rules
#################################################################

<today> rdf:type <http://www.w3.org/2003/11/swrl#Variable> .

<yesterday> rdf:type <http://www.w3.org/2003/11/swrl#Variable> .

[ <http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> "true"^^xsd:boolean ;
   rdfs:comment ""^^xsd:string ;
   rdfs:label "ItRainsLastNight"^^xsd:string ;
   rdf:type <http://www.w3.org/2003/11/swrl#Imp> ;
   <http://www.w3.org/2003/11/swrl#body> [ rdf:type <http://www.w3.org/2003/11/swrl#AtomList> ;
                                           rdf:first [ rdf:type <http://www.w3.org/2003/11/swrl#IndividualPropertyAtom> ;
                                                       <http://www.w3.org/2003/11/swrl#propertyPredicate> :hasFact ;
                                                       <http://www.w3.org/2003/11/swrl#argument1> <today> ;
                                                       <http://www.w3.org/2003/11/swrl#argument2> :wet
                                                     ] ;
                                           rdf:rest [ rdf:type <http://www.w3.org/2003/11/swrl#AtomList> ;
                                                      rdf:first [ rdf:type <http://www.w3.org/2003/11/swrl#IndividualPropertyAtom> ;
                                                                  <http://www.w3.org/2003/11/swrl#propertyPredicate> :previousDay ;
                                                                  <http://www.w3.org/2003/11/swrl#argument1> <today> ;
                                                                  <http://www.w3.org/2003/11/swrl#argument2> <yesterday>
                                                                ] ;
                                                      rdf:rest rdf:nil
                                                    ]
                                         ] ;
   <http://www.w3.org/2003/11/swrl#head> [ rdf:type <http://www.w3.org/2003/11/swrl#AtomList> ;
                                           rdf:first [ rdf:type <http://www.w3.org/2003/11/swrl#IndividualPropertyAtom> ;
                                                       <http://www.w3.org/2003/11/swrl#propertyPredicate> :hasFact ;
                                                       <http://www.w3.org/2003/11/swrl#argument1> <yesterday> ;
                                                       <http://www.w3.org/2003/11/swrl#argument2> :rain
                                                     ] ;
                                           rdf:rest rdf:nil
                                         ]
 ] .

###  Generated by the OWL API (version 4.2.8.20170104-2310) https://github.com/owlcs/owlapi
&#13;
&#13;
&#13;