简体   繁体   English

com.hp.hpl.jena.reasoner.rulesys.FBRuleInfGraph 不能转换为 org.mindswap.pellet.jena.PelletInfGraph

[英]com.hp.hpl.jena.reasoner.rulesys.FBRuleInfGraph cannot be cast to org.mindswap.pellet.jena.PelletInfGraph

i use https://www.jarfire.org/pellet.html我使用https://www.jarfire.org/pellet.html

to run an example, got error运行一个例子,得到错误

java.lang.ClassCastException: com.hp.hpl.jena.reasoner.rulesys.FBRuleInfGraph cannot be cast to org.mindswap.pellet.jena.PelletInfGraph at tutorial.HelloWorld.main(HelloWorld.java:178) java.lang.ClassCastException: com.hp.hpl.jena.reasoner.rulesys.FBRuleInfGraph 无法在 tutorial.HelloWorld.main(HelloWorld.java:178) 中转换为 org.mindswap.pellet.jena.PelletInfGraph

Model schema = FileManager.get().loadModel("C:/Users/vincent/Downloads/owlDemoSchema.owl");
            Model data = FileManager.get().loadModel("C:/Users/vincent/Downloads/owlDemoData.rdf");
            System.out.println("creating OntModel ");
            OntModel Infmodel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, schema);
                                  //dataset.getNamedModel(this.URL));
            // create an inferencing model using Pellet reasoner
            //InfModel model = ModelFactory.createInfModel(r, schema);
            Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
            InfModel model = ModelFactory.createInfModel(reasoner, data);
            // get the underlying Pellet graph
            PelletInfGraph pellet = (PelletInfGraph) model.getGraph();
            // check for inconsistency
            boolean consistent = pellet.isConsistent();
            if(consistent == true) 
                System.out.println("consistent");
            else
                System.out.println("not consistent");
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();

When you do this, you're getting whatever the default OWL reasoner from Jena.当您这样做时,您将获得来自 Jena 的任何默认 OWL 推理器。 That's a reasoner based on Jena's rule based inference.这是一个基于 Jena 基于规则的推理的推理器。 It's not a Pellet reasoner.它不是 Pellet 推理机。

That means that when you create the inference model, its reasoner is a rule based inference graph, not a Pellet inference graph, so this code fails:这意味着当您创建推理模型时,其推理器是基于规则的推理图,而不是 Pellet 推理图,因此此代码失败:

InfModel model = ModelFactory.createInfModel(reasoner, data);
// get the underlying Pellet graph
PelletInfGraph pellet = (PelletInfGraph) model.getGraph();

The original inference model that you created, though, with the following line, does have a Pellet reasoner behind it, and you can get a Pellet inference graph from it.但是,您创建的原始推理模型(包含以下行)背后确实有一个 Pellet 推理器,您可以从中获得 Pellet 推理图。

OntModel Infmodel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, schema);

That is, you should use something more like this:也就是说,你应该使用更像这样的东西:

OntModel infmodel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
// load data into the model
PelletInfGraph pellet = (PelletInfGraph) infModel.getGraph();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么会出现此异常com.hp.hpl.jena.reasoner.rulesys.Rule $ ParserException:在使用Apache Jena Reasoner时? - Why this exception occur com.hp.hpl.jena.reasoner.rulesys.Rule$ParserException: In Using Apache Jena Reasoner? 耶拿+ PermGen空间的颗粒推理 - Pellet Reasoner with Jena + PermGen spaces classNotFoundException:com.hp.hpl.jena.ontology.OntModelSpec - classNotFoundException: com.hp.hpl.jena.ontology.OntModelSpec Apache Jena - java.lang.UnsupportedClassVersionError:com / hp / hpl / jena / rdf / model / ModelFactory - Apache Jena - java.lang.UnsupportedClassVersionError: com/hp/hpl/jena/rdf/model/ModelFactory Java Jena Fuseki Set OntModelSpec粒子推理器 - Java jena fuseki set OntModelSpec pellet reasoner Jena / Fuseki:加载com.hp.hpl.jena.graph.impl.GraphBase的自定义实现? - Jena/Fuseki : loading a custom implementation of com.hp.hpl.jena.graph.impl.GraphBase? java.lang.NoClassDefFoundError:无法初始化类com.hp.hpl.jena.query.Query - java.lang.NoClassDefFoundError: Could not initialize class com.hp.hpl.jena.query.Query 尝试使用javac编译时com.hp.hpl.jena.rdf.model不存在 - com.hp.hpl.jena.rdf.model not exist when try to compile with javac java.lang.NoClassDefFoundError:com / hp / hpl / jena / shared / BadURIException在运行servlet时 - java.lang.NoClassDefFoundError: com/hp/hpl/jena/shared/BadURIException on running servlet 线程“ main”中的异常com.hp.hpl.jena.query.QueryParseException:在第1行第176列出现词法错误。在“ BIND”之后遇到:“”(32) - Exception in thread “main” com.hp.hpl.jena.query.QueryParseException: Lexical error at line 1, column 176. Encountered: “ ” (32), after : “BIND”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM