Ok so here is the rule

[InferredMembership:  (?u ie:memberOf ?g)
          <- allValue(?g ie:mandatoryInterestsForGroupInclusion
                         ie:helpsIndividualDefine ?u)]


And here is the code for AllValues

      logger.info(" subject is " + subj + " pred is " + pred + " pred2  is
" + pred2 + " obj is " + obj);

        ClosableIterator<Triple> ti =  context.find(subj, pred, (Node)
null);
        while (ti.hasNext()) {
            Triple triple = ti.next();
            logger.info(" got a triple of " + triple);
            logger.info(" triple subject is " + triple.getSubject());
            logger.info(" triple pred is " + triple.getPredicate());
            logger.info(" triple object is " + triple.getObject());
            logger.info(" looking for subject (triple.getObject()" +
triple.getObject() + " pred2 is " + pred2 + " obj is " + obj);
            if (!context.contains(triple.getObject(), pred2, obj)) {
                logger.info(" returning false");
                return false;
            }
        }


        logger.info(" returning true");

        return true;


When I have a case of true I get an error:

    [java] com.hp.hpl.jena.reasoner.ReasonerException: Internal error in LP
reasoner: variable in triple result
     [java]     at
com.hp.hpl.jena.reasoner.rulesys.impl.LPInterpreter.derefPossFunctor(LPInterpreter.java:784)


I assume I have to bind ?u somewhere.  How?  Where ?


On Wed, Nov 7, 2012 at 9:06 AM, Dave Reynolds <[email protected]>wrote:

> On 07/11/12 13:44, Scott Streit wrote:
>
>>   (?u ie:memberOf ?g)
>>          <- (?g ie:**mandatoryInterestsForGroupIncl**usion ?i)
>>             allValue(?i ie:#hasIndivudalInterestOf ?u)
>>
>> If I wrote an allValue builtIn, this would solve the problem correct.
>>
>
> You can't have an allValue predicate with that signature, what would it
> mean?
>
>
>  What I mean by this is all forward chaining would take place first, and
>> now
>> I could backward chain allValue.  All I need to do is write allValue.
>>
>> This is correct, right?
>>
>
> You could certainly do that bit of the work in code instead of in rules,
> sure. Though if you end up with just a few simple rules and a lot of
> special case builtins then the rule engine may not be offering you much
> value. You might just use code for everything or a sequenced set of SPARQL
> CONSTRUCT queries (SPARQL sub-queries, coupled with the unbound predicate,
> can do some closed world tests for you).
>
> If you do choose to go for a builtin then you'll need one that looks more
> like:
>
>   (?u ie:memberOf ?g)
>           <- allValue(?g ie:**mandatoryInterestsForGroupIncl**usion
>                          ie:hasIndivudalInterestOf ?u)
>
> Then the predicate allValue(root P Q u) would find all values ?x such that
> (root P ?x) and then pass if (u Q ?x) is true for all of those ?x.
>
> You would need to decide whether either or both of u and g can be unbound.
>
>
>  Now I looked at noValue and
>>
>>         return !context.contains(subj, pred, obj);
>>
>> and this is where I would make the change correct?
>>
>
> You'll need bigger changes than that, see above.
>
>
>  Also, how do I tell Jena of a new built in?
>>
>
>    BuiltinRegistry.theRegistry.**register(new MyBuiltin());
>
> Dave
>
>


-- 
"If you are lucky enough to have lived in Paris as a young man, then
wherever you go for the rest of your life, it stays with you, for Paris is
a moveable feast." -  Ernest Hemingway

www.scottstreit.com

Reply via email to