On 25/11/16 13:54, tina sani wrote:
I have something like this after my Jena forward chain rules and SPARQL
query:

 Reasoner reasoner1 = new GenericRuleReasoner(Rule.parseRules(rule));
        InfModel inf = ModelFactory.createInfModel(reasoner1, model);

Reasoner reasoner2 = ReasonerRegistry.getRDFSReasoner();

InfModel inf2 = ModelFactory.createRDFSModel(model);

If you want your rules to see the results of the RDFS closure then you need something more like:

    InfModel inf = ModelFactory.createRDFSModel(model);
    Reasoner reasoner1 = new GenericRuleReasoner(Rule.parseRules(rule));
    InfModel inf2 = ModelFactory.createInfModel(reasoner1, inf);

Dave

On Fri, Nov 25, 2016 at 4:46 PM, tina sani <tinamadri...@gmail.com> wrote:

So all I should so is to create rdfs model:

InfModel inf2 = ModelFactory.createRDFSModel();

What would be the arguments of the ModelFactory.createRDFSModel(). I have two 
models here, one the simple non inference model and other the inference model : 
InfModel inf = ModelFactory.createInfModel(reasoner, model);




On Fri, Nov 25, 2016 at 3:59 PM, Lorenz B. <buehm...@informatik.uni-
leipzig.de> wrote:



Yes I use GenericRuleReasoner, so using the following rules along with
my
own rules will solve the problem?

?x rdfs:subClassOf emp:ContractEmployee--> ?x rdfs:subClassOf
emp:Employee
?x rdfs:subClassOf emp:PermanantEmployee--> ?x rdfs:subClassOf
emp:Employee
That might be incomplete as rdfs:subClassOf is transitive. Simply use
the RDFS reasoning.

On Thu, Nov 24, 2016 at 11:39 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

 If I pass OntModelSpec.OWL_MEM_MICRO_RULE_INF” to the OntModel, will
it do
the RDFS reasoning?
See [1] in general and in particular [2] which shows how to setup an
RDFS reasoner

InfModel inf = ModelFactory.createRDFSModel(rdfsExample);

or

Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
InfModel inf = ModelFactory.createInfModel(reasoner, rdfsExample);

[1] https://jena.apache.org/documentation/inference/ [2]
https://jena.apache.org/documentation/inference/#generalExamples
b) adding the particular rules to your set of rules
 I have already created the rules, mentioned in my first email. You
means
rules other than that?
I don't know how you setup your rules, but if you use the
GenericRuleReasoner it does only apply your rules and you would have to
add the rules that do the rdfs:subClass/rdf:type inference.
On Wed, Nov 23, 2016 at 11:50 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

Dave meant that you need an additional layer of reasoning like RDFS
or
even less to get the inferences that you describe.
This can be done by

a) nesting two InfModels one that works on your specific rules and
one
that uses some kind of RDFS or
b) adding the particular rules to your set of rules

Ok sorry Dave, actually I did not completely understand your answer.

"You could have an inference model with the appropriate
configuration
to
deduce membership of employee"

Yes I have the inference model:
 Reasoner reasoner = new GenericRuleReasoner(Rule.parse
Rules(rule));
        InfModel infer = ModelFactory.createInfModel(reasoner,
model);

            Query query = QueryFactory.create(queryString);

     QueryExecution qe = QueryExecutionFactory.create(query,
infer);

What additionally I have to do apart from my Jena rule (Forward
Chain)
mentioned in previous email and the inference model.

And of course, I will have a SPARQL query :
Select *
where{ ?x rdf:type emp:QualifiedEmployee }

On Tue, Nov 22, 2016 at 6:03 PM, Dave Reynolds <
dave.e.reyno...@gmail.com>
wrote:

On 22/11/16 14:56, tina sani wrote:

Let me explain a bit.

String rule = "[rule1:(?x http://www.w3.org/1999/02/22-
rdf-syntax-ns#type
http://www.semanticweb.org#Employee) "
                + "( ?x http://www.semanticweb.org#Salary
?salary
)"
                + "greaterThan(?salary, 10,00) "
                + " ->  (?x http://www.w3.org/1999/02/22-r
df-syntax-ns#type
http://www.semanticweb.org#QualifiedEmployee. )]"


Classes in my ontology are

Employee (Super class of all employees)
   * ContractEmployee*  (Subclass of Employee)
           FinanceManager
            ITManager          (Subclasses of ContractEmployee)
   * PermanantEmployee   *(Subclass of Employee)
            Analyst
            Programmer

In this case, will I use ?x rdf:type Employee  or  ?x rdf:type
 ContractEmployee
All the instances are either from subclasses  * FinanceManager ,
ITManager
or Analyst, Programmer*

*Is it must that if I use ?x rdf:type Employee, then
FinanceManager &
ITManager should also be sub classes of general super class
"Employee"
?*
I don't think any of these details change my earlier answer, quoted
below.
Dave


On Tue, Nov 22, 2016 at 5:30 PM, Dave Reynolds <
dave.e.reyno...@gmail.com>
wrote:

On 22/11/16 10:12, tina sani wrote:
Inline image 1
The mail list doesn't support attachments so the image didn't
come
through.

However, I'm guessing it included a class Employee with
sub-classes
ContractEmployee and PermanantEmployee.

I have this ontology: Now if I want to use some rules like

if x rdf:type Employee and ?x salary>Euro10,000. then ?x
QualifiedEmployee.

My question here is should I use ?x rdf:type Employee or ?x
rdf:type
ContractEmployee or PermanantEmployee


Depends on your set up.

You could have an inference model with the appropriate
configuration
to
deduce membership of employee and then query that with SPARQL or
with
a
second inference model with your own rules in.

If you want just one layer of rules and want to combine OWL/RDFS
with
your
custom rules then that's possible (so long as you set all the
appropriate
flags, see documentation) but make sure that your own rules are
backward
not forward rules. [The default Jena rule sets for RDFS and OWL
are
hybrid
rules so some of the inferences are only available to backward
rules
in
the
same rule set.]

Or if you don't want the cost of full inference then you can
indeed
rewrite the "natural" query to explicitly check for the base
memberships.
Dave


--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center


--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center





Reply via email to