Actually, looking deeper once more, I saw that my statement below was based on another problem in my runtime. I now think the current code is correct, but is it possible that you pass in a Model into the registerAll function that does not import the SP namespace? It should be an OntModel that imports the http://spinrdf.org/sp namespace. If not, then the system will not know that sp:_arg1 etc are variables, and will expand them into constants. If this does not work, please send me your code (possibly off-list).
Holger On Mar 30, 2009, at 4:31 PM, Holger Knublauch wrote: > Hi Jeff, > > this is another manifestation of the same problem with the default > libraries. I debugged this and saw that - in stand-alone SPIN API > use - the query is again expanded into sp:mul and does not recognize > this as the built-in function *. > > While I will look into changing this for the next release, a simple > work-around is to have your function model import the http://spinrdf.org/spl > namespace and then run the registerAll: > > Model baseModel = ModelFactory.createDefaultModel(); > baseModel.read(...); > OntModel ontModel = > ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, baseModel); > SPINModuleRegistry.get().registerAll(ontModel); > > > Thanks for the report, > Holger > > > On Mar 30, 2009, at 2:32 PM, Schmitz, Jeffrey A wrote: > >> Continuing with the SPIN API, I've created my own function >> (twoDimArea, attached) in my own model (SpinLib.owl). I have >> successfully registered the function using: >> SPINModuleRegistry.get().registerFunctions(spinLibModel); >> >> I know it was registered because I can call: >> Function twoDimFunc = >> spinLibModel.getFunction("http://www.boeing.com/IVHM/SpinLib.owl#twoDimArea >> "); >> >> and then I can retrieve and print out the function's comment. >> Then I went back into the spinsquare.n3 model and changed the >> spin:rule on the Rectangle class to be reference my new function: >> >> # Computes area := width * height >> CONSTRUCT {?this :area ?area .} >> WHERE { >> ?this :width ?width . >> ?this :height ?height . >> LET (?area := SpinLib:twoDimArea(?width, ?height)) . >> } >> >> Since the twoDimArea function has been registered, I would expect >> the call to run the inferences on the spinsquare model to still work: >> SPINInferences.run(spinsquareOntModel, infmodel, exp, null, true, >> null); >> >> However, it's not returning any inferences. Note that changing the >> CONSTRUCT query back to use LET(?area := ?width * ?height) does >> still work. >> >> Am I missing a step in registering my new function? Or is there >> some other reason the SPINInferences engine isn't able to execute >> the new function? >> >> Thanks, >> >> Jeff >> >> <Outlook.jpg> >> >> >> >> From: Holger Knublauch [mailto:hol...@topquadrant.com] >> Sent: Thursday, March 26, 2009 7:37 PM >> To: topbraid-composer-users@googlegroups.com >> Subject: [tbc-users] Re: SPIN API is now open source >> >> The line below is shown in the examples that come with the SPIN API >> download, but I admit this is not obviously pointed out. I will >> either make this fact more prominent, or add such a call by default >> to make life easier. >> >> Holger >> >> >> On Mar 26, 2009, at 2:03 PM, Schmitz, Jeffrey A wrote: >> >>> Nope, missed that part. That did it though, thanks! Looks like >>> great stuff! >>> >>> Jeff >>> >>> From: Holger Knublauch [mailto:hol...@topquadrant.com] >>> Sent: Thursday, March 26, 2009 3:41 PM >>> To: topbraid-composer-users@googlegroups.com >>> Subject: [tbc-users] Re: SPIN API is now open source >>> >>> Hi Jeff, >>> >>> did you call this at init time: >>> >>> // Initialize system functions and templates >>> SPINModuleRegistry.get().init(); >>> >>> This will load the spl namespace and the functions defined >>> therein, including the system functions such as sp:mul so that the >>> SPIN engine knows that they are abbreviated (e.g. using *). >>> >>> Holger >>> >>> >>> On Mar 26, 2009, at 1:28 PM, Schmitz, Jeffrey A wrote: >>> >>>> >>>> Hello, >>>> I finally got a chance to look through the new SPIN API, and >>>> started >>>> with trying to run the SPIN rules on the spinsquare ontology. I >>>> think >>>> I'm pretty close, except it's choking on the line in the spin:rule >>>> construct query that uses the multiplication symbol, i.e. >>>> >>>> LET (?area := (?width * ?height)) . >>>> >>>> Stepping through the code, I can see that this gets turned into >>>> what I >>>> would guess must be a property function named sp:mul: >>>> >>>> LET (?area := sp:mul(?width, ?height)) >>>> >>>> However, I don't think my execution environment has access to that >>>> function and thus the query doesn't return anything. Is there >>>> any way I >>>> could get this function and make it available to my execution >>>> environment, and is that documented anywhere? Or is that not >>>> part of >>>> the release? >>>> >>>> Thanks! >>>> Jeff >>>> >>>> -----Original Message----- >>>> From: Holger Knublauch [mailto:hol...@topquadrant.com] >>>> Sent: Saturday, March 07, 2009 12:38 PM >>>> To: topbraid-composer-users@googlegroups.com >>>> Subject: [tbc-users] SPIN API is now open source >>>> >>>> >>>> Dear users, >>>> >>>> we have had several requests from people who would like to >>>> integrate >>>> SPIN functionality (SPARQL-based constraint checking, inferencing, >>>> user-defined functions) into their own applications. In order to >>>> encourage the wider adoption of SPIN in the community, we have >>>> therefore >>>> decided to make the key features of our SPIN implementation open >>>> source: >>>> >>>> http://www.topquadrant.com/topbraid/spin/api/ >>>> The SPIN API is built on Jena and provides the following features: >>>> >>>> * Converters between textual SPARQL syntax and the SPIN RDF >>>> Vocabulary >>>> * A SPIN-based constraint checking engine (via spin:constraint) >>>> * A SPIN-based inferencing engine (via spin:rule and >>>> spin:constructor) >>>> * Support to execute user-defined SPIN functions using Jena/ARQ >>>> * Support to execute user-defined SPIN templates >>>> >>>> The license has been selected to allow open source projects (from >>>> universities etc) to use SPIN without further complications. For >>>> closed >>>> source users, we offer a commercial license that also provides >>>> business >>>> users assurance and support. With this policy we hope to encourage >>>> researchers to provide their (open source) implementations back >>>> to the >>>> community to help the SPIN community grow. >>>> >>>> The SPIN API is currently in beta, and the official 1.0 release is >>>> scheduled in conjunction with TopBraid 3.0 in the next few weeks. >>>> We >>>> appreciate your feedback in the meantime. >>>> >>>> Kinds regards, >>>> Holger >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>> >> >> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TopBraid Composer Users" group. To post to this group, send email to topbraid-composer-users@googlegroups.com To unsubscribe from this group, send email to topbraid-composer-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/topbraid-composer-users?hl=en -~----------~----~----~----~------~----~------~--~---