Custom SWRL BuiltIns in Pellet 2.3.2

120 views
Skip to first unread message

Rodrigo Antonialli

unread,
Apr 15, 2015, 5:14:58 PM4/15/15
to pellet...@googlegroups.com
Hi,

This is my first time here, so the first question is: The open version of pellet (at GitHub) is still being developed?

I have a problem when using the latest version to create custom SWRL builtIns.

At first, I've created the custom builtins with version 2.3.1, they all work fine with this version.

When I've changed to version 2.3.2-SNAPSHOT, the "Literal[] args" param of apply function comes with null values.

Example rule: Thing(?t1), Thing(?t2), hasGeometry(?t1, ?geom1), hasGeometry(?t2, ?geom2), asWKT(?geom1, ?wkt1), asWKT(?geom2, ?wkt2), isWithinDistance(?wkt1, ?wkt2, 0.012) -> nearby(?t1, ?t2)

When I print args, it's like:

args[0] = null
args[1] = null
args[2] = "0.012"^^double

I'm attaching the source codes and the example ontology, because I have no ideia what's wrong. I don't change I single line of code. Just by changing the pellet version, the problem occurs. Using Pellet 2.3.1, it infers the correct statements.

The first thougth was about the wktLiteral datatype. But I've changed the values to xsd:string and the problem remains.

Just to clarify, my intension here is to build a set of functions to operate over spatial info. Most functions are wrapping geotools geometries operations,

I've read about a PelletSpatial plugin, but couldn't find it anywhere.

Since my code is the same, I think the problem is within pellet, or at least the way I should build custom SWRL builtins.

Can someone help me?!

Regards,

Rodrigo


GeoSWRL.java
GeoSWRLValidation.owl
IsWithinDistance.java
Main.java
GEOSPARQL.java

Rodrigo Antonialli

unread,
Apr 15, 2015, 5:45:16 PM4/15/15
to pellet...@googlegroups.com
One more thing about this issue: 

I've built version 2.3.2-SNAPSHOT from github. The first time, some months ago, and today again, just to check.... 

The built was ok, and this version is working pretty well in other tasks. I'm using jena 2.12 to do other things, and the 2.3.2 version works fine, most rules have few core builtins, and most owl class and properties assertions. 

The inferences with owl axioms looks good too. 

Kendall Clark

unread,
Apr 15, 2015, 5:57:46 PM4/15/15
to Rodrigo Antonialli, pellet...@googlegroups.com
Rodrigo,

To answer just one of yr questions, Pellet 2.x is community maintained now that it's at Github.

Cheers,
Kendall Clark
--
You received this message because you are subscribed to the Google Groups "Pellet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pellet-users...@googlegroups.com.
To post to this group, send email to pellet...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pellet-users/727753eb-6278-4d43-a639-a8b2a274a567%40googlegroups.com.

Rodrigo Antonialli

unread,
Apr 16, 2015, 7:59:00 AM4/16/15
to Kendall Clark, pellet...@googlegroups.com
Thanks, it's good to know it goes on!

This version still keeps bug tracks, and release roadmaps? 

Maybe I can look for differences in release 2.3.1 and the last version on master branch. If there's no doc about it yet, I can look for commits. 



Rodrigo C. Antonialli
======================================
Rio Claro - SP - Brasil
LinkedIn: http://www.linkedin.com/in/rcantonialli
Contato:  rcanto...@gmail.com
              Skype: rc_antonialli

Rodrigo Antonialli

unread,
Apr 16, 2015, 2:47:51 PM4/16/15
to Kendall Clark, pellet...@googlegroups.com
Ok, I was able to "fix" the problem, but I have no ideia why... 

So, the problem was about "isApplicable" method of GeneralFunction... for some reason, it must return false to work... 

So, again, the example rule:

Thing(?t1), Thing(?t2), hasGeometry(?t1, ?geom1), hasGeometry(?t2, ?geom2), asWKT(?geom1, ?wkt1), asWKT(?geom2, ?wkt2), isWithinDistance(?wkt1, ?wkt2, 0.012) -> nearby(?t1, ?t2) 


The custom builtIn is isWithinDistance function... which has 3 args set in this case. 

So I've noticed the following behavior:

With Pellet 2.3.1: No matter if isApplicable returns true or false. The function is always executed.

With Pellet 2.3.2-SNAPSHOT: isApplicable must return false. Otherwise, null values are set for the first two args (?wkt1 and ?wkt2).

In both version, the argument for isApplicable "boolean[] boundPositions" length is == 3 (it is correct for other custom builtins...)... 

Is this behavior expected?? As far as I could see, the isApplicable function is called in GeneralFunctionBuiltIn class, which has it's own isApplicable method... but I couldn't see any changes in this class, in both versions.... Although the git history shows some changes regarding rules (around 10 months ago)

Well, I think my problem is solved now, as far as I tested, return false in isApplicable make my custom builtIns work... Anyway it would be nice to know why...Someone has any clue?? =P

Cheers!


Rodrigo C. Antonialli
======================================
Rio Claro - SP - Brasil
LinkedIn: http://www.linkedin.com/in/rcantonialli
Contato:  rcanto...@gmail.com
              Skype: rc_antonialli

Evren Sirin

unread,
Apr 17, 2015, 10:12:51 AM4/17/15
to Rodrigo Antonialli, Kendall Clark, pellet...@googlegroups.com
The function isApplicable(boolean[] boundPositions) should look at
which variables are bound and return true only if it can evaluate the
function with given variables; i.e. the function will bind the
variables to actual values. It looks like your function can only
evaluate ground values so it should return true only when the array
length is 3 and all the elements in the array are true. If your
function does not bind any variables then you can always return false
as that indicates this function has no bindable variables. The problem
occurs when the function returns true incorrectly as in your first
attempt because the rule engine will not be able to choose a correct
ordering of the atoms in the rule and will try to execute your
function with unbound variables.

Best,
Evren
> https://groups.google.com/d/msgid/pellet-users/CAB0YjdSgFTnoZqxWoD9yhW7SVrx-Ctpcd%2BQH8fX9h10zErhVCw%40mail.gmail.com.

Rodrigo Antonialli

unread,
Apr 17, 2015, 1:14:21 PM4/17/15
to Evren Sirin, Kendall Clark, pellet...@googlegroups.com
Thank you very much Evren!!

Now I understand the meaning of this method and It's clear how it should be used!

Cheers,

Rodrigo C. Antonialli
======================================
Rio Claro - SP - Brasil
LinkedIn: http://www.linkedin.com/in/rcantonialli
Contato:  rcanto...@gmail.com
              Skype: rc_antonialli

yzhan...@gmail.com

unread,
Nov 6, 2016, 10:06:26 PM11/6/16
to Pellet Users, rcanto...@gmail.com, ken...@complexible.com
Could you explain it more detail? I can not understand it. whether I can let isApplicalbe() always return false?


在 2015年4月17日星期五 UTC+8下午10:12:51,Evren Sirin写道:
Reply all
Reply to author
Forward
0 new messages