Java Code Examples for org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom#getClassExpressions()
The following examples show how to use
org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom#getClassExpressions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompositionalClassPredictor.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void buildSimpleDefMap() { simpleDefMap = new HashMap<OWLClass,Set<OWLClassExpression>>(); OWLOntology o = getGraph().getSourceOntology(); for (OWLClass c : o.getClassesInSignature()) { for (OWLEquivalentClassesAxiom eca : o.getEquivalentClassesAxioms(c)) { Set<OWLClassExpression> elts = new HashSet<OWLClassExpression>(); for (OWLClassExpression x : eca.getClassExpressions()) { // assume one logical definitionper class - otherwise choose arbitrary if (x instanceof OWLObjectIntersectionOf) { if (getReachableOWLClasses(x, elts) && elts.size() > 0) { //LOG.info(c+" def= "+elts); simpleDefMap.put(c, elts); } } } } } }
Example 2
Source File: OWLGraphManipulator.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Reverse all {@code OWLObjectUnionOf}s, that are operands in * an {@code OWLEquivalentClassesAxiom}, into individual {@code OWLSubClassOfAxiom}s, where * the classes part of the {@code OWLObjectUnionOf} become subclasses, and * the original first operand of the {@code OWLEquivalentClassesAxiom} superclass. * <p> * Note that such {@code OWLEquivalentClassesAxiom}s are not removed from the ontology, * only {@code OWLSubClassOfAxiom}s are added. The axioms containing * {@code OWLObjectUnionOf}s will be removed by calling {@link #removeOWLObjectUnionOfs()}, * in order to give a chance to {@link #convertEquivalentClassesToSuperClasses()} * to do its job before. * * @see #performDefaultModifications() * @see #removeOWLObjectUnionOfs() * @see #convertEquivalentClassesToSuperClasses() */ private void reverseOWLObjectUnionOfs() { log.info("Reversing OWLObjectUnionOfs into OWLSubClassOfAxioms"); for (OWLOntology ont : this.getOwlGraphWrapper().getAllOntologies()) { for (OWLClass cls : ont.getClassesInSignature()) { for (OWLEquivalentClassesAxiom eca : ont.getEquivalentClassesAxioms(cls)) { for (OWLClassExpression ce : eca.getClassExpressions()) { if (ce instanceof OWLObjectUnionOf) { for (OWLObject child : ((OWLObjectUnionOf)ce).getOperands()) { //we reverse only named classes if (child instanceof OWLClass) { this.getOwlGraphWrapper().getManager().addAxiom(ont, ont.getOWLOntologyManager().getOWLDataFactory(). getOWLSubClassOfAxiom((OWLClass) child, cls)); } } } } } } } this.triggerWrapperUpdate(); log.info("OWLObjectUnionOf reversion done."); }
Example 3
Source File: CardinalityContraintsTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void visit(OWLEquivalentClassesAxiom axiom) { Set<OWLClassExpression> newExpressions = new HashSet<OWLClassExpression>(); boolean changed = false; for (OWLClassExpression ce : axiom.getClassExpressions()) { HandlerResult result = ce.accept(handler); if (result != null) { if (result.remove) { // skip handling and immediately remove and return remove(ontology, axiom); return; } changed = true; newExpressions.add(result.modified); } else { newExpressions.add(ce); } } if (changed) { remove(ontology, axiom); OWLEquivalentClassesAxiom newAxiom = factory.getOWLEquivalentClassesAxiom(newExpressions, axiom.getAnnotations()); add(ontology, newAxiom); } }
Example 4
Source File: OWLGraphWrapperEdges.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void cacheReverseUnionMap() { synchronized (edgeCacheMutex) { extraSubClassOfEdges = new HashMap<OWLObject, Set<OWLGraphEdge>>(); if (!config.isGraphReasonedAndRelaxed) { for (OWLOntology o : getAllOntologies()) { for (OWLClass cls : o.getClassesInSignature()) { for (OWLEquivalentClassesAxiom eca : o.getEquivalentClassesAxioms(cls)) { for (OWLClassExpression ce : eca.getClassExpressions()) { if (ce instanceof OWLObjectUnionOf) { for (OWLObject child : ((OWLObjectUnionOf)ce).getOperands()) { if (!extraSubClassOfEdges.containsKey(child)) { extraSubClassOfEdges.put(child, new OWLGraphEdgeSet()); } extraSubClassOfEdges.get(child).add( createSubClassOfEdge(child,cls,o,eca)); } } } } } } } } }
Example 5
Source File: SpeciesMergeUtil.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public OWLAxiom tr(OWLEquivalentClassesAxiom ax) { Set<OWLClassExpression> xs = new HashSet<OWLClassExpression>(); for (OWLClassExpression x : ax.getClassExpressions()) { OWLClassExpression tx = trx(x, true); if (tx == null) return null; xs.add(tx); } return fac.getOWLEquivalentClassesAxiom(xs); }
Example 6
Source File: TemplatedTransformer.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Set<OWLOntologyChange> tr(OWLAxiom inAxiom, Mapping m) { Set<OWLOntologyChange> chgs = new HashSet<OWLOntologyChange>(); boolean isModified = false; OWLAxiom newAxiom = null; if (inAxiom instanceof OWLEquivalentClassesAxiom) { OWLEquivalentClassesAxiom aa = (OWLEquivalentClassesAxiom)inAxiom; Set<OWLClassExpression> xs = new HashSet<OWLClassExpression>(); for (OWLClassExpression x : aa.getClassExpressions()) { OWLClassExpression x2 = replace(x, m); if (x2 == null) { xs.add(x); } else { isModified = true; xs.add(x2); LOG.info(" TR : "+x+ " ---> "+x2); } } if (isModified) { newAxiom = getOWLDataFactory().getOWLEquivalentClassesAxiom(xs); } } if (isModified) { if (m.isReplace) { chgs.add(new RemoveAxiom(ontology, inAxiom)); } chgs.add(new AddAxiom(ontology, newAxiom)); } return chgs; }
Example 7
Source File: SelfReferenceInDefinition.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Collection<CheckWarning> check(OWLGraphWrapper graph, Collection<OWLObject> allOwlObjects) { OWLOntology ontology = graph.getSourceOntology(); List<CheckWarning> violations = new ArrayList<CheckWarning>(); for(OWLClass cls : ontology.getClassesInSignature()) { Set<OWLEquivalentClassesAxiom> equivalentClassesAxioms = ontology.getEquivalentClassesAxioms(cls); if (equivalentClassesAxioms != null && !equivalentClassesAxioms.isEmpty()) { for (OWLEquivalentClassesAxiom owlEquivalentClassesAxiom : equivalentClassesAxioms) { for (OWLClassExpression ex : owlEquivalentClassesAxiom.getClassExpressions()) { if (ex instanceof OWLClass) continue; Set<OWLClass> classesInSignature = ex.getClassesInSignature(); if (classesInSignature != null && classesInSignature.contains(cls)) { String id = graph.getIdentifier(cls); String message = "Class "+id+" has a self reference in its logical definition: "+owlEquivalentClassesAxiom; CheckWarning warning = new CheckWarning("Self_Reference_In_Definition", message , isFatal(), cls.getIRI()); violations.add(warning); } } } } } if (!violations.isEmpty()) { return violations; } return null; }