我有一个程序,它使用 Jena 加载在 Protege 中设计的 .owl Ontology。我正在尝试使用 Pellet 对其进行推理,如果我在运行时添加一些语句来建模能够检查其一致性。例如,我有 'Method'、'Signature' 和 'hasSignature' 概念,其中 hasSignature 是一个对象属性。我有以下公理:
Method hasSignature exactly 1 Signature
当我添加一些实例语句以违反上述公理时,不会报告不一致。这是我的代码:
List<Statement> statements = new ArrayList<>();
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF);
FileManager.get().readModel(model, "Ontologies\\Ontology.owl");
OntClass Method = model.createClass( ns + "Method");
Individual method1 = Method.createIndividual(ns + "method1");
OntClass Signature = model.createClass( ns + "Signature");
Individual sign1 = Signature.createIndividual(ns + "sign1");
Individual sign2 = Signature.createIndividual(ns + "sign2");
Property hasSignature = model.createObjectProperty(ns + "hasSignature");
Statement st = model.createStatement(method1, hasSignature, sign1);
statements.add(st);
Statement st1 = model.createStatement(method1, hasSignature, sign2);
statements.add(st1);
Reasoner reasoner = PelletReasonerFactory.theInstance().create();
InfModel inf = ModelFactory.createInfModel(reasoner, model.add(statements));
System.out.println(inf.validate().isValid());
怎么了?为什么它不起作用?