Hello All, I have a problem, very same to Neha. I was waiting some answer
will come and I will get help but I think it did not solve.
I have quiz game for three categories(subjects) Physics, Chemistry and
Geography. User have to select one category and questions of that category
will come. When user select a category Physics, for instance, 1 will be
saved in a property Physics_Preferred_Category. When user select second
time Physics when login to the system, 2 will be saved.
I have designed a rule, shown below, to see which category user has
selected most of the time and will consider that BestCategory for that
user. The problem which I have currently is it saved the BestCategory
property not in the data property assertion but in the Annotations.
I have tried to include possible code but not ontology. If it is allowed I
will paste the screen shot of my properties.
OntModel model=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
InputStream in =FileManager.get().open("F://final.owl");
if (in==null) {
throw new IllegalArgumentException( "File: " + " not
found");
} model.read(in,"");
String ns="http://www.semanticweb.org
/t/ontologies/2016/7/myOWL#";
OntClass dil = model.getOntClass(ns + "DiligentUser");
OntClass avgr = model.getOntClass(ns + "AverageUser");
OntProperty bestcat=model.getOntProperty(ns+ "BestCategory");
Individual indiv = user1.createIndividual(ns + name); //name comes from a
text field
//Then rule
String rule ="[rule1: ( ?x http://www.semanticweb.org/t/
ontologies/2016/7/myOWL#Physics_Preferred_Category ?cat1 )" +
"( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_
Preferred_Category ?cat2 )" +
// "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Geo_
Preferred_Category ?cat3 )" +
// "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
+ " -> (?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#
BestCategory http://www.semanticweb.org/t/ontologies/2016/7/myOWL#
BestCategory#Physics )]";
//in ?cat1, ?cat2 ?cat3 there will be numbers like 1 2 3
Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule));
InfModel infModel = ModelFactory.createInfModel(reasoner2, model);
infModel.listStatements(null,bestcat,(RDFNode)null);
}