我正在使用带有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来保存本体到一个文件。此外,您可以通过以下链接了解有关工作的详细信息:-告诉关于颗粒推理器的工作和swrl规则