[英]Jena Reasoning and Rule Syntax
I have a questions regarding to the Jena API. 我对Jena API有疑问。
I wrote some rules that are working perfectly but with one thing I still have a problem. 我写了一些很好的规则,但是一件事我仍然有一个问题。 I hope you can help me with it.
希望您能帮助我。
Comparison of two integer 两个整数的比较
In my rules I need a comparison like "GreaterThan". 在我的规则中,我需要像“ GreaterThan”这样的比较。 I searched long for it but not a single version worked.
我搜索了很长时间,但没有一个版本可以工作。 I tried
GreaterThan(?x, ?y)
as part of the rule as well as the namespace swrlb:
<http://www.w3.org/2003/11/swrlb#>
with its function swrlb:GreaterEqual
, but both did not worked. 我尝试了
GreaterThan(?x, ?y)
作为规则的一部分,还swrlb:
了命名空间swrlb:
<http://www.w3.org/2003/11/swrlb#>
及其功能swrlb:GreaterEqual
,但是两者都做了没有用。
The rule looks like follows: 该规则如下所示:
[r0: (?x es:has_intensity ?I), GreaterThan(?I, 2) -> (?x es:test "true")]
or my alternative: 或者我的选择:
[r0: (?x es:has_intensity ?I), (?I swrlb:Greater 2) -> (?x es:test "true")]
The main issue that you are probably experiencing is that you are not using a known builtin. 您可能遇到的主要问题是您没有使用已知的内置函数。 The builtins are case-sensitive.
内建函数区分大小写。
As seen in Jena's owl-fb.rules
, the builtin that you intend to use is greaterThan
, not GreaterThan
. 正如在耶拿看到
owl-fb.rules
,你打算使用内置的是greaterThan
,不GreaterThan
。 An example of a rule using the builtin (from owl-fb.rules
) follows: 使用内置规则的示例(来自
owl-fb.rules
)如下:
[validationMaxN: (?v rb:validation on()), (?C rdfs:subClassOf max(?P, ?N)) greaterThan(?N, 1) (?P rdf:type owl:DatatypeProperty) ->
[max2b: (?X rb:violation error('too many values', 'Too many values on max-N property (prop, class)', ?P, ?C))
<- (?X rdf:type ?C), countLiteralValues(?X, ?P, ?M), lessThan(?N, ?M) ] ]
Editing your rule yields: 编辑规则将产生:
[r0: (?x es:has_intensity ?I), greaterThan(?I, 2) -> (?x es:test "true")]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.