On 14/10/16 14:53, javed khan wrote:
I have divided Students into ExcellentStudents and AverageStudents based on
some criteria via Jena rules: if student got 75% or more, he/she will be in
"ExcellentStudents" else "AverageStudents".
In first exam, if some one takes 75% and put into  ExcellentStudents but
next time if he scores less than 75%, he will be AverageStudents.

The problem is that when I store it in the file, the previous value does
not overwrite the new one and I see both categories in the owl file like:
John
 AverageStudents
 ExcellentStudents

How can we cope with this issue?


If in your data there is only ever one exam result for a given student then you it might make sense to have AverageStudents/ExcellentStudent classes. However, if you have multiple exam results in the same data then naturally some will be average on some and excellent on others.

So you have to decide what your semantics are. Do you want ExcellentStudent to mean that the student averages 75% or more across all exams? Or you you want an n-relationship between students, exams and classifications?

Once you've decided what you semantics are and how the answers should look then you can figure out an implementation.

Dave


The rules are:

String rule = "[rule1:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student) "
                + "( ?x http://www.semanticweb.org#score  ?marks )"
                + "greaterThan(?marks, 70) "
                + " ->  (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#ExcellentStudents )]"

+ "[rule2:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student) "
                + "( ?x http://www.semanticweb.org#score  ?marks )"
                + "lessThan(?marks, 70) "
                + " ->  (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#AverageStudents )]";


for (Iterator i = inf.listResourcesWithProperty(RDF.type,stutype1 );
i.hasNext();) {
           inf.listStatements(null,RDF.type, "ExcellentStudents");

        }
     for (Iterator i = inf.listResourcesWithProperty(RDF.type, stutype2);
i.hasNext();) {
             inf.listStatements(null,RDF.type, "AverageStudents");

        }

I also tried with SPARQL but same result.
SELECT  * " +
                " WHERE {   ?x rdf:type std:ExcellentStudents . ?x rdf:type
std:AverageStudents}";


Reply via email to