我一直在尝试设置一个查询打印机:https://github.com/owlcs/owlapi/wiki/dl-queries-with-a-real-reasoner,如果我用曼彻斯特语法给它一个查询,我就可以得到一个响应,它反映了我在Protege中得到的结果。我用Openllet替换了Hermit reasoner,它似乎不能再检索任何个体了。
出于原因,如果可能的话,我想远离耶拿。
ontController.java
public class OntController {
//declared variables here
public OntController(String name) throws OWLOntologyCreationException, OWLOntologyStorageException, IOException{
//initialized a bunch of other variables here
manager = OWLManager.createOWLOntologyManager();
reasonFactory = new OpenlletReasonerFactory();
}
public void reason(){
reasoner = reasonFactory.createReasoner(ont);
reasoner.precomputeInferences(InferenceType.OBJECT_PROPERTY_HIERARCHY, InferenceType.OBJECT_PROPERTY_ASSERTIONS);
}
public void infer(){
reasoner.precomputeInferences();
List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
gens.add(new InferredSubClassAxiomGenerator());
InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
iog.fillOntology(manager.getOWLDataFactory(), ont);
}
public void query() throws IOException{
reasoner = reasonFactory.createReasoner(ont);
ShortFormProvider shortFormProvider = new SimpleShortFormProvider();
DLQueryPrinter dlQueryPrinter = new DLQueryPrinter(new DLQueryEngine(reasoner,
shortFormProvider), shortFormProvider);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
while (true) {
System.out.println("Type a class expression in Manchester Syntax and press Enter (or press q to exit):");
//blah blah
}
dlQueryPrinter.askQuery(classExpression.trim());
System.out.println();
}
//more unrelated methods here
}
DLQueryEngine
import java.util.Collections;
import java.util.Set;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.reasoner.Node;
import org.semanticweb.owlapi.reasoner.NodeSet;
//import org.semanticweb.owlapi.reasoner.OWLReasoner;
import org.semanticweb.owlapi.util.ShortFormProvider;
import openllet.owlapi.OpenlletReasoner;
class DLQueryEngine {
private final OpenlletReasoner reasoner;
private final DLQueryParser parser;
public DLQueryEngine(OpenlletReasoner reasoner, ShortFormProvider shortFormProvider) {
this.reasoner = reasoner;
parser = new DLQueryParser(reasoner.getRootOntology(), shortFormProvider);
}
public Set<OWLClass> getSuperClasses(String classExpressionString, boolean direct) {
if (classExpressionString.trim().length() == 0) {
return Collections.emptySet();
}
OWLClassExpression classExpression = parser
.parseClassExpression(classExpressionString);
NodeSet<OWLClass> superClasses = reasoner
.getSuperClasses(classExpression, direct);
return superClasses.getFlattened();
}
public Set<OWLClass> getEquivalentClasses(String classExpressionString) {
if (classExpressionString.trim().length() == 0) {
return Collections.emptySet();
}
OWLClassExpression classExpression = parser
.parseClassExpression(classExpressionString);
Node<OWLClass> equivalentClasses = reasoner.getEquivalentClasses(classExpression);
Set<OWLClass> result = null;
if (classExpression.isAnonymous()) {
result = equivalentClasses.getEntities();
} else {
result = equivalentClasses.getEntitiesMinus(classExpression.asOWLClass());
}
return result;
}
public Set<OWLClass> getSubClasses(String classExpressionString, boolean direct) {
if (classExpressionString.trim().length() == 0) {
return Collections.emptySet();
}
OWLClassExpression classExpression = parser
.parseClassExpression(classExpressionString);
NodeSet<OWLClass> subClasses = reasoner.getSubClasses(classExpression, direct);
return subClasses.getFlattened();
}
public Set<OWLNamedIndividual> getInstances(String classExpressionString,
boolean direct) {
if (classExpressionString.trim().length() == 0) {
return Collections.emptySet();
}
OWLClassExpression classExpression = parser
.parseClassExpression(classExpressionString);
NodeSet<OWLNamedIndividual> individuals = reasoner.getInstances(classExpression,
direct);
return individuals.getFlattened();
}
}
您正在使用推断的子类公理生成器。这不会为个体创建公理,因此我不会期望生成的本体中有个体。要获得更多建议,我们需要看到再现问题的代码和数据片段。
OWLAPI用于序列化SWRL规则的OWL-XML序列化格式在哪里指定?例如。通过使用Protege(据我所知,它使用OWLAPI)序列化一个简单的规则,我得到以下代码: 这与SWRL规范[1]: 谢谢你![1]https://www.w3.org/submission/swrl/[2]http://dl.acm.org/citation.cfm?id=2890050
我刚开始用Protegé做本体论方面的工作,我正在尝试理解如何使用SWRL规则。我恐怕我不知道如何正确地对待它们,因为我不能产生任何输出。我将更多地解释我创建的一个简单的案例来测试这一点: 我创建了三个个体,称为A、B和C,每个个体都有一个测试属性,具有一个布尔范围。在每个属性断言选项卡上,我都初始化了它们的值,因此它们是、和。为了测试规则是如何工作的,我创建了这样一个规则:。我的理解是,如果A和
假设OWL本体论包含以下SWRL规则: 和以下对象属性断言: 当我运行的隐士推理器中的蛋白质,我得到以下推断对象属性断言: 然而,当我用owlready2加载同一个本体并运行它的hermitreasoner时,我没有得到任何推断的对象属性断言。例如: 不返回任何属性。 我确实以RDFXML格式保存了本体,并且可以使用owlready2检索SWRL规则。 owlready2推理器不支持这种推论吗?
本文向大家介绍如何使用HTML5 Canvas处理mousedown和mouseup,包括了如何使用HTML5 Canvas处理mousedown和mouseup的使用技巧和注意事项,需要的朋友参考一下 要使用HTML5 Canvas处理mousedown和mouseup事件,
我正在使用react router和react router redux处理我页面上的导航。我需要在组件内以编程方式更改url。我试着用这个方法:历史。推送实现这一点,但此方法只是更改url,与此url关联的组件不会更新。此应用程序是带有分页的简单列表,因此当我切换到下一页时,url会更改为例如/posts/1到/posts/2,但视图不会更新。我认为这应该是这样的: 用户单击分页项并单击处理程序
我正在开发一个java脚本客户端应用程序,在服务器端我需要处理CORS,所有我用JAX-RS和Jersey编写的服务。我的代码: 感谢佛普尼