Skip to content

Commit

Permalink
Merge pull request #322 from ontodev/issue-321
Browse files Browse the repository at this point in the history
Changing behavior for reduce, fixes #321
  • Loading branch information
cmungall authored Jul 27, 2018
2 parents e69ef9d + cdbb804 commit 8b8c09e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom;
import org.semanticweb.owlapi.model.OWLObjectPropertyCharacteristicAxiom;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom;
import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom;
import org.semanticweb.owlapi.model.parameters.Imports;
import org.semanticweb.owlapi.reasoner.Node;
import org.semanticweb.owlapi.reasoner.OWLReasoner;
Expand Down Expand Up @@ -99,10 +101,10 @@ public static void reduce(
OWLDataFactory dataFactory = manager.getOWLDataFactory();

// we treat an axiom as redundant if its is redundant within the
// subClassOf graph, excluding equivalence axioms
// subClassOf graph, including OP characteristic axioms (e.g. transitivity)
OWLOntology subOntology = manager.createOntology();
for (OWLAxiom a : ontology.getAxioms(Imports.INCLUDED)) {
if (!(a instanceof OWLEquivalentClassesAxiom)) {
if (a instanceof OWLSubClassOfAxiom || a instanceof OWLObjectPropertyCharacteristicAxiom) {
manager.addAxiom(subOntology, a);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void testReduceWithEquiv() throws IOException, OWLOntologyCreationExcepti
assertIdentical("/equiv_reduce_test_reduced.obo", reasoned);
}

/**
/**
* Edge case, taken from GO
*
* <p>See: 'central nervous system development' in the test file
Expand All @@ -135,8 +135,26 @@ public void testReduceEdgeCase() throws IOException, OWLOntologyCreationExceptio

Map<String, String> options = new HashMap<String, String>();
options.put("remove-redundant-subclass-axioms", "true");

ReduceOperation.reduce(reasoned, reasonerFactory, options);
assertIdentical("/reduce-edgecase-cnd-reduced.obo", reasoned);
}

/**
* Domain case, see https://github.com/ontodev/robot/issues/321
*
*
* @throws IOException
* @throws OWLOntologyCreationException
*/
@Test
public void testReduceDomainCase() throws IOException, OWLOntologyCreationException {
OWLOntology reasoned = loadOntology("/reduce-domain-test.owl");
OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory();

Map<String, String> options = new HashMap<String, String>();

ReduceOperation.reduce(reasoned, reasonerFactory, options);
assertIdentical("/reduce-domain-test.owl", reasoned);
}
}
12 changes: 12 additions & 0 deletions robot-core/src/test/resources/reduce-domain-test.owl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Prefix: : <http://x.org/>
Ontology: <http://x.org/>

ObjectProperty: supplies Domain: artery

Class: brain_artery
EquivalentTo: artery and supplies some brain
SubClassOf: artery
SubClassOf: supplies some brain

Class: artery
Class: brain

0 comments on commit 8b8c09e

Please sign in to comment.