ReasonOperation { public static void reason(OWLOntology ontology, OWLReasonerFactory reasonerFactory) throws OntologyLogicException, OWLOntologyCreationException, InvalidReferenceException { reason(ontology, reasonerFactory, getDefaultOptions()); }  static Map<String, String> getDefaultOptions(); static void reason(OWLOntology ontology, OWLReasonerFactory reasonerFactory); static void reason(
      OWLOntology ontology, OWLReasonerFactory reasonerFactory, Map<String, String> options); static OWLReasoner getTautologyChecker(boolean structural); static boolean isTautological(
      OWLAxiom axiom, OWLReasoner tautologyChecker, boolean structural); static void removeRedundantSubClassAxioms(OWLReasoner reasoner); static void removeRedundantSubClassAxioms(
      OWLReasoner reasoner, Map<String, String> options);  }
@Test public void testStructural() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertIdentical("/simple_structural.owl", reasoned); }
@Test public void testELK() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertIdentical("/simple_elk.owl", reasoned); }
@Test public void testWhelk() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new WhelkOWLReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertIdentical("/simple_elk.owl", reasoned); }
@Test public void testHermit() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertEquals(6, reasoned.getAxiomCount()); assertIdentical("/simple_hermit.owl", reasoned); }
@Test public void testJFact() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new JFactFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertEquals(6, reasoned.getAxiomCount()); assertIdentical("/simple_jfact.owl", reasoned); }
@Test public void testInferIntoNewOntology() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); Map<String, String> opts = new HashMap<>(); opts.put("create-new-ontology", "true"); opts.put("annotate-inferred-axioms", "true"); ReasonOperation.reason(reasoned, reasonerFactory, opts); assertEquals(2, reasoned.getAxiomCount()); }
@Test public void testInferIntoNewOntologyNonTrivial() throws Exception { OWLOntology reasoned = loadOntology("/relax_equivalence_axioms_test.obo"); OWLReasonerFactory reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); Map<String, String> opts = new HashMap<>(); opts.put("create-new-ontology", "true"); opts.put("annotate-inferred-axioms", "true"); ReasonOperation.reason(reasoned, reasonerFactory, opts); assertEquals(15, reasoned.getAxiomCount()); }
@Test public void testInferIntoNewOntologyNoDupes() throws Exception { OWLOntology reasoned = loadOntology("/relax_equivalence_axioms_test.obo"); OWLReasonerFactory reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); Map<String, String> opts = new HashMap<>(); opts.put("create-new-ontology", "true"); opts.put("annotate-inferred-axioms", "true"); opts.put("exclude-duplicate-axioms", "true"); ReasonOperation.reason(reasoned, reasonerFactory, opts); assertEquals(5, reasoned.getAxiomCount()); }
@Test public void testExcludeTautologies() throws Exception { OWLOntology input = loadOntology("/reason_exclude_tautologies.ofn"); OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); Map<String, String> options = new HashMap<>(); options.put("exclude-tautologies", "structural"); ReasonOperation.reason(input, reasonerFactory, options); assertFalse( EntitySearcher.getSuperClasses( dataFactory.getOWLClass(IRI.create("http: .contains(dataFactory.getOWLThing())); }
@Test public void testEMRBasic() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory coreReasonerFactory = new ElkReasonerFactory(); OWLReasonerFactory reasonerFactory = new ExpressionMaterializingReasonerFactory(coreReasonerFactory); ReasonOperation.reason(reasoned, reasonerFactory); assertIdentical("/simple_elk.owl", reasoned); }
@Test public void testIntersection() throws Exception { OWLOntology reasoned = loadOntology("/intersection.omn"); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertTrue(checkContains(reasoned, "SubClassOf(<http: }
@Test public void testExternal() throws Exception { OWLOntology importOnt1 = loadOntology("/intersection.omn"); IRI oiri = importOnt1.getOntologyID().getOntologyIRI().orNull(); if (oiri == null) { throw new Exception("Ontology 'intersection.omn' does not have an IRI"); } OWLOntology mainOnt = loadOntology("/simple.owl"); OWLOntologyManager mgr = mainOnt.getOWLOntologyManager(); OWLOntology importOnt = mgr.createOntology(oiri); mgr.addAxioms(importOnt, importOnt1.getAxioms()); OWLImportsDeclaration importsDecl = mgr.getOWLDataFactory().getOWLImportsDeclaration(oiri); AddImport ch = new AddImport(mainOnt, importsDecl); mgr.applyChange(ch); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); Map<String, String> opts = new HashMap<>(); opts.put("exclude-external-entities", "true"); ReasonOperation.reason(mainOnt, reasonerFactory, opts); assertFalse(checkContains(mainOnt, "SubClassOf(<http: opts.put("exclude-external-entities", "false"); ReasonOperation.reason(mainOnt, reasonerFactory, opts); assertTrue(checkContains(mainOnt, "SubClassOf(<http: }