The first rule here works and save the individual as GoodStudent when marks is greater than 2 but not assign individual to WorstStudent when marks are less than 2? Where I am doing mistake here ?
String rule = "[rule1:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.semanticweb.org#Student <http://www.semanticweb.org/#Student>) " + "( ?x http://www.semanticweb.org#GPA <http://www.semanticweb.org/#GPA> ?marks )" + "greaterThan(?marks, 2) " + " -> (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.semanticweb.org#GoodStudent <http://www.semanticweb.org/#GoodStudent> )]"; String rule = "[rule2:(?y http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.semanticweb.org#Student <http://www.semanticweb.org/#Student>) " + "( ?y http://www.semanticweb.org#GPA <http://www.semanticweb.org/#GPA> ?marks )" + "lessThan(?marks, 2) " + " -> (?y http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.semanticweb.org#WorstStudent <http://www.semanticweb.org/#GoodStudent> )]"; "SELECT * " + " WHERE { ?x rdf:type std:GoodStudent . ?y rdf:type std:WorstStudent }"; Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule)); InfModel inf = ModelFactory.createInfModel(reasoner2, model); Query query = QueryFactory.create(queryString); QueryExecution qe = QueryExecutionFactory.create(query, inf); ResultSet results = qe.execSelect(); ResultSetFormatter.out(System.out, results, query); qe.close(); try (FileOutputStream writer = new FileOutputStream("D://std.owl")) { inf.write(writer, "RDF/XML"); } catch (IOException ex) { Logger.getLogger(myframe.class.getName()).log(Level.SEVERE, null, ex); }
