Вот минимальная онтология с классами, как вы описали, то есть класс LivingPlace имеет два прямых подкласса: City и RuralArea. Существует один человек, ruralArea1, который имеет тип RuralArea и онтология содержит правило SWRL
RuralArea (? Х) → hasHospital (? Х, ложные)
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://example.org/places#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:swrl="http://www.w3.org/2003/11/swrl#"
xmlns:swrlb="http://www.w3.org/2003/11/swrlb#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://example.org/places"/>
<owl:Class rdf:about="http://example.org/places#LivingPlace"/>
<owl:Class rdf:about="http://example.org/places#City">
<rdfs:subClassOf rdf:resource="http://example.org/places#LivingPlace"/>
</owl:Class>
<owl:Class rdf:about="http://example.org/places#RuralArea">
<rdfs:subClassOf rdf:resource="http://example.org/places#LivingPlace"/>
</owl:Class>
<owl:DatatypeProperty rdf:about="http://example.org/places#hasHospital">
<rdfs:domain rdf:resource="http://example.org/places#LivingPlace"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/>
</owl:DatatypeProperty>
<swrl:Imp>
<swrl:body>
<swrl:AtomList>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
<rdf:first>
<swrl:ClassAtom>
<swrl:classPredicate rdf:resource="http://example.org/places#RuralArea"/>
<swrl:argument1>
<swrl:Variable rdf:about="urn:swrl#x"/>
</swrl:argument1>
</swrl:ClassAtom>
</rdf:first>
</swrl:AtomList>
</swrl:body>
<swrl:head>
<swrl:AtomList>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
<rdf:first>
<swrl:DatavaluedPropertyAtom>
<swrl:argument2 rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean"
>false</swrl:argument2>
<swrl:propertyPredicate rdf:resource="http://example.org/places#hasHospital"/>
<swrl:argument1 rdf:resource="urn:swrl#x"/>
</swrl:DatavaluedPropertyAtom>
</rdf:first>
</swrl:AtomList>
</swrl:head>
</swrl:Imp>
<owl:NamedIndividual rdf:about="http://example.org/places#ruralArea1">
<rdf:type rdf:resource="http://example.org/places#RuralArea"/>
</owl:NamedIndividual>
</rdf:RDF>
Когда я загрузить эту онтологию в Protégé 4ого и использовать Pellet как мыслитель, а также гарантировать, что выводы о свойствах типов данных являются Displyed в пользовательском интерфейсе (как описаны в this message on the Protégé OWL mailing list), вывод, что
ruralArea1 hasHospital false
, как показано на следующем снимке экрана.
Другой способ увидеть, что Пелле можно сделать этот вывод, чтобы спросить, используя SPARQL. Например, используя запрос SPARQL, сохраненный в query.sparql
prefix : <http://example.org/places#>
select ?s ?o where {
?s :hasHospital ?o
}
и инструмент pellet
командной строки, мы получаем следующие результаты:
$ pellet query -q query.sparql ./places.owl
Query Results (1 answers):
s | o
============================================================
ruralArea1 | false^^http://www.w3.org/2001/XMLSchema#boolean
Стоит отметить, что вы на самом деле не нужно SWRL к сделайте этот конкретный вывод. Вы можете просто сказать, что
RuralArea subClassOf (hasHospital значение ложь)
и получить те же результаты. В Protégé это будет выглядеть следующим образом. Это имеет то преимущество, что оно даст вам те же результаты, если вы используете OWL-аргумент, который не имеет поддержки SWRL.
позволяет утверждение типа данных в настройках были ключевым понятием для меня. благодаря – alex