Search code examples
owlowl-apipellet

Save Pellet inferences using OWL API


i'am using the last version of pellet reasoner with OWL API:

 OWLOntologyManager manager=OWLManager.createOWLOntologyManager();
 OWLOntology fist_ontology=manager.loadOntologyFromOntologyDocument.........
 ................
 OWLOntology last_ontology=manager.loadOntologyFromOntologyDocument..........

 reasoner=PelletReasonerFactory.getInstance().createReasoner(last_ontology);
 manager.addOntologyChangeListener(reasoner);

Several ontologies are loaded with the manager. Now I need to save in a file all of the inferences made by Pellet for all of the ontologies loaded with the manager, but I can not find any example. Someone can help me ? Thank you !


Solution

  • I have resolved:

    List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<>();
             gens.add(new InferredSubClassAxiomGenerator());  
             gens.add(new InferredClassAssertionAxiomGenerator());
             gens.add( new InferredDisjointClassesAxiomGenerator());
             gens.add( new InferredEquivalentClassAxiomGenerator());
             gens.add( new InferredEquivalentDataPropertiesAxiomGenerator());
             gens.add( new InferredEquivalentObjectPropertyAxiomGenerator());
             gens.add( new InferredInverseObjectPropertiesAxiomGenerator());
             gens.add( new InferredObjectPropertyCharacteristicAxiomGenerator());
             gens.add( new InferredPropertyAssertionGenerator());
             gens.add( new InferredSubDataPropertyAxiomGenerator());
             gens.add( new InferredSubObjectPropertyAxiomGenerator());
    
             InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
             OWLOntology infOnt = manager.createOntology();
             iog.fillOntology(datafactory, infOnt);
             manager.saveOntology(infOnt,new RDFXMLDocumentFormat(),IRI.create(new File("D://file.owl")));