EquivalentClassReasoning { public boolean reason() { for (OWLClass c : ontology.getClassesInSignature()) { Set<OWLClass> equivalentClasses = reasoner.getEquivalentClasses(c).getEntitiesMinus(c); foundEquivalentAxioms.addAll(this.createEquivalenceAxioms(c, equivalentClasses)); } for (OWLEquivalentClassesAxiom axiom : foundEquivalentAxioms) { if (reasoningTest.fails(axiom)) { failingAxioms.add(axiom); } } return failingAxioms.isEmpty(); } EquivalentClassReasoning(
      OWLOntology ontology, OWLReasoner reasoner, EquivalentClassReasoningMode mode); boolean reason(); void logReport(Logger logger);  }
@Test public void testReasonAllEquivalencesAllowed() throws IOException { OWLOntology inferred = loadOntology("/inferred-equiv.owl"); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(inferred); EquivalentClassReasoning allAllowedReasoning = new EquivalentClassReasoning(inferred, reasoner, EquivalentClassReasoningMode.ALL); assertTrue(allAllowedReasoning.reason()); }
@Test public void testReasonNoEquivalencesAllowed() throws IOException { OWLOntology inferred = loadOntology("/inferred-equiv.owl"); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(inferred); EquivalentClassReasoning noneAllowedReasoning = new EquivalentClassReasoning(inferred, reasoner, EquivalentClassReasoningMode.NONE); assertFalse(noneAllowedReasoning.reason()); }
@Test public void testReasonOnlyAssertedAllowedOnInferred() throws IOException { OWLOntology inferred = loadOntology("/inferred-equiv.owl"); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(inferred); EquivalentClassReasoning assertedOnlyReasoning = new EquivalentClassReasoning( inferred, reasoner, EquivalentClassReasoningMode.ASSERTED_ONLY); assertFalse(assertedOnlyReasoning.reason()); }
@Test public void testReasonOnlyAssertedAllowedOnAsserted() throws IOException { OWLOntology inferred = loadOntology("/asserted-equiv.owl"); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(inferred); EquivalentClassReasoning assertedOnlyReasoning = new EquivalentClassReasoning( inferred, reasoner, EquivalentClassReasoningMode.ASSERTED_ONLY); assertTrue(assertedOnlyReasoning.reason()); }