public static void main(String[] args) { FileManager.get().addLocatorClassLoader(ExampleONT_02.class.getClassLoader()); Model tbox = FileManager.get().loadModel("data/inference/tbox.owl", null, "RDF/XML"); // http://en.wikipedia.org/wiki/Tbox Reasoner reasoner = ReasonerRegistry.getOWLReasoner().bindSchema(tbox.getGraph()); Model abox = FileManager.get().loadModel("data/inference/abox.owl", null, "RDF/XML"); // http://en.wikipedia.org/wiki/Abox InfModel inf = ModelFactory.createInfModel(reasoner, abox); ValidityReport validityReport = inf.validate(); if ( !validityReport.isValid() ) { System.out.println("Inconsistent"); Iterator<Report> iter = validityReport.getReports(); while ( iter.hasNext() ) { Report report = iter.next(); System.out.println(report); } } else { System.out.println("Valid"); } }
/** illustrate validation */ public void test2(String fname) { System.out.println("Testing " + fname); Model data = FileManager.get().loadModel(fname); InfModel infmodel = ModelFactory.createRDFSModel(data); ValidityReport validity = infmodel.validate(); if (validity.isValid()) { System.out.println("OK"); } else { System.out.println("Conflicts"); for (Iterator<Report> i = validity.getReports(); i.hasNext(); ) { ValidityReport.Report report = i.next(); System.out.println(" - " + report); // System.out.println(" - " + i.next()); } } }
/** illustrate validation */ public void test2(String fname) { System.out.println("Testing " + fname); Model data = FileManager.get().loadModel(fname); InfModel infmodel = ModelFactory.createRDFSModel(data); ValidityReport validity = infmodel.validate(); if (validity.isValid()) { System.out.println("OK"); } else { System.out.println("Conflicts"); for (Iterator<Report> i = validity.getReports(); i.hasNext(); ) { ValidityReport.Report report = i.next(); System.out.println(" - " + report); // System.out.println(" - " + i.next()); } } }
public static void usageWithDefaultModel() { System.out.println("Results with plain RDF Model"); System.out.println("----------------------------"); System.out.println(); // ontology that will be used final String ont = "http://protege.cim3.net/file/pub/ontologies/koala/koala.owl#"; final String ns = "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl#"; // create Pellet reasoner final Reasoner reasoner = PelletReasonerFactory.theInstance().create(); // create an empty model final Model emptyModel = ModelFactory.createDefaultModel(); // create an inferencing model using Pellet reasoner final InfModel model = ModelFactory.createInfModel(reasoner, emptyModel); // read the file model.read(ont); // print validation report final ValidityReport report = model.validate(); printIterator(report.getReports(), "Validation Results"); // print superclasses final Resource c = model.getResource(ns + "MaleStudentWith3Daughters"); printIterator(model.listObjectsOfProperty(c, RDFS.subClassOf), "All super classes of " + c.getLocalName()); System.out.println(); }
public static void usageWithDefaultModel() { System.out.println("Results with plain RDF Model"); System.out.println("----------------------------"); System.out.println(); // ontology that will be used final String ont = "http://protege.cim3.net/file/pub/ontologies/koala/koala.owl#"; final String ns = "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl#"; // create Pellet reasoner final Reasoner reasoner = PelletReasonerFactory.theInstance().create(); // create an empty model final Model emptyModel = ModelFactory.createDefaultModel(); // create an inferencing model using Pellet reasoner final InfModel model = ModelFactory.createInfModel(reasoner, emptyModel); // read the file model.read(ont); // print validation report final ValidityReport report = model.validate(); printIterator(report.getReports(), "Validation Results"); // print superclasses final Resource c = model.getResource(ns + "MaleStudentWith3Daughters"); printIterator(model.listObjectsOfProperty(c, RDFS.subClassOf), "All super classes of " + c.getLocalName()); System.out.println(); }
/** * Test change of RDF specs to allow plain literals w/o lang and XSD string to be the same. */ public void testLiteralBug() { Model model = FileManager.get().loadModel("file:testing/reasoners/bugs/dtValidation.owl"); // Model m = ModelFactory.createDefaultModel(); Reasoner r = ReasonerRegistry.getOWLReasoner(); InfModel infmodel = ModelFactory.createInfModel(r, model); ValidityReport validity = infmodel.validate(); assertTrue (validity.isValid()); }
/** * Test change of RDF specs to allow plain literals w/o lang and XSD string to be the same. */ public void testLiteralBug() { Model model = FileManager.get().loadModel("file:testing/reasoners/bugs/dtValidation.owl"); // Model m = ModelFactory.createDefaultModel(); Reasoner r = ReasonerRegistry.getOWLReasoner(); InfModel infmodel = ModelFactory.createInfModel(r, model); ValidityReport validity = infmodel.validate(); assertTrue (validity.isValid()); }
/** * Run a single consistency test on the given data file. */ private boolean doTestOn(String dataFile) { // System.out.println("Test: " + dataFile); Model data = FileManager.get().loadModel(dataFile); InfModel infmodel = ModelFactory.createInfModel(makeReasoner(), data); ValidityReport reportList = infmodel.validate(); /* Debug only if (reportList.isValid()) { System.out.println("No reported problems"); } else { for (Iterator i = reportList.getReports(); i.hasNext(); ) { ValidityReport.Report report = (ValidityReport.Report)i.next(); System.out.println("- " + report); } } */ return reportList.isValid(); } }
private RDFNode doTestLiteralsInErrorReports(String rules) { GenericRuleReasoner reasoner = new GenericRuleReasoner( Rule.parseRules(rules) ); InfModel im = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel()); ValidityReport validity = im.validate(); assertTrue (! validity.isValid()); ValidityReport.Report report = (validity.getReports().next()); assertTrue( report.getExtension() instanceof RDFNode); return (RDFNode)report.getExtension(); }
/** * Run a single consistency test on the given data file. */ private boolean doTestOn(String dataFile) { // System.out.println("Test: " + dataFile); Model data = FileManager.get().loadModel(dataFile); InfModel infmodel = ModelFactory.createInfModel(makeReasoner(), data); ValidityReport reportList = infmodel.validate(); /* Debug only if (reportList.isValid()) { System.out.println("No reported problems"); } else { for (Iterator i = reportList.getReports(); i.hasNext(); ) { ValidityReport.Report report = (ValidityReport.Report)i.next(); System.out.println("- " + report); } } */ return reportList.isValid(); } }
/** * Run the consistency check, returning a ValidityReport. */ public ValidityReport testResults() { Model t = FileManager.get().loadModel(BASE_DIR + tbox); Model a = FileManager.get().loadModel(BASE_DIR + abox); // Work around non-deterministic bug in bindSchema // Reasoner r = rf.create(null).bindSchema(t); Reasoner r = rf.create(null); a.add(t); InfModel im = ModelFactory.createInfModel(r, a); return im.validate(); }
private RDFNode doTestLiteralsInErrorReports(String rules) { GenericRuleReasoner reasoner = new GenericRuleReasoner( Rule.parseRules(rules) ); InfModel im = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel()); ValidityReport validity = im.validate(); assertTrue (! validity.isValid()); ValidityReport.Report report = (validity.getReports().next()); assertTrue( report.getExtension() instanceof RDFNode); return (RDFNode)report.getExtension(); }
/** * Run the consistency check, returning a ValidityReport. */ public ValidityReport testResults() { Model t = FileManager.get().loadModel(BASE_DIR + tbox); Model a = FileManager.get().loadModel(BASE_DIR + abox); // Work around non-deterministic bug in bindSchema // Reasoner r = rf.create(null).bindSchema(t); Reasoner r = rf.create(null); a.add(t); InfModel im = ModelFactory.createInfModel(r, a); return im.validate(); }
/** * Test problem with bindSchema not interacting properly with validation. */ public void testBindSchemaValidate() { Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); Model schema = FileManager.get().loadModel("file:testing/reasoners/bugs/sbug.owl"); Model data = FileManager.get().loadModel("file:testing/reasoners/bugs/sbug.rdf"); // Union version InfModel infu = ModelFactory.createInfModel(reasoner, data.union(schema)); ValidityReport validity = infu.validate(); assertTrue( ! validity.isValid()); // debug print // for (Iterator i = validity.getReports(); i.hasNext(); ) { // System.out.println(" - " + i.next()); // } // bindSchema version InfModel inf = ModelFactory.createInfModel(reasoner.bindSchema(schema), data); validity = inf.validate(); assertTrue( ! validity.isValid()); }
/** * Test problem with bindSchema not interacting properly with validation. */ public void testBindSchemaValidate() { Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); Model schema = FileManager.get().loadModel("file:testing/reasoners/bugs/sbug.owl"); Model data = FileManager.get().loadModel("file:testing/reasoners/bugs/sbug.rdf"); // Union version InfModel infu = ModelFactory.createInfModel(reasoner, data.union(schema)); ValidityReport validity = infu.validate(); assertTrue( ! validity.isValid()); // debug print // for (Iterator i = validity.getReports(); i.hasNext(); ) { // System.out.println(" - " + i.next()); // } // bindSchema version InfModel inf = ModelFactory.createInfModel(reasoner.bindSchema(schema), data); validity = inf.validate(); assertTrue( ! validity.isValid()); }
assertFalse(aBox.validate().isValid()); // fails: why?
assertFalse(aBox.validate().isValid()); // fails: why?