You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Rob Stewart <ro...@googlemail.com> on 2011/09/15 19:05:28 UTC

Problem: deducing Jena rules

Hi,

I'm having a problem with the InfModel getDeductionsModel() method.

See my two files:

* Rules: http://www.macs.hw.ac.uk/~rs46/jenarules/rules.txt

* Java source: http://www.macs.hw.ac.uk/~rs46/jenarules/JenaRules.java

You can see that it is reading from my SPARQL endpoint, and that when
running it, spews out lots of :

 INFO [main] (FRuleEngine.java:407) - Fired rule: rule1 = [ rule1:
......... [etc]
 INFO [main] (FRuleEngine.java:407) - Fired rule: rule1 = [ rule1:
......... [etc]


However, when I inspect the generated inferred.rdf file, it doesn't
contain any of them:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
</rdf:RDF>

What am I missing?

My files should compile and run if you want to verify.

Regards,

--
Rob Stewart

Re: Problem: deducing Jena rules

Posted by Dave Reynolds <da...@gmail.com>.
On Thu, 2011-09-15 at 18:05 +0100, Rob Stewart wrote: 
> Hi,
> 
> I'm having a problem with the InfModel getDeductionsModel() method.
> 
> See my two files:
> 
> * Rules: http://www.macs.hw.ac.uk/~rs46/jenarules/rules.txt
> 
> * Java source: http://www.macs.hw.ac.uk/~rs46/jenarules/JenaRules.java
> 
> You can see that it is reading from my SPARQL endpoint, and that when
> running it, spews out lots of :
> 
>  INFO [main] (FRuleEngine.java:407) - Fired rule: rule1 = [ rule1:
> ......... [etc]
>  INFO [main] (FRuleEngine.java:407) - Fired rule: rule1 = [ rule1:
> ......... [etc]
> 
> 
> However, when I inspect the generated inferred.rdf file, it doesn't
> contain any of them:
> 
> <rdf:RDF
>     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
> </rdf:RDF>
> 
> What am I missing?
> 
> My files should compile and run if you want to verify.

They compile, which is helpful, but without your data they can't be
usefully run.

My best *guess* is that your data looks something like:

  example:doc1 sioc:has_creator example:user1 .
  example:user1 sioc:id 'user 1' .

Your rule is:

[rule1: (?doc1 sioc:has_creator ?user1)
(?user1 sioc:id ?personA)
     -> (?personA example:made ?doc1)]

So in that case it will try to assert the triple:

    ('user 1' example:made example:doc1)

The trouble is that in RDF you can't have literals as the subject of a
statement. Internally Jena allows this and the rules systems allow it
(because it is so useful to be able to chain deductions together) but by
default such illegal triples aren't allowed to escape from the rule
system and in any case can be serialized. So in that case you would get
the rule firing but no (legal) data will end up in the deductions model.

If that's the problem then you should represent your people by
resources, with a separate label or foaf:name.

If that's not the problem then post (a minimal sample of) your data.

Dave