首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pellet不包含我的SWRL规则

Pellet不包含我的SWRL规则
EN

Stack Overflow用户
提问于 2011-08-22 18:59:51
回答 2查看 885关注 0票数 3

我构建了一个本体,它使用SWRL规则进行推理。当我在Protege中执行SQWRL查询时,它工作得很好。问题是,当我想在Jena中使用Pellet时,Pellet似乎没有在查询中包含SWRL规则。我像这样包含了Pellet:

代码语言:javascript
复制
InputStream in = new FileInputStream(new File("D:\\Fakultet\\WeatherHealthcast1.owl"));
Model model = ModelFactory.createDefaultModel();
model.read(in, null);
OntModel ontology = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, model);

// Create a new query
String queryString =
            "PREFIX WeatherHealthcast: <http://www.semanticweb.org/ontologies/2011/2/WeatherHealthcast.owl#> " +
            "PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
            "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
            "SELECT ?disease " +
            "WHERE { " +
            "      ?person rdf:type WeatherHealthcast:Person." +
            "      ?person foaf:firstName ?fn." +
            "      ?person foaf:lastName ?ln." +
            "      FILTER regex(str(?fn), \"Viktor\")." +
            "      FILTER regex(str(?ln), \"Taneski\")." +
            "      ?disease rdf:type WeatherHealthcast:Disease. " +
            "      ?person WeatherHealthcast:suffersFrom ?disease." +
            "}";

Query query = QueryFactory.create(queryString);

// Execute the query and obtain results
QueryExecution qe = QueryExecutionFactory.create(query, ontology);
ResultSet resultSet = qe.execSelect();
System.out.println("TEST");

while (resultSet.hasNext())
{
    QuerySolution result = resultSet.next();
    RDFNode disease = result.get("disease");
    Resource resource = disease.asResource();

    System.out.println(" { Suffers from: " + resource.getLocalName() + " . }");
}

我还尝试了这个:

代码语言:javascript
复制
Reasoner r = PelletReasonerFactory.theInstance().create();
InfModel inferenceModel = ModelFactory.createInfModel(r, model);

但没有任何进展。有什么想法吗?我的毕业论文需要这个。谢谢

EN

回答 2

Stack Overflow用户

发布于 2014-09-06 00:18:27

据我所知,pellet不支持SQWRL。另一方面,它支持SWRL,但有一些限制(参见http://clarkparsia.com/pellet/faq/rules)。

票数 1
EN

Stack Overflow用户

发布于 2014-03-06 18:59:18

我可能会迟到,但我认为您应该切换到owl full,以便将您的所有规则包含在推理中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7146469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档