Search code examples
ontologyowlinferencepellet

catch all the inferences generated by pellet reasoner


I have a problem when executing the reasoner in my application, I can't capture the inferences generated by the reasoner. It's normally performed, the printClassTree shows me that inferences were found, but the result OWLOntology doesn't have inferences. The current code:

com.clarkparsia.pellet.owlapiv3.PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner(ontology);
    reasoner.getKB().realize();
    reasoner.getKB().printClassTree();

What should I change? How can I capture the axioms resulting from the inference reasoner?


Solution

  • The following code works fine and here "inferredOnotology" contains the base ontology and as well as the inferred results.

    Please note that this code was tested using pellet 2.1 or 2.2 version, not sure about the latest version of pellet.

            OWLOntology inferredOntology; 
            // Create Reasoner
            OWLReasonerFactory reasonerFactory = new PelletReasonerFactory();
            OWLReasoner reasoner = reasonerFactory.createReasoner(manager);
    
            // Load the ontologies into the reasoner.
            Set<OWLOntology> importsClosure = manager.getImportsClosure(inferredOntology);
            reasoner.loadOntologies(importsClosure);
    
            // Reason!
            reasoner.classify();
    
            InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner);
            iog.fillOntology(manager, inferredOntology);