You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by javed khan <ja...@gmail.com> on 2016/09/06 19:05:47 UTC

Jena rules to assign individuals to subclasses

I have *Student* class, having *ExcellentStudents* and *PoorStudents* as
subclasses.
My ontology contains Student *marks* (*marks is data property*) and based
on marks students can be assigned to ExcellentStudents and PoorStudents.

My requirements is to achieve it using Jena rules. I need some help in
getting to this.  I want something like :

If Student X marks>60, assign Student X to ExcellentStudent class else
assign to PoorStudents class. I have attempted the following but could not
succeeded.


String rule = "[rule1:"(?x
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.owlontologies.com/Student.owl#*Student*)+

 (?x http://www.owl-ontologies.com/Student.owl#marks  *>60*)" +


         "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.owlontologies.com/Student.owl#*ExcellentStudent*)]";


I think the problem will be in marks>60 because I do not know how to
compare things inside Jena rules.

Re: Jena rules to assign individuals to subclasses

Posted by javed khan <ja...@gmail.com>.
Thanks Soroka for your help.

On Tue, Sep 6, 2016 at 12:46 PM, A. Soroka <aj...@virginia.edu> wrote:

> [ exstu: (?stu rdf:type Student), (?stu marks ?m), greaterThan(?m, 60) ->
> (?stu rdf:type ExcellentStudents) ]
>
> is one way to do this. Please look at the examples on that same page.
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Sep 6, 2016, at 3:30 PM, javed khan <ja...@gmail.com> wrote:
> >
> > Thanks Soroka.
> >
> > I do not know how to use* greaterThan(?x, ?y) here in my case? How can I
> > compare the marks data property with this?*
> >
> > On Tue, Sep 6, 2016 at 12:09 PM, A. Soroka <aj...@virginia.edu> wrote:
> >
> >> https://jena.apache.org/documentation/inference/index.html#RULEbuiltins
> >>
> >> ---
> >> A. Soroka
> >> The University of Virginia Library
> >>
> >>> On Sep 6, 2016, at 3:05 PM, javed khan <ja...@gmail.com> wrote:
> >>>
> >>> I have *Student* class, having *ExcellentStudents* and *PoorStudents*
> as
> >>> subclasses.
> >>> My ontology contains Student *marks* (*marks is data property*) and
> based
> >>> on marks students can be assigned to ExcellentStudents and
> PoorStudents.
> >>>
> >>> My requirements is to achieve it using Jena rules. I need some help in
> >>> getting to this.  I want something like :
> >>>
> >>> If Student X marks>60, assign Student X to ExcellentStudent class else
> >>> assign to PoorStudents class. I have attempted the following but could
> >> not
> >>> succeeded.
> >>>
> >>>
> >>> String rule = "[rule1:"(?x
> >>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> >>> http://www.owlontologies.com/Student.owl#*Student*)+
> >>>
> >>> (?x http://www.owl-ontologies.com/Student.owl#marks  *>60*)" +
> >>>
> >>>
> >>>        "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> >>> http://www.owlontologies.com/Student.owl#*ExcellentStudent*)]";
> >>>
> >>>
> >>> I think the problem will be in marks>60 because I do not know how to
> >>> compare things inside Jena rules.
> >>
> >>
>
>

Re: Jena rules to assign individuals to subclasses

Posted by "A. Soroka" <aj...@virginia.edu>.
[ exstu: (?stu rdf:type Student), (?stu marks ?m), greaterThan(?m, 60) -> (?stu rdf:type ExcellentStudents) ]

is one way to do this. Please look at the examples on that same page.

---
A. Soroka
The University of Virginia Library

> On Sep 6, 2016, at 3:30 PM, javed khan <ja...@gmail.com> wrote:
> 
> Thanks Soroka.
> 
> I do not know how to use* greaterThan(?x, ?y) here in my case? How can I
> compare the marks data property with this?*
> 
> On Tue, Sep 6, 2016 at 12:09 PM, A. Soroka <aj...@virginia.edu> wrote:
> 
>> https://jena.apache.org/documentation/inference/index.html#RULEbuiltins
>> 
>> ---
>> A. Soroka
>> The University of Virginia Library
>> 
>>> On Sep 6, 2016, at 3:05 PM, javed khan <ja...@gmail.com> wrote:
>>> 
>>> I have *Student* class, having *ExcellentStudents* and *PoorStudents* as
>>> subclasses.
>>> My ontology contains Student *marks* (*marks is data property*) and based
>>> on marks students can be assigned to ExcellentStudents and PoorStudents.
>>> 
>>> My requirements is to achieve it using Jena rules. I need some help in
>>> getting to this.  I want something like :
>>> 
>>> If Student X marks>60, assign Student X to ExcellentStudent class else
>>> assign to PoorStudents class. I have attempted the following but could
>> not
>>> succeeded.
>>> 
>>> 
>>> String rule = "[rule1:"(?x
>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>> http://www.owlontologies.com/Student.owl#*Student*)+
>>> 
>>> (?x http://www.owl-ontologies.com/Student.owl#marks  *>60*)" +
>>> 
>>> 
>>>        "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>> http://www.owlontologies.com/Student.owl#*ExcellentStudent*)]";
>>> 
>>> 
>>> I think the problem will be in marks>60 because I do not know how to
>>> compare things inside Jena rules.
>> 
>> 


Re: Jena rules to assign individuals to subclasses

Posted by javed khan <ja...@gmail.com>.
Thanks Soroka.

I do not know how to use* greaterThan(?x, ?y) here in my case? How can I
compare the marks data property with this?*

On Tue, Sep 6, 2016 at 12:09 PM, A. Soroka <aj...@virginia.edu> wrote:

> https://jena.apache.org/documentation/inference/index.html#RULEbuiltins
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Sep 6, 2016, at 3:05 PM, javed khan <ja...@gmail.com> wrote:
> >
> > I have *Student* class, having *ExcellentStudents* and *PoorStudents* as
> > subclasses.
> > My ontology contains Student *marks* (*marks is data property*) and based
> > on marks students can be assigned to ExcellentStudents and PoorStudents.
> >
> > My requirements is to achieve it using Jena rules. I need some help in
> > getting to this.  I want something like :
> >
> > If Student X marks>60, assign Student X to ExcellentStudent class else
> > assign to PoorStudents class. I have attempted the following but could
> not
> > succeeded.
> >
> >
> > String rule = "[rule1:"(?x
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> > http://www.owlontologies.com/Student.owl#*Student*)+
> >
> > (?x http://www.owl-ontologies.com/Student.owl#marks  *>60*)" +
> >
> >
> >         "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> > http://www.owlontologies.com/Student.owl#*ExcellentStudent*)]";
> >
> >
> > I think the problem will be in marks>60 because I do not know how to
> > compare things inside Jena rules.
>
>

Re: Jena rules to assign individuals to subclasses

Posted by "A. Soroka" <aj...@virginia.edu>.
https://jena.apache.org/documentation/inference/index.html#RULEbuiltins

---
A. Soroka
The University of Virginia Library

> On Sep 6, 2016, at 3:05 PM, javed khan <ja...@gmail.com> wrote:
> 
> I have *Student* class, having *ExcellentStudents* and *PoorStudents* as
> subclasses.
> My ontology contains Student *marks* (*marks is data property*) and based
> on marks students can be assigned to ExcellentStudents and PoorStudents.
> 
> My requirements is to achieve it using Jena rules. I need some help in
> getting to this.  I want something like :
> 
> If Student X marks>60, assign Student X to ExcellentStudent class else
> assign to PoorStudents class. I have attempted the following but could not
> succeeded.
> 
> 
> String rule = "[rule1:"(?x
> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> http://www.owlontologies.com/Student.owl#*Student*)+
> 
> (?x http://www.owl-ontologies.com/Student.owl#marks  *>60*)" +
> 
> 
>         "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> http://www.owlontologies.com/Student.owl#*ExcellentStudent*)]";
> 
> 
> I think the problem will be in marks>60 because I do not know how to
> compare things inside Jena rules.