Thanks Dave and Lorenz for your time, I finally fixed it.

I passed "model" as second orgument to QueryExecutionFactory , which should
be InfModel rather..

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

regards

On Wed, Jul 27, 2016 at 2:10 AM, Dave Reynolds <dave.e.reyno...@gmail.com>
wrote:

> On 27/07/16 09:54, javed khan wrote:
>
>> Sorry but still not working.
>>
>> When I query instances of Expert, it shows "Tim" which is fine. When I
>> query instance of Student, it shows "Khan", which is also fine.
>> Even when I query both in one, it shows "Khan" which is also ok because
>> Khan is also Expert and Student, but when I try to assign it(Khan) to
>> another class, it does not work.
>>
>
> That's too imprecise to comment on.
>
> If you can show exactly your data and your rules then we might be able to
> spot the problem.
>
> I am afraid if Jena generic rules does not work on classes and only it
>> supports properties like transitive property and inverse property.
>>
>
> Generic rules just work in terms of triples. They can be used on instances
> or classes equally well. You just need to be clear on what you rules need
> to do and write the patterns accordingly.
>
> Dave
>
>
>
> On Wed, Jul 27, 2016 at 1:39 AM, javed khan <javedbtk...@gmail.com> wrote:
>>
>>   <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>>>
>>> are wrong. Either use the correct URI:
>>>
>>>     <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
>>>
>>> or use the prefix form:
>>>
>>>     rdf:type
>>>
>>>
>>> I am sorry due to too many threads, I did not read this reply.
>>>
>>> Thanks Dave, let me try.
>>>
>>> On Wed, Jul 27, 2016 at 1:35 AM, Dave Reynolds <
>>> dave.e.reyno...@gmail.com>
>>> wrote:
>>>
>>> See my earlier reply, you had an error in the URLs in your rules.
>>>>
>>>> Dave
>>>>
>>>>
>>>> On 27/07/16 09:33, javed khan wrote:
>>>>
>>>> If my email (code) is not understandable, I am just explaining in plain
>>>>> text.
>>>>>
>>>>> I have class Expert which have some researches i-e "Tim hasResearch
>>>>> Ontologies". I have another class Student (subclasses Master Phd). Khan
>>>>> is
>>>>> instance of Phd class (ultimately of Student class also). Phd student
>>>>> can
>>>>> also have some researches as Expert class and have type both : Student
>>>>> and
>>>>> Expert in Protege.
>>>>>
>>>>> I want instances which are both in Student and Expert i-e Khan in this
>>>>> case.
>>>>>
>>>>> If ?x rdf:type std:Expert and ?x rdf:type std:Student -> ?x rdf:type
>>>>> std:StudentExpert (a new class in the ontology).
>>>>>
>>>>> my query is : select * where { ?x rdf:type std:StudentExpert}
>>>>>
>>>>> On Wed, Jul 27, 2016 at 1:20 AM, javed khan <javedbtk...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> 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. <
>>>>>> buehm...@informatik.uni-leipzig.de> 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 <
>>>>>>>>
>>>>>>>> dave.e.reyno...@gmail.com>
>>>>>>>
>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>
>>

Reply via email to