public void explainUnsatisfiableClasses() { for (final OWLClass cls : _reasoner.getEquivalentClasses(OWL.Nothing)) { if (cls.isOWLNothing()) { continue; } explainUnsatisfiableClass(cls); } }
/** * Build the class hierarchy based on the results from the _reasoner */ static public Taxonomy<OWLClass> buildClassHierarchy(final OpenlletReasoner reasoner) { final Taxonomy<OWLClass> taxonomy = new TaxonomyImpl<>(null, OWL.Thing, OWL.Nothing); final Set<OWLClass> things = reasoner.getEquivalentClasses(OWL.Thing).entities().collect(Collectors.toSet()); things.remove(OWL.Thing); if (!things.isEmpty()) taxonomy.addEquivalents(OWL.Thing, things); final Set<OWLClass> nothings = reasoner.getEquivalentClasses(OWL.Nothing).entities().collect(Collectors.toSet()); nothings.remove(OWL.Nothing); if (!nothings.isEmpty()) taxonomy.addEquivalents(OWL.Nothing, nothings); for (final Node<OWLClass> subEq : reasoner.getSubClasses(OWL.Thing, true)) recursiveBuild(taxonomy, subEq, reasoner); return taxonomy; }
/** * Build the class hierarchy based on the results from the _reasoner */ static public Taxonomy<OWLClass> buildClassHierarchy(final OpenlletReasoner reasoner) { final Taxonomy<OWLClass> taxonomy = new TaxonomyImpl<>(null, OWL.Thing, OWL.Nothing); final Set<OWLClass> things = reasoner.getEquivalentClasses(OWL.Thing).entities().collect(Collectors.toSet()); things.remove(OWL.Thing); if (!things.isEmpty()) taxonomy.addEquivalents(OWL.Thing, things); final Set<OWLClass> nothings = reasoner.getEquivalentClasses(OWL.Nothing).entities().collect(Collectors.toSet()); nothings.remove(OWL.Nothing); if (!nothings.isEmpty()) taxonomy.addEquivalents(OWL.Nothing, nothings); for (final Node<OWLClass> subEq : reasoner.getSubClasses(OWL.Thing, true)) recursiveBuild(taxonomy, subEq, reasoner); return taxonomy; }
public void explainClassHierarchy() throws OWLException { final Set<OWLClass> visited = new HashSet<>(); _reasoner.flush(); startTask("Classification"); _reasoner.getKB().classify(); finishTask("Classification"); startTask("Realization"); _reasoner.getKB().realize(); finishTask("Realization"); _monitor = new ConsoleProgressMonitor(); _monitor.setProgressTitle("Explaining"); _monitor.setProgressLength((int) _reasoner.getRootOntology().classesInSignature().count()); _monitor.taskStarted(); final Node<OWLClass> bottoms = _reasoner.getEquivalentClasses(OWL.Nothing); explainClassHierarchy(OWL.Nothing, bottoms, visited); final Node<OWLClass> tops = _reasoner.getEquivalentClasses(OWL.Thing); explainClassHierarchy(OWL.Thing, tops, visited); _monitor.taskFinished(); }
/** * Test for #447 */ @Test public void testGetUnsatClasses() { createReasoner(OWL.disjointClasses(_A, _B), OWL.equivalentClasses(_C, OWL.and(_A, _B))); assertStreamAsSetEquals(Stream.of(_C, OWL.Nothing), _reasoner.getUnsatisfiableClasses().entities()); assertStreamAsSetEquals(Stream.of(_C, OWL.Nothing), _reasoner.getEquivalentClasses(_C).entities()); }
@Test public void testObjectRangeWithEquivalents() { createReasoner(OWL.equivalentClasses(_C, some(inverse(_p), OWL.Thing)), OWL.range(_p, _D), OWL.subClassOf(_C, _E)); _reasoner.getKB().printClassTree(); assertTrue(_reasoner.isEntailed(OWL.range(_p, _C))); assertStreamAsSetEquals(Stream.of(_C), _reasoner.getEquivalentClasses(some(inverse(_p), OWL.Thing)).entities()); assertStreamAsSetEquals(Stream.of(_C), _reasoner.getObjectPropertyRanges(_p, true).entities()); assertStreamAsSetEquals(Stream.of(_C, _D, _E, OWL.Thing), _reasoner.getObjectPropertyRanges(_p, false).entities()); }