首页 > 解决方案 > 如何通过 SHACL 断言逆三元组(假设它们还不存在?)

问题描述

我有一个本体,其中每个主题角色(例如,has-agent)都通过对象属性表示。此外,总是定义逆属性(例如,is-agent-of)。

我想通过 SHACL 规则在本体中断言所有逆三元组,前提是它们并不已经存在

因此,我编写了以下规则:

:assertInverseTriplesOnHasAgent rdf:type sh:NodeShape;
    sh:rule [rdf:type sh:TripleRule;
        sh:condition
        [
            sh:not[
                sh:property[
                    sh:path (TBox:has-agent TBox:is-agent-of);
                    sh:minCount 1;
                    sh:equals sh:this
                ]
            ]
        ];
        sh:subject [sh:path TBox:has-agent];
        sh:predicate TBox:is-agent-of;
        sh:object sh:this
    ];
    sh:targetSubjectsOf TBox:has-agent.

但它不起作用:它断言逆三元组即使它们已经存在(而且它不应该存在)。

我怀疑“sh:equals sh:this”不正确,即“sh:this”不能在 sh:property 中使用。另一方面,“sh:minCount 1;” 单独是行不通的,因为某人可以是多个行动的代理人。

谁能帮我?谢谢

标签: owlshacltopbraid-composer

解决方案


推荐阅读