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]
    <javascript:>> 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] <javascript:>> 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
            <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
            <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
        <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
        <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
        <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
        <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.

Reply via email to