예제 #1
0
파일: KB.java 프로젝트: NoHRReasoner/NoHR
 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);
   }
 }
예제 #2
0
파일: KB.java 프로젝트: NoHRReasoner/NoHR
 public void clear() {
   if (clear) return;
   concepts.clear();
   roles.clear();
   dataRoles.clear();
   individuals.clear();
   hybridKB.dispose();
   ontologyManager.removeOntology(ontology);
   setup();
   clear = true;
 }
예제 #3
0
파일: KB.java 프로젝트: NoHRReasoner/NoHR
  private void setup() {
    try {
      ontology = ontologyManager.createOntology(IRI.generateDocumentIRI());
      hybridKB = new NoHRHybridKB(new File(System.getenv("XSB_BIN_DIRECTORY")), ontology, profile);
      parser = new NoHRRecursiveDescentParser(hybridKB.getVocabulary());
    } catch (final IPException e) {

      throw new RuntimeException(e);
    } catch (final OWLOntologyCreationException e) {

      throw new RuntimeException(e);
    } catch (final UnsupportedAxiomsException e) {

      throw new RuntimeException(e);
    } catch (final PrologEngineCreationException e) {
      throw new RuntimeException(e);
    }
  }
예제 #4
0
파일: KB.java 프로젝트: NoHRReasoner/NoHR
 private boolean hasAnswer(
     String query, boolean trueAnswers, boolean undefinedAnswers, boolean inconsistentAnswers) {
   try {
     final Query q = parser.parseQuery(query);
     return hybridKB.hasAnswer(q, trueAnswers, undefinedAnswers, inconsistentAnswers);
   } catch (final OWLProfilesViolationsException e) {
     Assert.fail(e.getMessage());
     return false;
   } catch (final UnsupportedAxiomsException e) {
     Assert.fail(e.getMessage());
     return false;
   } catch (final ParseException e) {
     Assert.fail(e.getMessage());
     return false;
   } catch (final IllegalArgumentException e) {
     Assert.fail(e.getMessage());
     return false;
   }
 }
예제 #5
0
파일: KB.java 프로젝트: NoHRReasoner/NoHR
 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);
   }
 }
예제 #6
0
파일: KB.java 프로젝트: NoHRReasoner/NoHR
 public boolean remove(Rule rule) {
   return hybridKB.getProgram().remove(rule);
 }
예제 #7
0
파일: KB.java 프로젝트: NoHRReasoner/NoHR
 public QLOntologyNormalization getQLNormalizedOntology() throws UnsupportedAxiomsException {
   return new StaticQLOntologyNormalization(ontology, hybridKB.getVocabulary());
 }