SHACL规则中的多路径和存在量化(也许我应该使用sh:oneOne或MorePath?) [英] Multiple paths and existential quantification in SHACL rules (should I use sh:oneOrMorePath perhaps?)

查看:0
本文介绍了SHACL规则中的多路径和存在量化(也许我应该使用sh:oneOne或MorePath?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解如何在SHACL规则中处理多路径和存在量词。让我用一个示例本体来举例说明我的问题。

本体包括类、批准类、法律类、结果类、人类和机器类,这些类都是互不相交的。它有两个属性&Has-Theme&Quot;和&Quot;Come-From&Quot;以及以下个人:

:a rdf:type :Approve ;
   :has-theme :r1,:r2 .

:r1 rdf:type :Result ;
    :come-from :m1 .

:r2 rdf:type :Result ;
    :come-from :m2 .

:m1 rdf:type :Man .
:m2 rdf:type :Machine .

因此:批准操作有两个主题:";:r1";和";:R2";。前者来自人类:M1;,后者来自机器。

我要编写一条SHACL规则,声明主题中至少有一个结果来自男人的所有批准操作都是合法的。

我尝试了此功能,不会将其归类为合法(但它应该):

:testRule rdf:type sh:NodeShape;
    sh:rule [rdf:type sh:TripleRule;
        sh:condition :conditionTest;
        sh:subject sh:this;
        sh:predicate rdf:type;
        sh:object ontology:Legal
    ];
    sh:targetClass ontology:Approve.

:conditionTest
    rdf:type sh:NodeShape;
    sh:property 
    [
            #IF the theme of the Approve action is a Result come from a Man
        sh:path (ontology:has-theme ontology:come-from);
        sh:class ontology:Man
    ].

问题是";:A";有两个主题,一个来自人,另一个来自机器。

然后我在Web上读到了关于sh:oneOrMorePath的信息,并在sh:Property:

中尝试了以下变体
sh:oneOrMorePath (ontology:has-theme ontology:come-from);

sh:path ([sh:oneOrMorePath ontology:has-theme] ontology:come-from);

sh:path (ontology:has-theme [sh:oneOrMorePath ontology:come-from]);

无事可做,这些变体也不起作用。

另一方面,如果我删除三元组:r2:Come-from:M2";或三元组:A:has-heme:r2"; 它是有效的,因为在本体论中不再有从";:a";通向非人的分支。

你们中有谁能这么好地帮助我吗?

谢谢!

Livio

推荐答案

您的需求说明其主题中至少有一个来自人的结果,这在我听起来像是一个存在的约束。因此,您不能在这里真正使用sh:Class,但您可能希望使用限定值约束。

我还没有试过,但类似这样的操作可能会奏效:

:conditionTest
    rdf:type sh:NodeShape ;
    sh:property [
        sh:path (ontology:has-theme ontology:come-from) ;
        sh:qualifiedMinCount 1 ;
        sh:qualifiedValueShape [
            sh:class ontology:Man ;
        ]
    ] .

这应该意味着路径Has-Theme/Come-From中至少有一个值必须符合限定值形状,这意味着它必须是Man的实例。

SHACL中QVC的规范请参见https://www.w3.org/TR/shacl/#QualifiedValueShapeConstraintComponent

如果可以使用SHACL-SPARQL并导入破折号命名空间,还可以简单地编写破折号:hasValueWithClass本体:man,请参阅http://datashapes.org/constraints.html#HasValueWithClassConstraintComponent

这篇关于SHACL规则中的多路径和存在量化(也许我应该使用sh:oneOne或MorePath?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆