Hi Holger,
that's not it. I tried this as well:
CONSTRUCT {
> ?this :hasIndirectCapability ?newNode.
> ?newNode a :IndirectCapability .
> ?newNode :indirectAccessory ?accessory .
> ?newNode :indirectAction ?actionType .
> }
> WHERE {
> ?this :compatibleWithAccessory ?accessory .
> ?accessory a ?accessoryClass .
> ?accessoryClass (rdfs:subClassOf)* :Accessory .
> ?accessory :fitForActionType ?actionType .
> BIND(BNODE() AS ?newNode).
> FILTER NOT EXISTS {
> ?this :hasIndirectCapability ?cap .
> ?cap :indirectAccessory ?accessory.
> ?cap :indirectAction ?actionType.
> } .
> }
It interesting, since the SPARQL view behaves *exactly *as expected. It
constructs exactly 1 blank node with the expected properties. I can also
run this sort of INSERT query:
CONSTRUCT {
> ?tool :hasIndirectCapability ?newNode.
> ?newNode a :IndirectCapability .
> ?newNode :indirectAccessory ?accessory .
> ?newNode :indirectAction ?actionType .
> }
> WHERE {
> ?tool a ?toolClass.
> ?toolClass rdfs:subClassOf* :Tool.
> ?tool :compatibleWithAccessory ?accessory .
> ?accessory a ?accessoryClass .
> ?accessoryClass (rdfs:subClassOf)* :Accessory .
> ?accessory :fitForActionType ?actionType .
> BIND(BNODE() AS ?newNode).
> FILTER NOT EXISTS {
> ?tool :hasIndirectCapability ?cap .
> ?cap :indirectAccessory ?accessory.
> ?cap :indirectAction ?actionType.
> } .
> }
Which produces the right amount of nodes and no additional nodes when run
multiple times.
This seems more like a bug in the SPIN reasoner. It doesn't seem to handle
the blank nodes correctly, if they were created by a SPIN rule...
If you'd like to check it out: I've created a minimal ontology to
demonstrate the issue: http://pastebin.com/WfWQfwvG
Every time you run the reasoner, it creates additional IndirectCapability
individuals This shouldn't be the case.
Regards,
Michael
On Saturday, 1 February 2014 00:22:18 UTC+1, Holger Knublauch wrote:
>
> Hi Michael,
>
> it's probably multiplying the execution of the CONSTRUCT part for every
> OPTIONAL match. Could you try changing it to
>
> FILTER NOT EXISTS {
> ?this :hasIndirectCapability ?indirectAction .
> ?indirectAction :indirectAction ?actionType .
> ?indirectAction :indirectAccessory ?accessory .
> ?this :hasIndirectCapability ?indirectAction .
> } .
>
> BTW a more readable alternative to the _:b0 syntax is to create a bnode in
> the WHERE clause
>
> BIND(BNODE() AS ?newNode)
>
> and then use ?newNode instead of _:b0
>
> HTH
> Holger
>
>
> On 2/1/2014 1:11, Michael B. wrote:
>
> Tim,
>
> thanks for the hint! You were totally right. I modified my query to:
>
> CONSTRUCT {
>> _:b0 a :IndirectCapability .
>> ?this :hasIndirectCapability _:b0 .
>> _:b0 :indirectAction ?actionType .
>> _:b0 :indirectAccessory ?accessory .
>> }
>> WHERE {
>> ?this :compatibleWithAccessory ?accessory .
>> ?accessory a ?accessoryClass .
>> ?accessoryClass (rdfs:subClassOf)* :Accessory .
>> ?accessory :fitForActionType ?actionType .
>> OPTIONAL {
>> ?this :hasIndirectCapability ?indirectAction .
>> ?indirectAction :indirectAction ?actionType .
>> ?indirectAction :indirectAccessory ?accessory .
>> } .
>> FILTER NOT EXISTS {
>> ?this :hasIndirectCapability ?indirectAction .
>> } .
>> }
>
>
> This works perfectly fine, but for some reason creates 4 new nodes
> *every* time I run the reasoner. So after each "run inferences", I get 4
> new individuals of IndirectCapability.
>
> On Friday, 31 January 2014 15:34:10 UTC+1, Tim Smith wrote:
>>
>> I believe the SPIN reasoner stops when a pass does not create any new
>> triples. In this case, since the where clause is true even after
>> constructing the blank node and since you are using blank nodes which have
>> unique URIs by definition, the reasoner will always create new triples and
>> thus never stop.
>>
>> To fix it, I think you'll need to either create a URI that will be
>> created again on subsequent passes or modify the where clause to detect if
>> the desired triples already exist.
>>
>> I ran into a similar problem when I tried to use a UUID as part of a uri
>> inside a spin rule.
>> On Jan 31, 2014 9:06 AM, "Irene Polikoff" <[email protected]> wrote:
>>
>>> I would think you want to give whatever you are creating a type. Is it
>>> owl:Class?
>>>
>>> I also wonder if you need the middle two statements in the WHERE
>>> clause. Judging by the name of :compatibleWithAccessory the range of its
>>> values will always be an accessory. But, of course, I don't know your model
>>> and I can't say off hand what throws the reasoner into a loop.
>>>
>>> Sent from my iPhone
>>>
>>> On Jan 31, 2014, at 8:49 AM, "Michael B." <[email protected]> wrote:
>>>
>>> Hi Irene,
>>>
>>> my mistake. I don't want to specify a URI. What I need a new blank
>>> node which will be attached to ?this. This works a bit better:
>>>
>>> CONSTRUCT {
>>>> _:1 :fitForActionType ?actionType .
>>>> _:1 :compatibleWithAccessory ?accessory .
>>>> _:1 rdfs:subClassOf :IndirectCapability.
>>>> ?this :hasIndirectCapability _:1 .
>>>> }
>>>> WHERE {
>>>> ?this :compatibleWithAccessory ?accessory .
>>>> ?accessory a ?accessoryClass.
>>>> ?accessoryClass rdfs:subClassOf* :Accessory.
>>>> ?accessory :fitForActionType ?actionType .
>>>> }
>>>
>>>
>>> Problem is: the SPIN reasoner whacks out on this. It gets stuck in a
>>> loop...
>>>
>>> Regards,
>>> Michael
>>>
>>> On Friday, 31 January 2014 14:46:32 UTC+1, Irene Polikoff wrote:
>>>>
>>>> Michael,
>>>>
>>>> Yes, you can infer any triples you want in a rule. But the example
>>>> query you created needs to be changed.
>>>>
>>>> Your CONSTRUCT clause will not work because ?x is unbound. You must
>>>> bind it in the WHERE clause to create a URI for this new resource. Check
>>>> out various TopBraid functions for building URI.
>>>>
>>>> Regards,
>>>>
>>>> Irene
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On Jan 31, 2014, at 8:10 AM, "Michael B." <[email protected]> wrote:
>>>>
>>>> Is there any way to create new instances / resources using a SPIN
>>>> rule? I'd like to infer a new individual with something like this:
>>>>
>>>>
>>>>
>>>>> CONSTRUCT { ?x a :IndirectCapability.
>>>>> ?x :fitForActionType ?actionType.
>>>>> ?x :compatibleWithAccessory ?accessory.
>>>>> ?this :hasIndirectCapability ?x}
>>>>> WHERE {
>>>>> ?this :compatibleWithAccessory ?accessory.
>>>>> ?accessory :fitForActionType ?actionType.
>>>>> }
>>>>
>>>>
>>>> Regards,
>>>> Michael
>>>> --
>>>> -- You received this message because you are subscribed to the Google
>>>> Group "TopBraid Suite Users", the topics of which include Enterprise
>>>> Vocabulary Network (EVN), TopBraid Composer, TopBraid Live, TopBraid
>>>> Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
>>>> To post to this group, send email to
>>>> [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/topbraid-users?hl=en
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "TopBraid Suite Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>> --
>>> -- You received this message because you are subscribed to the Google
>>> Group "TopBraid Suite Users", the topics of which include Enterprise
>>> Vocabulary Network (EVN), TopBraid Composer, TopBraid Live, TopBraid
>>> Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
>>> To post to this group, send email to
>>> [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/topbraid-users?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "TopBraid Suite Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>> --
>>> -- You received this message because you are subscribed to the Google
>>> Group "TopBraid Suite Users", the topics of which include Enterprise
>>> Vocabulary Network (EVN), TopBraid Composer, TopBraid Live, TopBraid
>>> Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
>>> To post to this group, send email to
>>> [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/topbraid-users?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "TopBraid Suite Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>> --
> -- You received this message because you are subscribed to the Google
> Group "TopBraid Suite Users", the topics of which include Enterprise
> Vocabulary Network (EVN), TopBraid Composer, TopBraid Live, TopBraid
> Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
> To post to this group, send email to
> [email protected] <javascript:>
> To unsubscribe from this group, send email to
> [email protected] <javascript:>
> For more options, visit this group at
> http://groups.google.com/group/topbraid-users?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary
Network (EVN), TopBraid Composer, TopBraid Live, TopBraid Insight,
SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
---
You received this message because you are subscribed to the Google Groups
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.