2

I have a questions regarding to the 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". 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.

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")]
Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
Jan Wagner
  • 21
  • 2

1 Answers1

4

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. An example of a rule using the builtin (from owl-fb.rules) follows:

[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")] 
Rob Hall
  • 2,693
  • 16
  • 22