繁体   English   中英

Pellet不包括我的SWRL规则

[英]Pellet doesn't include my SWRL rules

我构建了一个使用SWRL规则进行推理的本体。 当我在Protege中进行SQWRL查询时,它运行正常。 问题是,当我想将Pellet与Jena一起使用时,似乎Pellet在查询中不包含SWRL规则。 我包括像这样的Pellet:

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() + " . }");
}

我也试过这个:

Reasoner r = PelletReasonerFactory.theInstance().create();
InfModel inferenceModel = ModelFactory.createInfModel(r, model);

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

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

我可能会迟到但我认为你应该切换到猫头鹰,以便将所有规则都包含在推理中。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM