public void visit(OWLDisjointClassesAxiom axiom) {
   Set<OWLClassExpression> added = new HashSet<OWLClassExpression>();
   for (OWLClassExpression descA : axiom.getClassExpressions()) {
     for (OWLClassExpression descB : axiom.getClassExpressions()) {
       if (!descA.equals(descB) && !added.contains(descA) && !added.contains(descB)) {
         addChildParent(descA, descB, axiom);
         added.add(descA);
         added.add(descB);
         descA.accept(this);
         descB.accept(this);
       }
     }
   }
 }
Esempio n. 2
0
 @Override
 public void visit(OWLDisjointClassesAxiom axiom) {
   if (axiom.getClassExpressions().size() != 2) {
     for (OWLClassExpression left : axiom.getClassExpressions()) {
       for (OWLClassExpression right : axiom.getClassExpressions()) {
         if (left != right) {
           if (left.equals(subject)) {
             left.accept(this);
             writeSpace();
             write(SUBCLASS);
             writeSpace();
             write(NOT);
             writeSpace();
             right.accept(this);
           } else {
             right.accept(this);
             writeSpace();
             write(SUBCLASS);
             writeSpace();
             write(NOT);
             writeSpace();
             left.accept(this);
           }
           writer.writeNewLine();
         }
       }
     }
   } else {
     Iterator<OWLClassExpression> it = axiom.getClassExpressions().iterator();
     OWLClassExpression descA = it.next();
     OWLClassExpression descB = it.next();
     OWLClassExpression lhs;
     OWLClassExpression rhs;
     if (descA.equals(subject)) {
       lhs = descA;
       rhs = descB;
     } else {
       lhs = descB;
       rhs = descA;
     }
     lhs.accept(this);
     writeSpace();
     write(SUBCLASS);
     writeSpace();
     write(NOT);
     writeSpace();
     rhs.accept(this);
   }
 }
 public Boolean visit(OWLDisjointClassesAxiom axiom) {
   for (OWLClassExpression ce : axiom.getClassExpressions()) {
     if (ce.isAnonymous()) {
       return false;
     }
   }
   return true;
 }
  public void actionPerformed(ActionEvent actionEvent) {
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
    int axiomsRemoved = 0;
    int axiomsAdded = 0;
    int numberOfDisjoints = 0;

    for (OWLOntology ont : getOWLModelManager().getActiveOntologies()) {

      // act on each ontology in turn
      CliqueFinder<OWLClassExpression> merger = new CliqueFinder<OWLClassExpression>();

      Set<OWLDisjointClassesAxiom> oldAxioms = ont.getAxioms(AxiomType.DISJOINT_CLASSES);
      numberOfDisjoints += oldAxioms.size();
      for (OWLDisjointClassesAxiom ax : oldAxioms) {
        merger.add(ax.getClassExpressions());
      }

      for (Set<OWLClassExpression> newAxioms : merger.getResults()) {
        OWLDisjointClassesAxiom newAxiom =
            getOWLModelManager().getOWLDataFactory().getOWLDisjointClassesAxiom(newAxioms);
        if (oldAxioms.contains(newAxiom)) {
          oldAxioms.remove(newAxiom);
        } else {
          changes.add(new AddAxiom(ont, newAxiom));
          axiomsAdded++;
        }
      }

      for (OWLDisjointClassesAxiom oldAxiom : oldAxioms) {
        changes.add(new RemoveAxiom(ont, oldAxiom));
        axiomsRemoved++;
      }
    }
    getOWLModelManager().applyChanges(changes);
    logger.info(
        axiomsRemoved
            + " (of "
            + numberOfDisjoints
            + " total) disjoint class axioms replaced with "
            + axiomsAdded);
  }
 @Override
 public void visit(OWLDisjointClassesAxiom axiom) {
   Set<OWLClassExpression> descs = duplicateSet(axiom.getClassExpressions());
   obj = dataFactory.getOWLDisjointClassesAxiom(descs, duplicateAxiomAnnotations(axiom));
 }
 public void visit(OWLDisjointClassesAxiom axiom) {
   for (OWLClassExpression desc : axiom.getClassExpressions()) {
     desc.accept(this);
   }
   processAxiomAnnotations(axiom);
 }