【发布时间】:2019-10-04 13:22:31
【问题描述】:
我有以下 Turtle 语法文件(见问题结尾),我希望能够推断出 :hasSibling,但只有完整的兄弟姐妹,而不是一半。 即我只想要那些同父异母的孩子。
我查看了How to infer isBrotherOf property between two individuals,解决了一半的问题。以下 SPARQL 查询:
PREFIX : <http://example.com/Test#>
SELECT DISTINCT *
WHERE {
?child :isSiblingOf ?sibling .
FILTER ( ?child = :jennySmith )
}
返回:
-
:jimJones- 同父异母,不要 :joeSmith-
:jennySmith- 自我,不理想,但我可以忍受它
我尝试使用 owl:intersectionOf 并提供 2 组,一组在 owl:propertyChainAxiom 中使用 :hasFather,另一组使用 :hasMother,但该交叉点是空的(有可能 - 可能 - 我已经语法错误,或者 2 个属性链实际上返回了不同的“事物”——我对 OWL 的掌握还不是很清楚):
:x1
a owl:Restriction ;
owl:intersectionOf (
[
owl:propertyChainAxiom(
:hasFather
:isParentOf
) ] [
owl:propertyChainAxiom(
:hasMother
:isParentOf
)
]
)
.
另一种可能性是,OWL 不可能做到这一点。
我在 GraphDB 中使用 OWL2-RL 设置了存储库。请忽略现有的本体来定义家谱,而 OWL 可能不是表示它们的最佳方式。我的目标是不是创建家谱,而是学习 OWL 的限制和推论。这是我想出的 MVCE 来说明我的问题。
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix owl2: <http://www.w3.org/2006/12/owl2#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.com/Test#> .
<file:test.ttl>
a owl:Ontology ;
.
:Person
a owl:Class ;
rdfs:subClassOf owl:Thing ;
.
:hasGender
a owl:ObjectProperty ;
rdfs:domain :Person ;
.
:Man
a owl:Class ;
rdfs:subClassOf :Person ;
owl:equivalentClass [
a owl:Restriction ;
owl:onProperty :hasGender ;
owl:hasValue :male ;
]
.
:Woman
a owl:Class ;
rdfs:subClassOf :Person ;
owl:equivalentClass [
a owl:Restriction ;
owl:onProperty :hasGender ;
owl:hasValue :female ;
]
.
:Parent
a owl:Restriction ;
rdfs:subClassOf :Person ;
owl:onProperty :isParentOf ;
owl:someValuesFrom :Person ;
.
:Child
a owl:Restriction ;
rdfs:subClassOf :Person ;
owl:onProperty :hasParent ;
owl:someValuesFrom :Person ;
.
:Father
a owl:Class ;
rdfs:subClassOf :Parent ;
owl:equivalentClass [
a owl:Restriction ;
owl:intersectionOf ( :Parent :Man ) ;
] ;
.
:Mother
a owl:Class ;
rdfs:subClassOf :Parent ;
owl:equivalentClass [
a owl:Restriction ;
owl:intersectionOf ( :Parent :Woman ) ;
] ;
owl2:disjointObjectProperties :Father ;
.
:hasFather
owl:inverseOf :isFatherOf ;
.
:hasMother
owl:inverseOf :isMotherOf ;
.
:hasParent
a owl:ObjectProperty ;
.
:isMotherOf
a owl:ObjectProperty ;
rdfs:domain :Woman ;
rdfs:range: :Child ;
rdfs:subPropertyOf :isParentOf ;
.
:isFatherOf
a owl:ObjectProperty ;
rdfs:domain :Man ;
rdfs:range: :Child ;
rdfs:subPropertyOf :isParentOf ;
.
:isParentOf
a owl:ObjectProperty ;
rdfs:domain :Person ;
rdfs:range :Person ;
owl:inverseOf :hasParent ;
.
:isSiblingOf
a owl:ObjectProperty ;
owl:propertyChainAxiom(
:hasParent
:isParentOf
)
.
:janeSmith
a :Person ;
:hasGender :female ;
:isMotherOf :jimJones ;
:isMotherOf :joeSmith ;
:isMotherOf :jennySmith ;
.
:johnSmith
a :Person ;
:hasGender :male ;
:isFatherOf :joeSmith ;
:isFatherOf :jennySmith ;
.
:tomJones
a :Person ;
:hasGender :male ;
:isFatherOf :jimJones ;
.
:jimJones
a :Person ;
:hasGender :male ;
.
:joeSmith
a :Person ;
:hasGender :male ;
.
:jennySmith
a :Person ;
:hasGender :female ;
:isMotherOf :harrySmith ;
.
:harrySmith
a :Person ;
:hasGender :male ;
.
【问题讨论】:
-
你不能做属性的交集是属性链。您所拥有的不是有效的 OWL 公理。您在 OWL 中也没有变量,因此,如果您选择的三重存储支持,您想要表达的内容需要 SWRL 或其他类型的规则语言。 GraphDB确实支持自定义规则,所以只要尝试用相应的语法编写规则即可。
-
难道不能在OWL中表达“实例是兄弟姐妹当且仅当他们有相同的2个父母”这个概念吗?我没有必须使用属性链,这正是我能够想出的。我的工作假设只是因为我无法弄清楚并不意味着它不可能。