RelaxOperation { public static void relax(OWLOntology ontology, Map<String, String> options) { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); Set<OWLAxiom> newAxioms = new HashSet<>(); Set<OWLEquivalentClassesAxiom> eqAxioms = ontology.getAxioms(AxiomType.EQUIVALENT_CLASSES); for (OWLEquivalentClassesAxiom ax : eqAxioms) { for (OWLClassExpression x : ax.getClassExpressions()) { if (!x.isAnonymous()) { OWLClass c = (OWLClass) x; for (OWLClassExpression y : ax.getClassExpressionsMinus(c)) { for (OWLObjectSomeValuesFrom svf : getSomeValuesFromAncestor(y, dataFactory)) { newAxioms.add(dataFactory.getOWLSubClassOfAxiom(c, svf)); } for (OWLClass z : getNamedAncestors(y)) { newAxioms.add(dataFactory.getOWLSubClassOfAxiom(c, z)); } } } } } for (OWLAxiom ax : newAxioms) { logger.info("NEW: " + ax); manager.addAxiom(ontology, ax); } }  static Map<String, String> getDefaultOptions(); static void relax(OWLOntology ontology, Map<String, String> options);  }
@Test public void testRelax() throws IOException { OWLOntology ont = loadOntology("/relax_equivalence_axioms_test.obo"); Map<String, String> options = new HashMap<String, String>(); options.put("remove-redundant-subclass-axioms", "true"); RelaxOperation.relax(ont, options); assertIdentical("/relax_equivalence_axioms_relaxed.obo", ont); }