You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Abduladem Eljamel <a_...@yahoo.co.uk.INVALID> on 2016/04/16 19:26:38 UTC

Jena Reasoning

Hi,,I am not sure if I am using Jena reasoning and rules correctly. I could not get any results after following some of examples in jena website. This one of the codes which I do not know where is wrong in it:
OntModel schema = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);
.schema.add(kwakeb, employerOfNAry, rel01);
schema.add(rel01, hasRelationValue, hadi);
String ruleSrc ="[r1: (?org employerOfNAry ?nary) (?nary hasRelationValue ?per) -> (?org employerOf  ?per)] ";List rules = Rule.parseRules(ruleSrc);
Reasoner reasoner = new GenericRuleReasoner(rules);  
InfModel infmodel = ModelFactory.createInfModel(reasoner, schema);
It supposed to add the triple => ( kwakeb employerOf hadi)Could some one please tell me what I missed in Jena reasonong?Thank you in advanceAbdul

Re: Jena Reasoning

Posted by Dave Reynolds <da...@gmail.com>.
Hi,

On 17/04/16 15:06, Abduladem Eljamel wrote:
> Hi Dave
> Thank you for answering my email.
> I don't know what is reason of the scrambling my emails. I sent the same email to many other email accounts and there is no scrambling.
>
> Regarding to my last question, it is as you said, the problem was related to URIs. After adding URIs to the rules, they are working fine now. Thank you again.

Good.

> I have other question, I am extracting information from online news documents, entities and relations between them. Then, I populate them to a semantic knowledge-base by using an Ontology. My Idea is to put the Information Extracted from a every document into a separate named graph. It means that the semantic knowledge-base is a collection of named graphs and every named graph represents one document. Practically, I am storing the semantic knowledge-base into TDB store and the ontology in a separate RDF file.
>
> My question is how to apply reasoning to all named graphs in the same time and the named graphthe in the resulting inferred knowledge-base stay separate.

The reasoners are not dataset-aware. That is, they work at the level of 
single models/graphs - you apply reasoner to a single graph and you get 
an InfGraph in which the inference results are visible (stored in memory 
or computed on demand).

If you have a set of named graphs and you want to compute some inference 
closure over each of them separately then you'll just have to write code 
which will iterate over the source graphs and create an InfGraph for 
each. If your goal is to have the results of that inference be 
persistent then you would need code that copies the resulting InfGraph 
contents to a set of named graphs in some store.

Dave

>        From: Dave Reynolds <da...@gmail.com>
>   To: users@jena.apache.org
>   Sent: Sunday, 17 April 2016, 9:52
>   Subject: Re: Jena Reasoning
>
> Hi,
>
> Your email came through too scrambled to read but ...
>
> On 16/04/16 18:26, Abduladem Eljamel wrote:
>> Hi,,I am not sure if I am using Jena reasoning and rules correctly. I could not get any results after following some of examples in jena website. This one of the codes which I do not know where is wrong in it:
>> OntModel schema = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);
>
> Probably best to make that plain OWL_MEM, at least to begin with
> otherwise you have the OWL reasoner running underneath a generic rule
> reasoner which will complicate your debugging.
>
>> .schema.add(kwakeb, employerOfNAry, rel01);
>
> What are the values of all these variables? Especially employerOfNAry?
>
> You haven't shown us the rest of your code.
>
>> schema.add(rel01, hasRelationValue, hadi);
>> String ruleSrc ="[r1: (?org employerOfNAry ?nary) (?nary hasRelationValue ?per) -> (?org employerOf  ?per)] ";List rules = Rule.parseRules(ruleSrc);
>
> This is using "employerOfNAry" as the predicate in the rule, but that's
> not a URI and so is unlikely to match whatever you have put into schema.
>
> Make sure you use consistent URIs in both your data and rules.
>
> Dave
>
>
>
>
>

Re: Jena Reasoning

Posted by Abduladem Eljamel <a_...@yahoo.co.uk.INVALID>.
Hi Dave
Thank you for answering my email. 
I don't know what is reason of the scrambling my emails. I sent the same email to many other email accounts and there is no scrambling.

Regarding to my last question, it is as you said, the problem was related to URIs. After adding URIs to the rules, they are working fine now. Thank you again.

I have other question, I am extracting information from online news documents, entities and relations between them. Then, I populate them to a semantic knowledge-base by using an Ontology. My Idea is to put the Information Extracted from a every document into a separate named graph. It means that the semantic knowledge-base is a collection of named graphs and every named graph represents one document. Practically, I am storing the semantic knowledge-base into TDB store and the ontology in a separate RDF file.

My question is how to apply reasoning to all named graphs in the same time and the named graphthe in the resulting inferred knowledge-base stay separate.

I am asking this question because as far as I know that I should transfer the triples in TDB store into a default or named Models to apply reasoning.

Thanks in Advance
Abdul


      From: Dave Reynolds <da...@gmail.com>
 To: users@jena.apache.org 
 Sent: Sunday, 17 April 2016, 9:52
 Subject: Re: Jena Reasoning
   
Hi,

Your email came through too scrambled to read but ...

On 16/04/16 18:26, Abduladem Eljamel wrote:
> Hi,,I am not sure if I am using Jena reasoning and rules correctly. I could not get any results after following some of examples in jena website. This one of the codes which I do not know where is wrong in it:
> OntModel schema = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);

Probably best to make that plain OWL_MEM, at least to begin with 
otherwise you have the OWL reasoner running underneath a generic rule 
reasoner which will complicate your debugging.

> .schema.add(kwakeb, employerOfNAry, rel01);

What are the values of all these variables? Especially employerOfNAry?

You haven't shown us the rest of your code.

> schema.add(rel01, hasRelationValue, hadi);
> String ruleSrc ="[r1: (?org employerOfNAry ?nary) (?nary hasRelationValue ?per) -> (?org employerOf  ?per)] ";List rules = Rule.parseRules(ruleSrc);

This is using "employerOfNAry" as the predicate in the rule, but that's 
not a URI and so is unlikely to match whatever you have put into schema.

Make sure you use consistent URIs in both your data and rules.

Dave



  

Re: Jena Reasoning

Posted by Dave Reynolds <da...@gmail.com>.
Hi,

Your email came through too scrambled to read but ...

On 16/04/16 18:26, Abduladem Eljamel wrote:
> Hi,,I am not sure if I am using Jena reasoning and rules correctly. I could not get any results after following some of examples in jena website. This one of the codes which I do not know where is wrong in it:
> OntModel schema = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);

Probably best to make that plain OWL_MEM, at least to begin with 
otherwise you have the OWL reasoner running underneath a generic rule 
reasoner which will complicate your debugging.

> .schema.add(kwakeb, employerOfNAry, rel01);

What are the values of all these variables? Especially employerOfNAry?

You haven't shown us the rest of your code.

> schema.add(rel01, hasRelationValue, hadi);
> String ruleSrc ="[r1: (?org employerOfNAry ?nary) (?nary hasRelationValue ?per) -> (?org employerOf  ?per)] ";List rules = Rule.parseRules(ruleSrc);

This is using "employerOfNAry" as the predicate in the rule, but that's 
not a URI and so is unlikely to match whatever you have put into schema.

Make sure you use consistent URIs in both your data and rules.

Dave