使用属性链和 Rolification
安托万·齐默尔曼的回答 https://stackoverflow.com/a/19565141/1281433是这个问题的一个很好的开始,并且触及了解决此类任务所需的要点:
From x to each of x's brothers, there is a path of the form hasFather o hasFather-1.
但现在,这实际上不仅仅适用于兄弟。对于所有兄弟姐妹来说都是如此x本身。这意味着您将拥有以下定义有兄弟姐妹:
hasSibling ≡ hasFather o hasFather-1
(其实,这真的只是有父亲兄弟姐妹;更精确的定义将使用有父级.) 现在,使用这个,你可以要求兄弟,这些兄弟只是男性的兄弟姐妹,x查询如下:
(hasSibling 值 x) 和 Man
然而,它would很高兴定义一个适当的有兄弟财产。你可以用财产链来做到这一点有兄弟姐妹如果你有一个特殊的属性来连接每个Man到他自己,并且只将男性与他们自己联系起来:
hasBrother == hasSibling o 特殊属性
In fact, such a property is what we get from a technique called rolification, which has been described more in a question, OWL 2 rolification https://stackoverflow.com/q/16989042/1281433, and its answer. The idea is that for the class Man, we create a new property rMan and add the equivalence:
Man ≡ rMan some Self
which says that each Man is related to himself by the rMan property, and that only instances of Man are so connected. This is exactly the property that we need as specialProperty above. Thus, we end up with the following definitions of Man, hasSibling, and hasBrother:
现在我们可以向兄弟们请教x查询如下:
hasBrother-1 value x
例如,我们可以要求Greg的兄弟姐妹,并得到Peter, Greg(他本人),以及Bobby.
样本本体
这是 Turtle 中的本体:
@prefix : <http://www.example.org/brady#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix brady: <http://www.example.org/brady#> .
@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#> .
brady:hasSibling a owl:ObjectProperty ;
owl:propertyChainAxiom ( brady:hasFather [ owl:inverseOf
brady:hasFather ] ) .
brady:Carol a owl:NamedIndividual , brady:Woman .
brady:hasBrother a owl:ObjectProperty ;
owl:propertyChainAxiom ( brady:hasSibling brady:r_Man ) .
<http://www.example.org/brady>
a owl:Ontology .
brady:Woman a owl:Class ;
rdfs:subClassOf brady:Person ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty brady:r_Woman
] .
brady:hasFather a owl:ObjectProperty .
brady:Person a owl:Class .
brady:Man a owl:Class ;
rdfs:subClassOf brady:Person ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty brady:r_Man
] .
brady:r_Woman a owl:ObjectProperty .
brady:r_Man a owl:ObjectProperty .
brady:Marcia a owl:NamedIndividual , brady:Woman ;
brady:hasFather brady:Mike .
brady:Peter a owl:NamedIndividual , brady:Man ;
brady:hasFather brady:Mike .
brady:Jan a owl:NamedIndividual , brady:Woman ;
brady:hasFather brady:Mike .
brady:Cindy a owl:NamedIndividual , brady:Woman ;
brady:hasFather brady:Mike .
brady:Bobby a owl:NamedIndividual , brady:Man ;
brady:hasFather brady:Mike .
brady:Greg a owl:NamedIndividual , brady:Man ;
brady:hasFather brady:Mike .
brady:Mike a owl:NamedIndividual , brady:Man .