org.semanticweb.owlapi.util.OWLClassExpressionVisitorAdapter Java Examples
The following examples show how to use
org.semanticweb.owlapi.util.OWLClassExpressionVisitorAdapter.
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: ReasonerUtil.java From SciGraph with Apache License 2.0 | 6 votes |
void removeRedundantAxioms() { final List<RemoveAxiom> changes = new ArrayList<RemoveAxiom>(); Set<OWLClass> allClasses = ont.getClassesInSignature(true); logger.info("Check classes for redundant super class axioms, all OWL classes count: " + allClasses.size()); for (OWLClass cls: allClasses) { final Set<OWLClass> directSuperClasses = reasoner.getSuperClasses(cls, true).getFlattened(); for (final OWLOntology importedOntology: ont.getImportsClosure()) { Set<OWLSubClassOfAxiom> subClassAxioms = importedOntology.getSubClassAxiomsForSubClass(cls); for (final OWLSubClassOfAxiom subClassAxiom : subClassAxioms) { subClassAxiom.getSuperClass().accept(new OWLClassExpressionVisitorAdapter(){ @Override public void visit(OWLClass desc) { if (directSuperClasses.contains(desc) == false) { changes.add(new RemoveAxiom(importedOntology, subClassAxiom)); } } }); } } } logger.info("Found redundant axioms: " + changes.size()); List<OWLOntologyChange> result = manager.applyChanges(changes); logger.info("Removed axioms: " + result.size()); }
Example #2
Source File: AssertInferredClassExpressions.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static Set<OWLObjectSomeValuesFrom> getSuperSVFs(Set<OWLSubClassOfAxiom> axioms) { final Set<OWLObjectSomeValuesFrom> svfs = new HashSet<OWLObjectSomeValuesFrom>(); for (OWLSubClassOfAxiom existing : axioms) { OWLClassExpression superCE = existing.getSuperClass(); superCE.accept(new OWLClassExpressionVisitorAdapter() { @Override public void visit(OWLObjectSomeValuesFrom svf) { svfs.add(svf); } }); } return svfs; }
Example #3
Source File: AssertInferredClassExpressions.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static Set<OWLObjectSomeValuesFrom> getSVFs(Set<OWLClassExpression> expressions) { final Set<OWLObjectSomeValuesFrom> svfs = new HashSet<OWLObjectSomeValuesFrom>(); for(OWLClassExpression ce : expressions) { ce.accept(new OWLClassExpressionVisitorAdapter(){ @Override public void visit(OWLObjectSomeValuesFrom svf) { svfs.add(svf); } }); } return svfs; }
Example #4
Source File: TransitivityGraphTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Use the {@link ExpressionMaterializingReasoner} to also infer * 'REL some value from TARGET' unnamed super classes. * * @throws Exception */ @Test public void testExpectedRelations() throws Exception { final OWLClass in = graph.getOWLClassByIdentifier("GO:0030414"); // GO:0030414 ! peptidase inhibitor activity final OWLClass ac = graph.getOWLClassByIdentifier("GO:0008233"); // GO:0008233 ! peptidase activity List<String> propIds = Arrays.asList("BFO:0000050", "BFO:0000066", "RO:0002211", "RO:0002212", "RO:0002213", "RO:0002215", "RO:0002216"); Set<OWLObjectProperty> props = graph.relationshipIDsToPropertySet(propIds); ExpressionMaterializingReasoner r = new ExpressionMaterializingReasoner(graph.getSourceOntology(), new ElkReasonerFactory()); Logger.getLogger(ExpressionMaterializingReasoner.class).setLevel(Level.ERROR); Logger.getLogger("org.semanticweb.elk").setLevel(Level.ERROR); r.materializeExpressions(props); Set<OWLClassExpression> superClassExpressions = r.getSuperClassExpressions(in, false); final Set<String> foundProperties = new HashSet<String>(); for (OWLClassExpression ce : superClassExpressions) { ce.accept(new OWLClassExpressionVisitorAdapter(){ @Override public void visit(OWLClass cls) { if (cls.isBuiltIn() == false && ac.equals(cls)) { foundProperties.add("is_a"); } } @Override public void visit(OWLObjectSomeValuesFrom svf) { if (ac.equals(svf.getFiller())) { foundProperties.add(graph.getIdentifier(svf.getProperty())); } } }); } assertEquals(2, foundProperties.size()); assertTrue(foundProperties.contains("RO:0002211")); assertTrue(foundProperties.contains("RO:0002212")); }