如何正确使用sh:rule和sh:count

How to use sh:rule and sh:count correctly

这是我的 data.ttl:

@prefix : <http://example.com/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:Bob  a  :Student ;
        :name "Bob" ;
        :tookTest :Test1, :Test2, :Test3, :Test4, :Test5 .

:Test1 a :Test ;   
          :grade "A" .

:Test2 a :Test ;
           :grade "A" .

:Test3  a :Test ;
          :grade "A" .

:Test4 a :Test ;
          :grade "C" .

:Test5 a :Test ;
          :grade "D" .

shacl.ttl 是:

@prefix : <http://example.com/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

:Test a rdfs:Class,  sh:NodeShape .
:Student    a rdfs:Class, sh:NodeShape ;
                sh:rule [
        a sh:TripleRule ;
        sh:subject sh:this ;
        sh:predicate :rating ;
        sh:object [sh:count [sh:path :Test] ];  
                     ] .

并且我使用 shacl 推理引擎 (https://github.com/TopQuadrant/shacl):

shaclinfer.bat -datafile D:\data.ttl -shapesfile D:\shacl.ttl>D:\report.txt

我得到的结果报告为:

<http://example.com/ns#Bob>
        <http://example.com/ns#rating>  0 .

我实际上想执行以下规则:

如果 Bob 获得超过 2 个“A”,则--> :Bob :rating “Outstanding”。

如何正确编写此 sh:condition 语句? 在这种情况下sh:count应该计算出test which grade="A",难道我必须使用sparql CONSTRUCT语句吗? 感谢您的帮助!

@prefix : <http://example.com/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

:Test a rdfs:Class,  sh:NodeShape .
:Student    a  rdfs:Class, sh:NodeShape ;
            sh:rule [
                    a sh:TripleRule ;
                    sh:subject sh:this ;
                    sh:predicate :rating ;
                    sh:object "Outstanding";  
                    sh:condition :Student ;
                    sh:condition [
                            sh:qualifiedValueShape [
                                     sh:path (:tookTest :grade ) ;
                                     sh:hasValue "A" ; ] ; 
                            sh:qualifiedMinCount 2 ; ];    
                    ] .

shacl.ttl看起来接近正确,但是https://github.com/TopQuadrant/shacl的引擎出错了,错误信息如下:

Exception in thread "main" org.apache.jena.query.QueryParseException: Line 2, column 1: Unresolved prefixed name: :tookTest

有人可以用任何其他 SHACL 推理引擎测试这个吗?