我在应用程序中执行推理程序时遇到了一个问题,我无法捕获由推理程序生成的推理。通常会执行printClassTree,向我显示找到了推理,但结果OWLOntology没有推理。当前代码:
com.clarkparsia.pellet.owlapiv3.PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner(ontology);
reasoner.getKB().realize();
reasoner.getKB().printClassTree();
我应该改变什么?我如何捕获由推理推理器得出的公理?
下面的代码工作得很好,这里的" interredonoontology "包含基本本体以及推断的结果。
请注意,这段代码是使用pellet 2.1或2.2版本测试的,不确定是否使用最新版本的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);
我使用这个导入
import com.clarkparsia.pellet.owlapiv3.PelletReasoner
与Pellet 2.3.0
我像这样声明:
PelletReasoner razonador;
和初始化本体:
razonador=com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.getInstance().createReasoner(ont)
其中ont是本体我只是用它来分类:
razonador.getKB().classify();
希望有帮助!