Esempio n. 1
0
 public Rule rule(String rule) {
   try {
     final Rule r = parser.parseRule(rule);
     hybridKB.getProgram().add(r);
     return r;
   } catch (final ParseException e) {
     throw new RuntimeException(e);
   }
 }
Esempio n. 2
0
 public void assertNegative(String query) {
   try {
     final NoHRRecursiveDescentParser parser =
         new NoHRRecursiveDescentParser(new DefaultVocabulary(ontology));
     if (!query.endsWith(".")) query += ".";
     final Query q = parser.parseQuery(query);
     for (final Literal l : q.getLiterals()) {
       if (l instanceof NegativeLiteral)
         throw new IllegalArgumentException("literals must be positive");
       if (!l.isGrounded()) throw new IllegalArgumentException("literals must be grounded");
       hybridKB.getProgram().add(Model.rule(l.getAtom()));
     }
     Assert.assertTrue("should have inconsistent answers", hasAnswer(query, false, false, true));
     Assert.assertFalse(
         "shouldn't have non inconsistent answers", hasAnswer(query, true, true, false));
   } catch (final ParseException e) {
     fail(e);
   }
 }
Esempio n. 3
0
 public boolean remove(Rule rule) {
   return hybridKB.getProgram().remove(rule);
 }