[tbc-users] Re: own functions in spin:rules
Yes, this convention has been introduced to make some functions more convenient, reducing the number of arguments. For example, this approach allows you to define a cardinality function that only needs the property as argument - the subject would be ?this. Keep in mind though that calling such functions only makes sense within object-oriented SPIN queries such as spin:rule and spin:constraint, because they are context sensitive. Holger On Mar 18, 2009, at 12:49 AM, Bohms, H.M. (Michel) wrote: Hi Scott, I deleted the argument stuff (call and definition) and indeed: same behaviour. I understand ?this but I had not thought that its binding would have been known within the local scope of the defined function. So now I see its global for both the calling query and the executing function. Ch/Michel -Original Message- From: topbraid-composer-users@googlegroups.com [mailto:topbraid-composer-users@googlegroups.com ] On Behalf Of Scott Henninger Sent: 17 March 2009 18:30 To: TopBraid Composer Users Subject: [tbc-users] Re: own functions in spin:rules Yes. The way ?this works is that it is applied to all instances of the class. You defined your sumFunction to be used with SPIN so that a query defined for a class is applied to all instances of the class. Another way to see how ?this works is to copy/paste your sumFunction construct query into the SPARQL Tab. Run the query then choose instances of the class. With each choice the constructed triple will change so that ?this is bound to the chosen resource. This is a good way to edit/debug your SPIN rules. I.e. ?this applies to a chosen resource and SPIN defines the chosen resource to be all instance of the class the spin:rule is defined on. -- Scott On Mar 17, 11:35 am, Bohms, H.M. (Michel) michel.bo...@tno.nl wrote: Great, it works now. Wrt your argument issue: is that because the function works already implicitly on ?this ? Thanks for getting it to work! Michel -Original Message- From: topbraid-composer-users@googlegroups.com [mailto:topbraid-composer-us...@googlegroups.com] On Behalf Of Scott Henninger Sent: 17 March 2009 17:26 To: TopBraid Composer Users Subject: [tbc-users] Re: own functions in spin:rules In terms of the sumFunction not working, there are a number of things going on in the file you sent. The most important is the type of the spin function (sumFunction) is defined as owl:Class. It needs to be spin:Function. The argument defined in sumFunction is not necessary, as it is not used in the query, but will not hurt anything. -- Scott But when executing: no error, but when I try to look at an individual for its derived value (totalCost of say House1): Operation Failed, Reason: Could not execute query; attempt to get a CONSTRUCT model from a slect query. This e-mail and its contents are subject to the DISCLAIMER athttp://www.tno.nl/disclaimer/email.html This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/disclaimer/email.html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[tbc-users] Re: own functions in spin:rules
Replying myself after reading the manual :) I now first defined a subclass of sp:Functions called sumFunction. Then I defined a spin:constraint for it: Argument sp:arg1 : House Finally I defined a body for it (delete at House...): SELECT SUM(?cost) AS ?totalCost WHERE { arg1 :hasPart_transitive ?Part . ?Part :cost ?cost . OPTIONAL { ?Part :hasPart_directly ?anotherPart . } . FILTER (!bound(?anotherPart)) . } still 2 problems: 1. the box for the body stays red 2. at House: the box for the spin:rule: CONSTRUCT {?this :totalCost ?totalCost } WHERE { LET (?totalCost := sumFunction (?this)). } is still red (despite the function is now known...). Feel I am getting closerthx for getting it to work! Michel On 17 mrt, 13:28, Michel Bohms michel.bo...@gmail.com wrote: Hi Holger, In earlier mails we discussed the determination of totalCost (of some 'whole') via a helper function. When I do as spin:rule: CONSTRUCT {?this :totalCost ?totalCost } WHERE { LET (?totalCost := sumFunction (?this)). } it seems the box stays red although I defined: a spin:body SELECT SUM(?cost) AS ?totalCost WHERE { ?this :hasPart_transitive ?Part . ?Part :cost ?cost . OPTIONAL { ?part :hasPart_directly ?anotherPart . } . FILTER (!bound(?anotherPart)) . } clearly I am missing the sumFuction definition itself but how do I do that ? (assuming SUM is now implemented in the latest beta). (to refresh your memory: the idea was to calculate the cost of the whole by counting all the leaf part's cost via querying over the all transitive parts and then filter out the atomic leafs) thx a lot, Michel --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[tbc-users] Re: own functions in spin:rules
Hello Scott, I'll have a look. partial choices: in attached ontology when I wanted to add existing individuals of WallSegment as parts for my Wall individuals. if you want to reproduce: 1. go to Wall1 of Class Wall 2. at hasPart_directly widget do add existing' (there are already 2 individuals there) 3. the list on the right has no scroll bar only after you select again the already selected owl:Thing (I added some dummy individuals to make the problem apperent otherwise the list was too short...) ps this is the same ontology of the inference problemyou get the error when you run Inferences and then try to look at Wall1 again...(anyway I study your examples too) TNO.NL Michel Böhms Consultant Building Innovation TNO Built Environment and Geosciences Van Mourik Broekmanweg 6 | PO Box 49 | 2600 AA Delft | The Netherlands T +31 15 2763107 M +31 6 30381220 E michel.bo...@tno.nl blocked::blocked::blocked::mailto:michel.bo...@tno.nl Disclaimer blocked::http://www.tno.nl/content.cfm?context=overtnocontent=overtnosublaag1=282item_id=72Taal=2 From: topbraid-composer-users@googlegroups.com [mailto:topbraid-composer-us...@googlegroups.com] On Behalf Of Scott Henninger Sent: 17 March 2009 15:44 To: topbraid-composer-users@googlegroups.com Subject: [tbc-users] Re: own functions in spin:rules It seems that somewhere the function is not getting defined in the right places. Attached is a minimal file that calls the function in a spin:rule. ...when you 'add existing' (and owl:Thing is higlighted) ther is only a partial set of choices... Where exactly is this happening? -- Scott Bohms, H.M. (Michel) wrote: Dear Scot, All red boxes resolved. But when executing: no error, but when I try to look at an individual for its derived value (totalCost of say House1): Operation Failed, Reason: Could not execute query; attempt to get a CONSTRUCT model from a slect query. Ps Small other issue: when you 'add existing' (and owl:Thing is higlighted) ther is only a partial set of choices on the right side; only after you select manually owl:Thing you can scroll (ie initially the scroll bar is missing..). -Original Message- From: topbraid-composer-users@googlegroups.com [mailto:topbraid-composer-us...@googlegroups.com] On Behalf Of Scott Henninger Sent: 17 March 2009 14:48 To: TopBraid Composer Users Subject: [tbc-users] Re: own functions in spin:rules Michel; The red box indicates syntax errors, which are shown in the status bar at the bottom of Composer. The first syntax error is to encapsulate the AS statement with parentheses: SELECT (SUM(?cost) AS ?totalCost) The second is to use the variable name ?arg1 - i.e. the ? is missing. When a function is created, it exists in your ontology as a URI. Therefore you need to use a qname or full URI to name the function, i.e.: :sumFunction() or http://myStuff.org/funct#sumFunction http://myStuff.org/funct#sumFunction () Give that a try. -- Scott On Mar 17, 8:11 am, Michel Bohms michel.bo...@gmail.com mailto:michel.bo...@gmail.com wrote: Replying myself after reading the manual :) I now first defined a subclass of sp:Functions called sumFunction. Then I defined a spin:constraint for it: Argument sp:arg1 : House Finally I defined a body for it (delete at House...): SELECT SUM(?cost) AS ?totalCost WHERE { arg1 :hasPart_transitive ?Part . ?Part :cost ?cost . OPTIONAL { ?Part :hasPart_directly ?anotherPart . } . FILTER (!bound(?anotherPart)) . } still 2 problems: 1. the box for the body stays red 2. at House: the box for the spin:rule: CONSTRUCT {?this :totalCost ?totalCost } WHERE { LET (?totalCost := sumFunction (?this)).} is still red (despite the function is now known...). Feel I am getting closerthx for getting it to work! Michel On 17 mrt, 13:28, Michel Bohms michel.bo...@gmail.com mailto:michel.bo...@gmail.com wrote: Hi Holger