예제 #1
0
 /** Run a single test of any sort, return true if the test succeeds. */
 public boolean doRunTest(Resource test) throws IOException {
   if (test.hasProperty(RDF.type, OWLTest.PositiveEntailmentTest)
       || test.hasProperty(RDF.type, OWLTest.NegativeEntailmentTest)
       || test.hasProperty(RDF.type, OWLTest.OWLforOWLTest)
       || test.hasProperty(RDF.type, OWLTest.ImportEntailmentTest)
       || test.hasProperty(RDF.type, OWLTest.TrueTest)) {
     // Entailment tests
     boolean processImports = test.hasProperty(RDF.type, OWLTest.ImportEntailmentTest);
     Model premises = getDoc(test, RDFTest.premiseDocument, processImports);
     Model conclusions = getDoc(test, RDFTest.conclusionDocument);
     comprehensionAxioms(premises, conclusions);
     long t1 = System.currentTimeMillis();
     InfGraph graph = reasoner.bind(premises.getGraph());
     if (printProfile) {
       ((FBRuleInfGraph) graph).resetLPProfile(true);
     }
     Model result = ModelFactory.createModelForGraph(graph);
     boolean correct = WGReasonerTester.testConclusions(conclusions.getGraph(), result.getGraph());
     long t2 = System.currentTimeMillis();
     lastTestDuration = t2 - t1;
     if (printProfile) {
       ((FBRuleInfGraph) graph).printLPProfile();
     }
     if (test.hasProperty(RDF.type, OWLTest.NegativeEntailmentTest)) {
       correct = !correct;
     }
     return correct;
   } else if (test.hasProperty(RDF.type, OWLTest.InconsistencyTest)) {
     //            System.out.println("Starting: " + test);
     Model input = getDoc(test, RDFTest.inputDocument);
     long t1 = System.currentTimeMillis();
     InfGraph graph = reasoner.bind(input.getGraph());
     boolean correct = !graph.validate().isValid();
     long t2 = System.currentTimeMillis();
     lastTestDuration = t2 - t1;
     return correct;
   } else if (test.hasProperty(RDF.type, OWLTest.ConsistencyTest)) {
     // Not used normally becase we are not complete enough to prove consistency
     //            System.out.println("Starting: " + test);
     Model input = getDoc(test, RDFTest.inputDocument);
     long t1 = System.currentTimeMillis();
     InfGraph graph = reasoner.bind(input.getGraph());
     boolean correct = graph.validate().isValid();
     long t2 = System.currentTimeMillis();
     lastTestDuration = t2 - t1;
     return correct;
   } else {
     for (StmtIterator i = test.listProperties(RDF.type); i.hasNext(); ) {
       System.out.println("Test type = " + i.nextStatement().getObject());
     }
     throw new ReasonerException("Unknown test type");
   }
 }
예제 #2
0
 /** Run a single test of any sort, performing any appropriate logging and error reporting. */
 public void runTest(Resource test) {
   System.out.println("Running " + test);
   boolean success = false;
   boolean fail = false;
   try {
     success = doRunTest(test);
   } catch (Exception e) {
     fail = true;
     System.out.print("\nException: " + e);
     e.printStackTrace();
   }
   testCount++;
   if (success) {
     System.out.print((testCount % 40 == 0) ? ".\n" : ".");
     System.out.flush();
     passCount++;
   } else {
     System.out.println("\nFAIL: " + test);
   }
   Resource resultType = null;
   if (fail) {
     resultType = OWLResults.FailingRun;
   } else {
     if (test.hasProperty(RDF.type, OWLTest.NegativeEntailmentTest)
         || test.hasProperty(RDF.type, OWLTest.ConsistencyTest)) {
       resultType = success ? OWLResults.PassingRun : OWLResults.FailingRun;
     } else {
       resultType = success ? OWLResults.PassingRun : OWLResults.IncompleteRun;
     }
   }
   // log to the rdf result format
   Resource result =
       testResults
           .createResource()
           .addProperty(RDF.type, OWLResults.TestRun)
           .addProperty(RDF.type, resultType)
           .addProperty(OWLResults.test, test)
           .addProperty(OWLResults.system, jena2);
 }