/** * Returns all the (named) subclasses of class c. The class c itself is not included in the list but all the other classes that are equivalent to c are put * into the list. Also note that the returned list will always have at least one element, that is the BOTTOM concept. By definition BOTTOM concept is * subclass of every concept. This function is equivalent to calling getSubClasses(c, true). * <p> * *** This function will first classify the whole ontology *** * </p> * * @param c class whose subclasses are returned * @return A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects. */ public default Set<Set<ATermAppl>> getSubClasses(final ATermAppl c) { return getSubClasses(c, false); }
/** * Returns all the (named) subclasses of class c. The class c itself is not included in the list but all the other classes that are equivalent to c are put * into the list. Also note that the returned list will always have at least one element, that is the BOTTOM concept. By definition BOTTOM concept is * subclass of every concept. This function is equivalent to calling getSubClasses(c, true). * <p> * *** This function will first classify the whole ontology *** * </p> * * @param c class whose subclasses are returned * @return A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects. */ public default Set<Set<ATermAppl>> getSubClasses(final ATermAppl c) { return getSubClasses(c, false); }
private Set<ATermAppl> getDistinctSubclasses(final KnowledgeBase kb, final ATermAppl c) { final Set<ATermAppl> filteredClasses = new HashSet<>(); final Set<Set<ATermAppl>> subclasses = kb.getSubClasses(c); for (final Set<ATermAppl> s : subclasses) filteredClasses.addAll(s); filteredClasses.add(c); //Remove not(TOP), since taxonomy builder complains otherwise... filteredClasses.remove(ATermUtils.negate(ATermUtils.TOP)); return filteredClasses; }
@Override public final ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectSetFiller(kb.getSubClasses(openllet.getLoader().node2term(o), true), p, o); } });
@Override public final ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectSetFiller(kb.getSubClasses(openllet.getLoader().node2term(o)), p, o); } });
@Override public final ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectSetFiller(kb.getSubClasses(openllet.getLoader().node2term(o), true), p, o); } });
@Override public final ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectSetFiller(kb.getSubClasses(openllet.getLoader().node2term(o)), p, o); } });
@Override public final ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectSetFiller(kb.getSubClasses(openllet.getLoader().node2term(o), true), p, o); } });
@Override public final ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectSetFiller(kb.getSubClasses(openllet.getLoader().node2term(o)), p, o); } });
@Override public NodeSet<OWLClass> getSubClasses(final OWLClassExpression ce, final boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { refreshCheck(); try { return toClassNodeSet(_kb.getSubClasses(term(ce), direct)); } catch (final PelletRuntimeException e) { throw convert(e); } }
@Override public NodeSet<OWLClass> getSubClasses(final OWLClassExpression ce, final boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { refreshCheck(); try { return toClassNodeSet(_kb.getSubClasses(term(ce), direct)); } catch (final PelletRuntimeException e) { throw convert(e); } }
@Override public NodeSet<OWLClass> getSubClasses(final OWLClassExpression ce, final boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { refreshCheck(); try { return toClassNodeSet(_kb.getSubClasses(term(ce), direct)); } catch (final PelletRuntimeException e) { throw convert(e); } }
@Test public void testGetSubClassBehavior() { classes(_c, _d, _e); _kb.addEquivalentClass(_c, _d); _kb.addSubClass(_e, _d); final Set<Set<ATermAppl>> result = new HashSet<>(); result.add(Collections.singleton(ATermUtils.BOTTOM)); result.add(Collections.singleton(_e)); assertEquals(result, _kb.getSubClasses(_c, false)); }
return kb.isSubClassOf(arguments.get(0), arguments.get(1)); case DirectSubClassOf: for (final Set<ATermAppl> a : kb.getSubClasses(arguments.get(1), true)) if (a.contains(arguments.get(0))) return true;
final Set<ATermAppl> subs = SetUtils.union(kb.getSubClasses(c, true));
final Set<ATermAppl> subs = SetUtils.union(kb.getSubClasses(c, true));
candidates = flatten(_kb.getSubClasses(top, true));
candidates = flatten(_kb.getSubClasses(top, true));
candidates = flatten(_kb.getSubClasses(top, true));
@Test public void testUndefinedTerms() { // This test case is to test the retrieval of equivalences // for undefined classes/properties (see ticket 90) final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl C = term("C"); kb.addClass(C); final ATermAppl p = term("p"); kb.addObjectProperty(p); final ATermAppl undef = term("undef"); assertEquals(Collections.singleton(p), kb.getAllEquivalentProperties(p)); assertEquals(Collections.emptySet(), kb.getEquivalentProperties(p)); assertEquals(Collections.singleton(Collections.singleton(TermFactory.BOTTOM_OBJECT_PROPERTY)), kb.getSubProperties(p)); assertEquals(Collections.singleton(Collections.singleton(TermFactory.TOP_OBJECT_PROPERTY)), kb.getSuperProperties(p)); assertEquals(Collections.singleton(C), kb.getAllEquivalentClasses(C)); assertEquals(Collections.emptySet(), kb.getEquivalentClasses(C)); assertEquals(Collections.emptySet(), kb.getSubClasses(p)); assertEquals(Collections.emptySet(), kb.getSuperClasses(p)); assertEquals(Collections.emptySet(), kb.getAllEquivalentProperties(undef)); assertEquals(Collections.emptySet(), kb.getEquivalentProperties(undef)); assertEquals(Collections.emptySet(), kb.getSubProperties(undef)); assertEquals(Collections.emptySet(), kb.getSuperProperties(undef)); assertEquals(Collections.emptySet(), kb.getAllEquivalentClasses(undef)); assertEquals(Collections.emptySet(), kb.getEquivalentClasses(undef)); assertEquals(Collections.emptySet(), kb.getSubClasses(undef)); assertEquals(Collections.emptySet(), kb.getSuperClasses(undef)); }