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)); }
@Override public OWLAxiom visit(OWLEquivalentClassesAxiom axiom) { return df.getOWLEquivalentClassesAxiom( axiom.classExpressions().map(p -> p.accept(classVisitor))); }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { // tested for memory release[x] if (axiom.namedClasses().collect(Collectors.toSet()).size() != 1) { createEquivalentClass(axiom); return; } OWLClass referencedClass = axiom.namedClasses().collect(Collectors.toSet()).iterator().next(); Set<OWLClassExpression> expressionsWithoutRefClass = axiom.getClassExpressionsMinus(referencedClass); for (OWLClassExpression anonymExpressions : expressionsWithoutRefClass) { anonymExpressions.accept(new OwlClassAxiomVisitor(vowlData, referencedClass)); } } private void createEquivalentClass(OWLEquivalentClassesAxiom axiom) {
@Override public void visit(OWLEquivalentClassesAxiom axiom) { if (axiom.classExpressions().count() == 2) { addPairwise(axiom, axiom.classExpressions(), OWL_EQUIVALENT_CLASS.getIRI()); } else { axiom.splitToAnnotatedPairs().stream().sorted().forEach(ax -> ax.accept(this)); } }
public MacroExpansions() { visitor = new GCIVisitor(inputOntology, newAxioms); inputOntology.axioms(AxiomType.SUBCLASS_OF).forEach(axiom -> axiom.accept(visitor)); inputOntology.axioms(AxiomType.EQUIVALENT_CLASSES) .forEach(axiom -> axiom.accept(visitor)); inputOntology.axioms(AxiomType.CLASS_ASSERTION).forEach(axiom -> axiom.accept(visitor)); inputOntology.axioms(AxiomType.ANNOTATION_ASSERTION).forEach(this::expand); }
ontology.classesInSignature().filter(owlClass -> !processedEquivalentClasses.contains(owlClass)).forEach(owlClass -> ontology.equivalentClassesAxioms(owlClass).forEach(equivalentAxiom -> equivalentAxiom.namedClasses().forEach(equivalentClasses::add); if (equivalentAxiom.containsOWLNothing()) thing_Nothing[1] = true; //equivalentToNothing if (equivalentAxiom.containsOWLThing()) thing_Nothing[0] = true; //equivalentToThing }); ontology.classAssertionAxioms(taxonomyNode.getName())// .map(classAssertionAxiom -> classAssertionAxiom.getIndividual())// .filter(individual -> individual.isNamed() && individual instanceof OWLNamedIndividual) //
@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 void visit(OWLEquivalentClassesAxiom axiom) { isLocal = false; if (pairs(axiom.classExpressions()).map(v -> df.getOWLEquivalentClassesAxiom(v.i, v.j)) .anyMatch(ax -> !kernel.isEntailed(ax))) { return; } isLocal = true; }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { dl(() -> insufficientOperands(axiom)); ql(() -> axiom.classExpressions().filter(ce -> !isOWL2QLSubClassExpression(ce)) .forEach(this::nonSubclass)); rl(() -> axiom.classExpressions() .filter(ce -> !ce.accept(equivalentClassExpressionChecker).booleanValue()) .forEach(this::nonEquivalentClass)); }
@Nonnull public OBOTermCrossProduct getCrossProduct(@Nonnull OWLClass term) { Optional<OWLEquivalentClassesAxiom> axiom = getCrossProductEquivalentClassesAxiom(term); if (!axiom.isPresent()) { return OBOTermCrossProduct.emptyOBOTermCrossProduct(); } Set<OWLObjectSomeValuesFrom> relationships = new HashSet<>(); Optional<OWLClass> genus = Optional.empty(); for (OWLClassExpression operand : axiom.get().getClassExpressionsMinus(term)) { Set<OWLClassExpression> conjuncts = operand.asConjunctSet(); for (OWLClassExpression conjunct : conjuncts) { if (conjunct instanceof OWLObjectSomeValuesFrom) { OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) conjunct; if (!svf.getProperty().isAnonymous() && !svf.getFiller().isAnonymous()) { relationships.add((OWLObjectSomeValuesFrom) conjunct); } } else if (conjunct instanceof OWLClass) { genus = Optional.of((OWLClass) conjunct); } } } Optional<OWLClassData> visualCls = genus.map(renderingManager::getClassData); Set<OBORelationship> discriminatingRelationships = relationships.stream() .map(relationshipConverter::toOboRelationship) .collect(toSet()); return new OBOTermCrossProduct(visualCls, new OBOTermRelationships(discriminatingRelationships)); }
@Override public Collection<OWLClass> getParents(OWLClass child) { Collection<OWLClass> result = new HashSet<>(); for (OWLOntology ont : getRootOntology().getImportsClosure()) { Stream.concat( ont.getSubClassAxiomsForSubClass(child).stream().map(OWLSubClassOfAxiom::getSuperClass), ont.getEquivalentClassesAxioms(child).stream().flatMap(ax -> ax.getClassExpressionsMinus(child).stream()) ).forEach(ce -> { if (!ce.isAnonymous()) { result.add(ce.asOWLClass()); } else if (ce instanceof OWLObjectIntersectionOf) { OWLObjectIntersectionOf intersectionOf = (OWLObjectIntersectionOf) ce; for (OWLClassExpression conjunct : intersectionOf.asConjunctSet()) { if (!conjunct.isAnonymous()) { result.add(conjunct.asOWLClass()); } } } }); } return result; }
private static OptimizedDirectedMultigraph<OWLClass> extractGraphFromSubsumptionAxiomsWith(final OWLOntology ontology, final ClassCollector visitor) { final OptimizedDirectedMultigraph<OWLClass> graph = new OptimizedDirectedMultigraph<>(); ontology.axioms(AxiomType.SUBCLASS_OF).forEach(axiom -> // processSubsumption(graph, axiom.getSubClass(), axiom.getSuperClass(), visitor)); ontology.axioms(AxiomType.EQUIVALENT_CLASSES).forEach(axiom -> { final Set<OWLClassExpression> equivalences = axiom.classExpressions().collect(Collectors.toSet()); for (final OWLClassExpression equivalence1 : equivalences) for (final OWLClassExpression equivalence2 : equivalences) if (equivalence1 != equivalence2) processSubsumption(graph, equivalence1, equivalence2, visitor); }); return graph; }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { if (axiom.classExpressions().count() == 2 && contains(axiom.classExpressions(), dataFactory.getOWLNothing())) { desc = axiom.classExpressions().filter(c -> !c.isOWLNothing()).findFirst().orElse(null); if (desc != null) { return; } } // (C and not D) or (not C and D) Iterator<OWLClassExpression> it = axiom.classExpressions().iterator(); OWLClassExpression descC = it.next(); OWLClassExpression notC = dataFactory.getOWLObjectComplementOf(descC); OWLClassExpression descD = it.next(); OWLClassExpression notD = dataFactory.getOWLObjectComplementOf(descD); OWLObjectIntersectionOf left = dataFactory .getOWLObjectIntersectionOf(CollectionFactory.createSet(descC, notD)); OWLObjectIntersectionOf right = dataFactory .getOWLObjectIntersectionOf(CollectionFactory.createSet(notC, descD)); desc = dataFactory.getOWLObjectUnionOf(CollectionFactory.createSet(left, right)); } }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { AtomicBoolean allAnon = new AtomicBoolean(true); axiom.classExpressions().filter(d -> !d.isAnonymous()).forEach(desc -> { equivalentClassesAxiomsByClass.put((OWLClass) desc, axiom); classAxiomsByClass.put((OWLClass) desc, axiom); allAnon.set(false); }); if (allAnon.get()) { addGeneralClassAxioms(axiom); } }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { axiom.namedClasses().forEach(cls -> { if (source == null) { source = cls; } else if (target == null) { target = cls; } }); }
@Override public Stream<K> visit(OWLEquivalentClassesAxiom axiom) { Stream<OWLClassExpression> stream = axiom.classExpressions(); if (named) { stream = stream.filter(c -> !c.isAnonymous()); } return (Stream<K>) stream; }
@Override public OWLAxiom visit(OWLEquivalentClassesAxiom axiom) { Set<OWLClassExpression> newExpressions = new HashSet<>(); AtomicBoolean sawChange = new AtomicBoolean(false); axiom.classExpressions().forEach(op -> { OWLClassExpression newExpression = op.accept(classVisitor); newExpressions.add(newExpression); if (!op.equals(newExpression)) { sawChange.set(true); } }); if (!sawChange.get()) { return axiom; } return df.getOWLEquivalentClassesAxiom(newExpressions, getAnnotationsWithOptionalExpansionMarker(axiom)); }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { axiom.classExpressions().forEach(desc -> { if (!desc.isAnonymous()) { getAxiomsForLHS(desc.asOWLClass()).add(axiom); } indexAxiomsByRHSEntities(desc, axiom); }); }
private void generateChanges() { Set<OWLClassExpression> supers = new HashSet<>(); for (OWLOntology o : ontologies) { o.equivalentClassesAxioms(cls).forEach(ax -> { addChange(new RemoveAxiom(o, ax)); ax.classExpressions().forEach(c -> collectClassExpressions(c, supers)); }); } supers.remove(cls); supers.forEach( sup -> addChange(new AddAxiom(targetOntology, df.getOWLSubClassOfAxiom(cls, sup)))); }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { process(axiom); axiom.classExpressions().forEach(a -> a.accept(this)); }