【发布时间】:2018-09-06 15:44:01
【问题描述】:
我得到了the previous question 的建议并修改了源代码。但是,源仍然无法正常工作。
我正在使用 GraphDB(RuleSet: OWL2-RL) 和 SPARQL。
我有一个包含 Person 和 Animal_Lover 类的本体。如果人们拥有超过 2 只宠物,则他们是 Animal_Lover。
如何在我的本体中做到这一点?
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.example.com/test"
xmlns:test="http://www.example.com/test#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.example.com/test"/>
<owl:ObjectProperty rdf:about="http://www.example.com/test#hasOwner">
<owl:inverseOf rdf:resource="http://www.example.com/test#hasPet"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:about="http://www.example.com/test#hasPet">
<owl:inverseOf rdf:resource="http://www.example.com/test#hasOwner"/>
</owl:ObjectProperty>
<owl:Class rdf:about="http://www.example.com/test#Animal_Lover">
<owl:equivalentClass>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.example.com/test#hasPet"/>
<owl:minQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">2</owl:minQualifiedCardinality>
<owl:onClass rdf:resource="http://www.example.com/test#Mammal"/>
</owl:Restriction>
</owl:equivalentClass>
<rdfs:subClassOf rdf:resource="http://www.example.com/test#Person"/>
</owl:Class>
<owl:Class rdf:about="http://www.example.com/test#Mammal"/>
<owl:Class rdf:about="http://www.example.com/test#Dog">
<rdfs:subClassOf rdf:resource="http://www.example.com/test#Mammal"/>
<owl:disjointWith rdf:resource="http://www.example.com/test#Person"/>
</owl:Class>
<owl:Class rdf:about="http://www.example.com/test#Person">
<rdfs:subClassOf rdf:resource="http://www.example.com/test#Mammal"/>
<owl:disjointWith rdf:resource="http://www.example.com/test#Dog"/>
</owl:Class>
<owl:NamedIndividual rdf:about="http://www.example.com/test#Lulu">
<rdf:type rdf:resource="http://www.example.com/test#Dog"/>
<test:hasOwner rdf:resource="http://www.example.com/test#Smith"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="http://www.example.com/test#Tank">
<rdf:type rdf:resource="http://www.example.com/test#Dog"/>
<test:hasOwner rdf:resource="http://www.example.com/test#Smith"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="http://www.example.com/test#Nala">
<rdf:type rdf:resource="http://www.example.com/test#Dog"/>
<test:hasOwner rdf:resource="http://www.example.com/test#Smith"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="http://www.example.com/test#Smith">
<rdf:type rdf:resource="http://www.example.com/test#Person"/>
<test:hasPet rdf:resource="http://www.example.com/test#Lulu"/>
<test:hasPet rdf:resource="http://www.example.com/test#Nala"/>
<test:hasPet rdf:resource="http://www.example.com/test#Tank"/>
</owl:NamedIndividual>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDifferent"/>
<owl:distinctMembers rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.example.com/test#Lulu"/>
<rdf:Description rdf:about="http://www.example.com/test#Nala"/>
<rdf:Description rdf:about="http://www.example.com/test#Smith"/>
<rdf:Description rdf:about="http://www.example.com/test#Tank"/>
</owl:distinctMembers>
</rdf:Description>
</rdf:RDF>
我希望史密斯被推断并成为 Animal_Lover。但是此代码在 OWL(或 GraphDB)中不起作用。有什么问题?
【问题讨论】:
-
你昨天已经得到了答案。你接受了答案。所以为什么?您是否尝试按照答案中的建议进行操作?
-
@AKSW,我确认:它在 Protege 中有效,但在 GraphDB 中无效。也许OP应该检查w3.org/TR/owl2-profiles。
-
@StanislavKralin 是正确的。由
equivClassExpression := Class other than owl:Thing | equivObjectIntersectionOf | ObjectHasValue | DataHasValue定义的等效类公理不支持最小基数 - 简而言之,在 OWL RL 配置文件中根本不支持最小基数(模min 1确实隐含地包含在存在限制中)。 -
还有另一个名为
owl-max的 GraphDB 配置文件声称也涵盖了 min cardinilaty - 也许值得一试。 -
@AKSW 感谢您的评论。不幸的是,它不适用于
owl-max...
标签: owl ontology protege graphdb