簡體   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