为什么Jena的推理API说这段代码有效?

时间:2018-06-19 10:52:04

标签: rdf jena owl

我想使用Jena的推理API来检查实体是否有效。但是,运行下面的测试会产生true(有效)而不是false。我是Ontology和Inference API的新手。我的代码有什么问题吗?

    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
    model.setNsPrefix("kg", "http://ai.sankuai.com/kg/");

    OntClass klass = model.createClass("http://ai.sankuai.com/kg/POI");
    OntClass klass2 = model.createClass("http://ai.sankuai.com/kg/Address");
    OntClass klass3 = model.createClass("http://ai.sankuai.com/kg/Area");

    ObjectProperty pt = model.createObjectProperty("http://ai.sankuai.com/kg/property/abc");
    Restriction r = model.createHasValueRestriction("http://ai.sankuai.com/kg/property/aaa", pt, klass3);
    klass.addProperty(pt, "http://ai.sankuai.com/kg/property/abc");
    Individual dual = model.createIndividual("http://ai.sankuai.com/kg/POI/123", klass);
    InfModel inf = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF, model);
    System.out.println(inf.validate().isValid());

0 个答案:

没有答案