简体   繁体   中英

Jena Reasoning and Rule Syntax

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")]

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")] 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM