我试图理解 rdfs 域和范围的语义。因为我来自面向对象的背景,所以我很难理解语义以及如何针对 rdfs 语句验证数据。
这是一个乌龟格式的示例文件:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix tmpl: <http://template.example.com/>
prefix data: <http://data.example.com/>
tmpl:Thing a owl:Class.
tmpl:Employment rdfs:subClassOf tmpl:TemporalThing.
tmpl:Party rdfs:subClassOf tmpl:Thing.
tmpl:Individual rdfs:subClassOf tmpl:Party.
tmpl:Organisation rdfs:subClassOf tmpl:Party.
tmpl:LimitedLiabilityCompany rdfs:subClassOf tmpl:Organisation.
tmpl:hasCurrentEmployer a owl:ObjectProperty;
rdfs:domain tmpl:Party;
rdfs:range tmpl:Party.
data:Simon a tmpl:Individual;
skos:prefLabel "Simon S".
data:PtyLtd a tmpl:LimitedLiabilityCompany.
data:Simon tmpl:hasCurrentEmployer data:PtyLtd.
tmpl:Animal a owl:Thing.
data:Beans a tmpl:Animal.
data:Simon tmpl:hasCurrentEmployer data:Beans.
我使用 GRAPHDB 作为我的测试环境。我希望最后一个陈述失败并带有某种消息,因为'Beans'是'动物',它不是**'派对'。
然而,GRAPHDB 只接受该声明。
有任何想法吗?
编辑
根据 Stanislav 在下面的评论:虽然推理引擎可能没有问题,但我们可以在应用程序中使用域和范围进行错误检查。
1 回答
正如评论中所说,你误解了域和范围的语义。
意味着如果一个语句
s P o
成立,那么(在推理器运行的情况下),可以推断出s rdf:type D
和o rdf:type R
。域和范围从不限制属性。这一点必须清楚。
要了解工作原理,请检查 examplem OWL 在这里指向对象属性的语义。