【发布时间】:2021-11-25 15:09:38
【问题描述】:
请看下面的例子:
@prefix : <#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Bob :score 78 .
:John :score 50 .
:rule1 :condition [
rdf:subject :score ;
rdf:predicate :notLessThan ;
rdf:object 60
];
:condition [
rdf:subject :score ;
rdf:predicate :notGreaterThan ;
rdf:object 80
];
:rating :passed .
:rule2 :condition [
rdf:subject :score ;
rdf:predicate :lessThan ;
rdf:object 60
];
:rating :failed .
我想通过 spqrql 查询得到以下输出:
:Bob :rating :passed.
:John :rating :failed.
这里的rdf:predicate是用户可以改变的,它的值可能是:
lessThan, notLessThan, greaterThan, notGreaterThan
那么我该如何编写这个基于动态谓词的 SPARQL 语句呢?
我没有任何想法。谢谢你帮助我。
【问题讨论】:
-
到目前为止您尝试了什么?我的意思是,你已经提出了很多问题,你应该能够从已经知道
FILTER、BIND、IF和所有那些相关的 SPARQL 结构的东西开始。 -
顺便说一句,在某些时候,使用单个 SPARQL 查询即使不是不可能的事情也会变得复杂。这里我们已经遇到了一个规则的所有条件都必须检查的问题,并且有多个规则。这就是为什么人们发明了规则引擎并且 SPARQL 1.1 带有自己的蕴涵机制。
-
谢谢 UninformedUser 。什么样的规则引擎适合这样的问题?我是 RDF 和 Sparql 的初学者。感谢您和其他人的帮助,我学到了很多东西。