I am sorry that is just the mistake when I copy code from my IDE to email. In the original code, its written just once.
On Wed, Jul 27, 2016 at 1:11 AM, Lorenz B. < [email protected]> wrote: > I'm not an expert, but why do you have each URI twice in the rule? > > > I have rule body:I want instance x which are in both classes to assign to > > another class "StudentExpert" which have no other instances. But does not > > work. > > (My Owl inverse property and transitive property rule works but this > > generic rule does not work) > > > > String rule = "*[rule1:(?x > > http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type > > <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type> > > http://www.semanticweb.org/141#Student > > <http://www.semanticweb.org/141#Student>) " +* > > * "(?x > > http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type > > <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type> > > http://www.semanticweb.org/141#Expert > > <http://www.semanticweb.org/141#Expert> )" + * > > > > "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type > > http://www.semanticweb.org/141#StudentExpert )]"; > > > > After prefixes, my query is: > > > > "Select * " + "where { ?x rdf:type std:StudentExpert. }"; > > > > My Reasoner and InfModel classes are: > > > > Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule)); > > > > InfModel inf = ModelFactory.createInfModel(reasoner2, model); > > > > Then query is executed as usual in jena. > > > > > > > > > > On Mon, Jul 25, 2016 at 2:38 PM, Dave Reynolds < > [email protected]> > > wrote: > > > >> On 25/07/16 19:33, javed khan wrote: > >> > >>> I have a Student class (Phd students) and Teacher class, having > instances. > >>> There are some students which are also Teacher (teaching to junior > >>> classes). > >>> ?x rdf:type ont:Student ?y rdf:type ont:Teacher --> ? > >>> This will give us Students and teachers instances. > >>> > >>> I want Jena generic rule(Forward chaining) which filters those who are > >>> both > >>> Teachers and Students. Is there any way to do so? > >>> > >> Yes. You are nearly there but you want the rule body to be more like: > >> > >> (?x rdf:type ont:Student) (?x rdf:type ont:Teacher) -> ... > >> > >> the rule consequent could assert a new type or some other property to > >> indicate that ?x is in both classes. > >> > >> Dave > >> > >> > -- > Lorenz Bühmann > AKSW group, University of Leipzig > Group: http://aksw.org - semantic web research center > >
