Pellet不包括我的SWRL规则

时间:2011-08-22 10:59:51

标签: jena pellet swrl

我构建了一个使用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);

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

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