使用 OWL API 保存 Pellet 推理

Save Pellet inferences using OWL API

我正在使用最新版本的 pellet reasoner 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);

管理器加载了多个本体。现在我需要将 Pellet 对管理器加载的所有本体所做的所有推断保存在一个文件中,但我找不到任何示例。有人可以帮助我吗?谢谢!

我已解决:

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"))); 
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();
        }
    }

您可以使用此 api 将 ontology 保存到文件中。此外,为了您对工作的详细了解,您可以阅读此 link :- tells about the working of a pellet reasoner and swrl rules