Pregunta

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?

¿Fue útil?

Solución

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);

Otros consejos

I'm using this import

import com.clarkparsia.pellet.owlapiv3.PelletReasoner

with Pellet 2.3.0

I'm declaring like this:

PelletReasoner razonador;

and initializing with the ontology with this:

razonador=com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.getInstance().createReasoner(ont)

where ont is the ontology and I'm just using this to classify:

razonador.getKB().classify();

Hope it helps!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top