public Set<OWLClass> getClassEquivalents(OWLClass clase) { Set<OWLClass> classSet = new HashSet<OWLClass>(); for (OWLEquivalentClassesAxiom eca : _ontology.getEquivalentClassesAxioms(clase)) { for (OWLClassExpression ce : eca.getClassesInSignature()) { if (!ce.equals(clase)) classSet.add(ce.asOWLClass()); } } return classSet; }
public Boolean visit(OWLEquivalentClassesAxiom axiom) { if (!axiom.containsNamedEquivalentClass()) { return false; } for (OWLClassExpression ce : axiom.getClassExpressions()) { if (!isOBOClassExpression(ce)) { return false; } } return true; }
public void visit(OWLEquivalentClassesAxiom axiom) { Set<OWLClassExpression> added = new HashSet<OWLClassExpression>(); for (OWLClassExpression descA : axiom.getClassExpressions()) { descA.accept(this); for (OWLClassExpression descB : axiom.getClassExpressions()) { if (!descA.equals(descB) && !added.contains(descA) && !added.contains(descB)) { addChildParent(descA, descB, axiom); descA.accept(this); descB.accept(this); added.add(descA); added.add(descB); } } } }
public Integer visit(OWLEquivalentClassesAxiom axiom) { int max = _0; for (OWLClassExpression ce : axiom.getClassExpressions()) { int depth = ce.accept(this); if (depth > max) { max = depth; } } return max; }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { if (axiom.getClassExpressions().size() > 2) { Set<Set<OWLClassExpression>> rendered = new HashSet<Set<OWLClassExpression>>(); for (OWLClassExpression left : axiom.getClassExpressions()) { for (OWLClassExpression right : axiom.getClassExpressions()) { if (left != right) { Set<OWLClassExpression> cur = CollectionFactory.createSet(left, right); if (!rendered.contains(cur)) { rendered.add(cur); left.accept(this); writeSpace(); write(EQUIV); writeSpace(); right.accept(this); } } } } } else if (axiom.getClassExpressions().size() == 2) { Iterator<OWLClassExpression> it = axiom.getClassExpressions().iterator(); OWLClassExpression descA = it.next(); OWLClassExpression descB = it.next(); OWLClassExpression lhs; OWLClassExpression rhs; if (subject.equals(descA)) { lhs = descA; rhs = descB; } else { lhs = descB; rhs = descA; } lhs.accept(this); writeSpace(); write(EQUIV); writeSpace(); rhs.accept(this); } }
/* * (non-Javadoc) * * @see * org.semanticweb.owlapi.model.OWLAxiomVisitor#visit(org.semanticweb.owlapi * .model.OWLEquivalentClassesAxiom) */ @Override public void visit(OWLEquivalentClassesAxiom axiom) { Set<OWLClassExpression> owlClassEspressions = axiom.getClassExpressions(); if (owlClassEspressions != null) { int i = 1; for (OWLClassExpression exp : owlClassEspressions) { exp.accept(this); if (i < owlClassEspressions.size()) { sb.append(" .EQ "); } i++; } } }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { Iterator<OWLClassExpression> classes = axiom.getClassExpressions().iterator(); OWLClassExpression c1 = classes.next(); OWLClassExpression c2 = classes.next(); if (classes.hasNext()) { logger.warning("EquivalentClassesAxiom with more than two elements not supported!"); } // apply simplification for the cases where either concept is // owl:Thing or owlapi:Nothin if (c1.isOWLNothing()) { result = c2; } else if (c2.isOWLNothing()) { result = c1; } else if (c1.isOWLThing()) { result = not(c2); } else if (c2.isOWLThing()) { result = not(c1); } else { result = or(and(c1, not(c2)), and(not(c1), c2)); } }
public void testAsSubAxioms() { OWLEquivalentClassesAxiom objA = EquivalentClasses(Class(createIRI()), Class(createIRI())); assertTrue(objA.asOWLSubClassOfAxioms().size() == 2); }
public Set<OWLAxiom> write(OWLClass cls) { Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); axioms.addAll(writeEntityStart(CLASS, cls)); if (!isFiltered(AxiomType.EQUIVALENT_CLASSES)) { for (OWLOntology ontology : getOntologies()) { SectionMap equivalentClasses = new SectionMap(); for (OWLEquivalentClassesAxiom ax : ontology.getEquivalentClassesAxioms(cls)) { if (ax.getClassExpressions().size() == 2) { if (isDisplayed(ax)) { for (OWLClassExpression equivCls : ax.getClassExpressionsMinus(cls)) { equivalentClasses.add(equivCls, ax); } axioms.add(ax); } } } equivalentClasses.remove(cls); writeSection(EQUIVALENT_TO, equivalentClasses, ",", true, ontology); } } if (!isFiltered(AxiomType.SUBCLASS_OF)) { for (OWLOntology ontology : getOntologies()) { SectionMap superclasses = new SectionMap(); for (OWLSubClassOfAxiom ax : ontology.getSubClassAxiomsForSubClass(cls)) { if (isDisplayed(ax)) { superclasses.add(ax.getSuperClass(), ax); axioms.add(ax); } } writeSection(SUBCLASS_OF, superclasses, ",", true, ontology); } if (renderExtensions) { for (OWLOntology ont : getOntologies()) { SectionMap subClasses = new SectionMap(); for (OWLSubClassOfAxiom ax : ont.getSubClassAxiomsForSuperClass(cls)) { if (isDisplayed(ax)) { subClasses.add(ax.getSubClass(), ax); axioms.add(ax); } } writeSection(SUPERCLASS_OF, subClasses, ",", true, ont); } } } if (!isFiltered(AxiomType.DISJOINT_CLASSES)) { for (OWLOntology ontology : getOntologies()) { Set<OWLAxiom> pairwiseDisjointClassesAxioms = new HashSet<OWLAxiom>(); SectionMap disjointClasses = new SectionMap(); for (OWLDisjointClassesAxiom ax : ontology.getDisjointClassesAxioms(cls)) { if (isDisplayed(ax)) { if (ax.getClassExpressions().size() == 2) { pairwiseDisjointClassesAxioms.add(ax); OWLClassExpression disjointWith = ax.getClassExpressionsMinus(cls).iterator().next(); disjointClasses.add(disjointWith, ax); } axioms.add(ax); } } writeSection(DISJOINT_WITH, disjointClasses, ", ", false, ontology); if (renderExtensions) { // Handling of nary in frame style for (OWLDisjointClassesAxiom ax : ontology.getDisjointClassesAxioms(cls)) { if (isDisplayed(ax)) { if (ax.getClassExpressions().size() > 2) { Set<OWLClassExpression> allDisjointClasses = new TreeSet<OWLClassExpression>(ax.getClassExpressions()); allDisjointClasses.remove(cls); axioms.add(ax); writeSection(DISJOINT_CLASSES, allDisjointClasses, ", ", false, ontology); } } } } } } if (!isFiltered(AxiomType.HAS_KEY)) { for (OWLOntology ontology : getOntologies()) { for (OWLHasKeyAxiom ax : ontology.getHasKeyAxioms(cls)) { if (isDisplayed(ax)) { SectionMap map = new SectionMap(); map.add(ax.getPropertyExpressions(), ax); writeSection(HAS_KEY, map, ", ", true, ontology); } } } } if (!isFiltered(AxiomType.CLASS_ASSERTION)) { for (OWLOntology ontology : getOntologies()) { SectionMap individuals = new SectionMap(); for (OWLClassAssertionAxiom ax : ontology.getClassAssertionAxioms(cls)) { if (isDisplayed(ax)) { if (renderExtensions || ax.getIndividual().isAnonymous()) { individuals.add(ax.getIndividual(), ax); axioms.add(ax); } } } writeSection(INDIVIDUALS, individuals, ",", true, ontology); } } if (!isFiltered(AxiomType.SWRL_RULE)) { for (OWLOntology ontology : getOntologies()) { Set<OWLAxiom> rules = new HashSet<OWLAxiom>(); for (SWRLRule rule : ontology.getAxioms(AxiomType.SWRL_RULE)) { if (isDisplayed(rule)) { for (SWRLAtom atom : rule.getHead()) { if (atom.getPredicate().equals(cls)) { writeSection(RULE, rules, ", ", true, ontology); break; } } } } } } writeEntitySectionEnd(CLASS.toString()); return axioms; }
public void writeOntology() throws OWLRendererException { if (ontologies.size() != 1) { throw new OWLRuntimeException("Can only render one ontology"); } OWLOntology ontology = getOntologies().iterator().next(); writePrefixMap(); writeNewLine(); writeOntologyHeader(ontology); for (OWLAnnotationProperty prop : ontology.getAnnotationPropertiesInSignature()) { write(prop); } for (OWLDatatype datatype : ontology.getDatatypesInSignature()) { write(datatype); } for (OWLObjectProperty prop : ontology.getObjectPropertiesInSignature()) { write(prop); OWLObjectPropertyExpression invProp = prop.getInverseProperty(); if (!ontology.getAxioms(invProp).isEmpty()) { write(invProp); } } for (OWLDataProperty prop : ontology.getDataPropertiesInSignature()) { write(prop); } for (OWLClass cls : ontology.getClassesInSignature()) { write(cls); } for (OWLNamedIndividual ind : ontology.getIndividualsInSignature()) { write(ind); } for (OWLAnonymousIndividual ind : ontology.getReferencedAnonymousIndividuals()) { write(ind); } // Nary disjoint classes axioms event = new RendererEvent(this, ontology); for (OWLDisjointClassesAxiom ax : ontology.getAxioms(AxiomType.DISJOINT_CLASSES)) { if (ax.getClassExpressions().size() > 2) { SectionMap map = new SectionMap(); map.add(ax.getClassExpressions(), ax); writeSection(DISJOINT_CLASSES, map, ",", false, ontology); } } // Nary equivalent classes axioms for (OWLEquivalentClassesAxiom ax : ontology.getAxioms(AxiomType.EQUIVALENT_CLASSES)) { if (ax.getClassExpressions().size() > 2) { SectionMap map = new SectionMap(); map.add(ax.getClassExpressions(), ax); writeSection(EQUIVALENT_CLASSES, map, ",", false, ontology); } } // Nary disjoint properties for (OWLDisjointObjectPropertiesAxiom ax : ontology.getAxioms(AxiomType.DISJOINT_OBJECT_PROPERTIES)) { if (ax.getProperties().size() > 2) { SectionMap map = new SectionMap(); map.add(ax.getProperties(), ax); writeSection(DISJOINT_PROPERTIES, map, ",", false, ontology); } } // Nary equivlant properties for (OWLEquivalentObjectPropertiesAxiom ax : ontology.getAxioms(AxiomType.EQUIVALENT_OBJECT_PROPERTIES)) { if (ax.getProperties().size() > 2) { SectionMap map = new SectionMap(); map.add(ax.getProperties(), ax); writeSection(EQUIVALENT_PROPERTIES, map, ",", false, ontology); } } // Nary disjoint properties for (OWLDisjointDataPropertiesAxiom ax : ontology.getAxioms(AxiomType.DISJOINT_DATA_PROPERTIES)) { if (ax.getProperties().size() > 2) { SectionMap map = new SectionMap(); map.add(ax.getProperties(), ax); writeSection(DISJOINT_PROPERTIES, map, ",", false, ontology); } } // Nary equivalent properties for (OWLEquivalentDataPropertiesAxiom ax : ontology.getAxioms(AxiomType.EQUIVALENT_DATA_PROPERTIES)) { if (ax.getProperties().size() > 2) { SectionMap map = new SectionMap(); map.add(ax.getProperties(), ax); writeSection(EQUIVALENT_PROPERTIES, map, ",", false, ontology); } } // Nary different individuals for (OWLDifferentIndividualsAxiom ax : ontology.getAxioms(AxiomType.DIFFERENT_INDIVIDUALS)) { if (ax.getIndividuals().size() > 2) { SectionMap map = new SectionMap(); map.add(ax.getIndividuals(), ax); writeSection(DIFFERENT_INDIVIDUALS, map, ",", false, ontology); } } for (SWRLRule rule : ontology.getAxioms(AxiomType.SWRL_RULE)) { writeSection(RULE, Collections.singleton(rule), ", ", false); } flush(); }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { Set<OWLClassExpression> descs = duplicateSet(axiom.getClassExpressions()); obj = dataFactory.getOWLEquivalentClassesAxiom(descs, duplicateAxiomAnnotations(axiom)); }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { handleObject(axiom); process(axiom.getClassExpressions()); }
@Override public void visit(OWLEquivalentClassesAxiom axiom) { for (OWLClassExpression desc : axiom.getClassExpressions()) { desc.accept(this); } }
public void visit(OWLEquivalentClassesAxiom axiom) { type = AXIOM_TYPE_INDEX_BASE + axiom.getAxiomType().getIndex(); }
public void visit(OWLEquivalentClassesAxiom axiom) { for (OWLClassExpression desc : axiom.getClassExpressions()) { desc.accept(this); } processAxiomAnnotations(axiom); }