这是我的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 :评级为“杰出”。
如何正确编写sh:condition语句?在这种情况下,sh:count应该计算测试哪个grade="A“的数量,我是否必须使用sparql构造语句?谢谢你的帮助!
发布于 2021-08-13 03:17:35
@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推理引擎测试一下?
https://stackoverflow.com/questions/68761288
复制相似问题