/** * Interprets this expression as a conjunction and returns the conjuncts. This method does not * normalise the expression (full CNF is not computed). * * @return The conjucts of this expression if it is a conjunction (object intersection of), or * otherwise a singleton set containing this expression. Note that nested conjunctions * will be flattened, for example, calling this method on (A and B) and C will return * the set {A, B, C} */ default Stream<OWLClassExpression> conjunctSet() { return asConjunctSet().stream().sorted(); }
/** * Interprets this expression as a conjunction and returns the conjuncts. This method does not * normalise the expression (full CNF is not computed). * * @return The conjucts of this expression if it is a conjunction (object intersection of), or * otherwise a singleton set containing this expression. Note that nested conjunctions * will be flattened, for example, calling this method on (A and B) and C will return * the set {A, B, C} */ default Stream<OWLClassExpression> conjunctSet() { return asConjunctSet().stream().sorted(); }
/** * Interprets this expression as a conjunction and returns the conjuncts. This method does not * normalise the expression (full CNF is not computed). * * @return The conjucts of this expression if it is a conjunction (object intersection of), or * otherwise a singleton set containing this expression. Note that nested conjunctions * will be flattened, for example, calling this method on (A and B) and C will return * the set {A, B, C} */ default Stream<OWLClassExpression> conjunctSet() { return asConjunctSet().stream().sorted(); }
public Set<OWLClassExpression> asConjunctSet() { Set<OWLClassExpression> conjuncts = new HashSet<OWLClassExpression>(); for (OWLClassExpression op : getOperands()) { conjuncts.addAll(op.asConjunctSet()); } return conjuncts; }
@Override public Set<OWLClassExpression> asConjunctSet() { Set<OWLClassExpression> conjuncts = new HashSet<>(); for (OWLClassExpression op : getOperands()) { conjuncts.addAll(op.asConjunctSet()); } return conjuncts; }
@Override public Set<OWLClassExpression> asConjunctSet() { Set<OWLClassExpression> conjuncts = new HashSet<OWLClassExpression>(); for (OWLClassExpression op : getOperands()) { conjuncts.addAll(op.asConjunctSet()); } return conjuncts; }
@Override public Set<OWLClassExpression> asConjunctSet() { Set<OWLClassExpression> conjuncts = new HashSet<>(); for (OWLClassExpression op : getOperands()) { conjuncts.addAll(op.asConjunctSet()); } return conjuncts; }
private boolean isPlacedByEquivalentClassesAxiom(@Nonnull OWLClass subClass, @Nonnull OWLClass superClass) { return ontologyStream(rootOntology, Imports.INCLUDED) .flatMap(o -> o.getEquivalentClassesAxioms(subClass).stream()) .flatMap(ax -> ax.getClassExpressions().stream()) .flatMap(ce -> ce.asConjunctSet().stream()) .anyMatch(ce -> ce.equals(superClass)); }
private void createEdgeForSubClassOfAxiom(OWLClass subCls, OWLSubClassOfAxiom subClassOfAxiom, Set<Edge> edges, Set<OWLEntity> processed) { OWLEntityData subClsData = renderer.getClassData(subCls); subClassOfAxiom .getSuperClass() .asConjunctSet() .stream() .filter(ClassExpression::isNotOwlThing) .forEach(superClass -> addEdgeForSuperClass(edges, processed, subClsData, superClass)); }
@Nonnull @Override public Set<PropertyValue> visit(OWLEquivalentClassesAxiom axiom) { if (!subject.isOWLClass()) { return Collections.emptySet(); } Set<PropertyValue> result = new HashSet<>(); if (axiom.contains(subject.asOWLClass())) { for (OWLClassExpression ce : axiom.getClassExpressions()) { if (!ce.equals(subject)) { for (OWLClassExpression conj : ce.asConjunctSet()) { Set<PropertyValue> vals = conj.accept(new ClassExpressionTranslator(State.DERIVED)); if (vals != null) { result.addAll(vals); } } } } } return result; }
@Override public void visit(OWLSubClassOfAxiom axiom) { if (subClassOfEntailment != null) { Set<OWLClassExpression> superConjuncts = axiom.getSuperClass().asConjunctSet(); Set<OWLClassExpression> subDisjuncts = axiom.getSubClass().asDisjunctSet(); if (superConjuncts.contains(axiom.getSuperClass()) && subDisjuncts.contains(axiom.getSubClass())) { addExplanation(axiom); } } }
public void visit(OWLSubClassOfAxiom axiom) { if (axiom.getSubClass().isAnonymous()) { // Not in our results because we only want to return class names return; } // Example: // If searching for subs of B, candidates are: // SubClassOf(A B) // SubClassOf(A And(B ...)) if (checker.containsConjunct(currentParentClass, axiom.getSuperClass())) { results.add(axiom.getSubClass().asOWLClass()); } else if (!relationships.isEmpty()) { // SubClassOf(A ObjectSomeValuesFrom(p B)) axiom.getSuperClass().asConjunctSet().stream() .filter(ce -> ce instanceof OWLObjectSomeValuesFrom) .map(ce -> ((OWLObjectSomeValuesFrom) ce)) .filter(svf -> !svf.getProperty().isAnonymous()) .filter(svf -> svf.getFiller().equals(currentParentClass)) .filter(svf -> relationships.contains(svf.getProperty().asOWLObjectProperty())) .findFirst().ifPresent(c -> { OWLClass child = axiom.getSubClass().asOWLClass(); results.add(child); child2RelationshipMap.put(child, c.getProperty()); }); } }
@Override public Collection<OWLClass> getChildren(OWLClass parent) { Collection<OWLClass> result = new HashSet<>(); for (OWLAxiom ax : asUnorderedSet( getRootOntology().referencingAxioms(parent, INCLUDED))) { if (ax instanceof OWLSubClassOfAxiom) { OWLSubClassOfAxiom sca = (OWLSubClassOfAxiom) ax; if (!sca.getSubClass().isAnonymous()) { Set<OWLClassExpression> conjuncts = sca.getSuperClass().asConjunctSet(); if (conjuncts.contains(parent)) { result.add(sca.getSubClass().asOWLClass()); } } } else if (ax instanceof OWLEquivalentClassesAxiom) { OWLEquivalentClassesAxiom eca = (OWLEquivalentClassesAxiom) ax; eca.classExpressions().filter(ce -> ce.containsConjunct(parent)) .forEach(ce -> eca .classExpressions().forEach(sub -> { if (!sub.isAnonymous() && !sub.equals(ce)) { result.add(sub.asOWLClass()); } })); } } return result; } }
@Override public Collection<OWLClass> getChildren(OWLClass parent) { Collection<OWLClass> result = new HashSet<>(); for (OWLAxiom ax : asUnorderedSet( getRootOntology().referencingAxioms(parent, INCLUDED))) { if (ax instanceof OWLSubClassOfAxiom) { OWLSubClassOfAxiom sca = (OWLSubClassOfAxiom) ax; if (!sca.getSubClass().isAnonymous()) { Set<OWLClassExpression> conjuncts = sca.getSuperClass().asConjunctSet(); if (conjuncts.contains(parent)) { result.add(sca.getSubClass().asOWLClass()); } } } else if (ax instanceof OWLEquivalentClassesAxiom) { OWLEquivalentClassesAxiom eca = (OWLEquivalentClassesAxiom) ax; eca.classExpressions().filter(ce -> ce.containsConjunct(parent)) .forEach(ce -> eca .classExpressions().forEach(sub -> { if (!sub.isAnonymous() && !sub.equals(ce)) { result.add(sub.asOWLClass()); } })); } } return result; } }
@Override public Collection<OWLClass> getChildren(OWLClass parent) { Collection<OWLClass> result = new HashSet<>(); for (OWLAxiom ax : asUnorderedSet( getRootOntology().referencingAxioms(parent, INCLUDED))) { if (ax instanceof OWLSubClassOfAxiom) { OWLSubClassOfAxiom sca = (OWLSubClassOfAxiom) ax; if (!sca.getSubClass().isAnonymous()) { Set<OWLClassExpression> conjuncts = sca.getSuperClass().asConjunctSet(); if (conjuncts.contains(parent)) { result.add(sca.getSubClass().asOWLClass()); } } } else if (ax instanceof OWLEquivalentClassesAxiom) { OWLEquivalentClassesAxiom eca = (OWLEquivalentClassesAxiom) ax; eca.classExpressions().filter(ce -> ce.containsConjunct(parent)) .forEach(ce -> eca .classExpressions().forEach(sub -> { if (!sub.isAnonymous() && !sub.equals(ce)) { result.add(sub.asOWLClass()); } })); } } return result; } }
public Collection<OWLClass> getChildren(OWLClass parent) { Collection<OWLClass> result = new HashSet<OWLClass>(); for (OWLOntology ont : getRootOntology().getImportsClosure()) { for (OWLAxiom ax : ont.getReferencingAxioms(parent)) { if (ax instanceof OWLSubClassOfAxiom) { OWLSubClassOfAxiom sca = (OWLSubClassOfAxiom) ax; if (!sca.getSubClass().isAnonymous()) { Set<OWLClassExpression> conjuncts = sca.getSuperClass().asConjunctSet(); if (conjuncts.contains(parent)) { result.add(sca.getSubClass().asOWLClass()); } } } else if (ax instanceof OWLEquivalentClassesAxiom) { OWLEquivalentClassesAxiom eca = (OWLEquivalentClassesAxiom) ax; for (OWLClassExpression ce : eca.getClassExpressions()) { if (ce.containsConjunct(parent)) { for (OWLClassExpression sub : eca.getClassExpressions()) { if (!sub.isAnonymous() && !sub.equals(ce)) { result.add(sub.asOWLClass()); } } } } } } } return result; } }
private void convertOWLClassExpressionToArcs(OWLClass owlClass, OWLClassExpression expression, Set<GraphArc> arcs, Icon icon, boolean mustBeVisible) { boolean isSubClass = true; if(icon != null) { isSubClass = false; } for(OWLClassExpression e : expression.asConjunctSet()) { if(e instanceof OWLQuantifiedRestriction) { OWLQuantifiedRestriction restriction = (OWLQuantifiedRestriction)e; if(restriction.getFiller() instanceof OWLClass) { String relType = owlModelManager.getRendering(restriction.getProperty()); if(isSubClass) { if(restriction instanceof OWLObjectSomeValuesFrom) relType += SUB_CLASS_SOME_VALUE_OF; else relType += SUB_CLASS_ALL_VALUES; } else { if(restriction instanceof OWLObjectSomeValuesFrom) relType += EQUIVALENT_CLASS_SOME_VALUE_OF; else relType += EQUIVALENT_CLASS_ALL_VALUES; } if(!filterManager.isArcTypeVisible(relType)) continue; if(isDisplayableNode( (OWLClass)restriction.getFiller(), mustBeVisible)) { arcs.add(createArc(owlClass, (OWLClass)restriction.getFiller(), relType, icon)); } } } } }
private void convertOWLClassExpressionsToArcs(OWLClass owlClass, Set<OWLClassExpression> expressions, Set<GraphArc> arcs, Icon icon, boolean mustBeVisible) { for(OWLClassExpression expression : expressions) { if(expression.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM) || expression.getClassExpressionType().equals(ClassExpressionType.OBJECT_ALL_VALUES_FROM)) { convertOWLClassExpressionToArcs(owlClass, expression, arcs, icon, mustBeVisible); } else if(expression.getClassExpressionType().equals(ClassExpressionType.OBJECT_INTERSECTION_OF)) { for(OWLClassExpression e : expression.asConjunctSet()) { convertOWLClassExpressionToArcs(owlClass, e, arcs, icon, mustBeVisible); } } } }
@Nonnull @Override public Set<PropertyValue> visit(OWLObjectSomeValuesFrom desc) { if (!desc.getProperty().isAnonymous()) { if (!desc.getFiller().isAnonymous()) { return toSet(PropertyClassValue.get(rm.getObjectPropertyData(desc.getProperty().asOWLObjectProperty()), rm.getClassData(desc.getFiller().asOWLClass()), state)); } else { Set<PropertyValue> result = Sets.newHashSet(); for (OWLClassExpression ce : desc.getFiller().asConjunctSet()) { if (!ce.isAnonymous()) { result.add(PropertyClassValue.get(rm.getObjectPropertyData(desc.getProperty().asOWLObjectProperty()), rm.getClassData(ce.asOWLClass()), State.DERIVED)); } } return result; } } else { return null; } }
private OWLAxiom parseClassAxiomRemainder(OWLClassExpression startExpression) { String kw = consumeToken(); if (SUBCLASS_OF.matchesEitherForm(kw)) { OWLClassExpression superClass = parseClassExpression(); return df.getOWLSubClassOfAxiom(startExpression, superClass); } else if (DISJOINT_WITH.matchesEitherForm(kw)) { OWLClassExpression disjointClass = parseClassExpression(); return df.getOWLDisjointClassesAxiom(startExpression, disjointClass); } else if (EQUIVALENT_TO.matchesEitherForm(kw)) { OWLClassExpression equivClass = parseClassExpression(); return df.getOWLEquivalentClassesAxiom(startExpression, equivClass); } else if (AND.matchesEitherForm(kw)) { OWLClassExpression conjunct = parseIntersection(); Set<OWLClassExpression> conjuncts = conjunct.asConjunctSet(); conjuncts.add(startExpression); OWLClassExpression ce = df.getOWLObjectIntersectionOf(conjuncts); return parseClassAxiomRemainder(ce); } else if (OR.matchesEitherForm(kw)) { OWLClassExpression disjunct = parseUnion(); Set<OWLClassExpression> disjuncts = disjunct.asDisjunctSet(); disjuncts.add(startExpression); OWLClassExpression ce = df.getOWLObjectUnionOf(disjuncts); return parseClassAxiomRemainder(ce); } else { throw new ExceptionBuilder() .withKeyword(SUBCLASS_OF, DISJOINT_WITH, EQUIVALENT_TO, AND, OR).build(); } }