【问题标题】:Pellet doesn't include my SWRL rulesPellet 不包括我的 SWRL 规则
【发布时间】:2011-08-22 10:59:50
【问题描述】:

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

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

【问题讨论】:

  • 你好 viktor,你终于解决了你的问题了吗?

标签: jena pellet swrl


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2019-01-28
      • 2011-09-25
      • 2015-05-24
      • 1970-01-01
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 2013-06-25
      • 2015-11-23
      相关资源
      最近更新 更多