我正在尝试在 Graphdb 中制定海关规则。我有一个Person本体,它具有“Parent”和“Child”类,以及对象属性“hasChild”和“hasGrandChild”。三个节点的关系是这样的:
:Ali :hasChild :Aslam
:Aslam :hasChild :Ahmed
现在我想推断 Graphdb 中的“:Ali :hasGrandChild :Ahmed”。像 owl horst 优化的内置规则集不起作用。我尝试使用 .pie 文件来制定自定义规则,但新规则不起作用
2 回答
如果您想表达不属于 OWL 或 RDFS 标准的语义,GraphDB 可以让您灵活地开发自己的规则。在此示例中,您尝试将属性定义为由hasGranChild
两个属性组成的链hasChild
。这可以通过 OWL 属性链公理实现。
我的建议是在 GraphDB 中使用 OWL 2 RL 和 OWL 2 QL 规则集的标准 OWL 语义部分。这是一个例子:
@prefix : <http://www.example.org/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:hasParent a owl:ObjectProperty .
:hasGrandChild owl:propertyChainAxiom
( :hasChild :hasChild ) .
:Ahmed :hasChild :Ali .
:Ali :hasParent :Aslam .
请不要忘记在存储库创建期间将默认规则集更改为 OWL 2 RL 或 OWL 2 QL。
我创建了一个名为“CustomRule.pie”的规则集文件。它包含三个主要部分:“前言”、“公理”和“规则”。
在 Prefices 中,我插入了我们的本体前缀,例如:
Person : http://www.semanticweb.org/hamza/ontologies/2017/6/Person.owl#
然后在 Axioms 中,我们必须编写所有三元组 Subject, Predicate, Object我们已经插入到我们的本体中。喜欢:
<'Person:Ahmed'> <'Person:hasChild'> <'Person:Ali'>
<'Person:Ali'> <'Person:hasChild'> <'Person:Aslam'>
//Ingore 逗号
最后,在规则部分,我们可以编写蕴涵规则。它检查公理部分中可用的所有公理以实施规则。Like
Id: 自定义
一个 <'Person:
------------------------------------------------
a <'Person:hasGrandChild'> c