This is the code where the first rules works and the second does not.

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#GPA
   ?marks )"
                + "greaterThan(?marks, 2) "
                 + " ->  (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
 http://www.semanticweb.org#GoodStudent
  )]";


 * String rule2 = "[rule2:(?y
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
<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.w3.org/1999/02/22-rdf-syntax-ns#type>*
* http://www.semanticweb.org#WorstStudent
<http://www.semanticweb.org#WorstStudent>*
* )]";*

   "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();

Reply via email to