1

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 !

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Discipulos
  • 423
  • 8
  • 23

2 Answers2

1

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"))); 
Discipulos
  • 423
  • 8
  • 23
0
public void flushToFile() {
        reasoner.flush();
        //System.out.println(reasoner.isEntailed(ax5));
        InferredOntologyGenerator gen = new InferredOntologyGenerator(reasoner);
        gen.fillOntology(factory, newOntology);
        try {
            manager.saveOntology(newOntology, new FileOutputStream(new File("D:\\XYZ\\OutputNew.owl")));
        } catch (OWLOntologyStorageException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

You can use this api for saving the ontology to a file. Also for your detailed understanding regarding the working you can go through this link :- tells about the working of a pellet reasoner and swrl rules

Batman22
  • 376
  • 4
  • 25
  • Only basic inferences will be added if you don't specify the type of inferences that should be included in the ontology. – Discipulos Sep 15 '15 at 08:40