我正在尝试学习如何正确使用 OWLAPI,但我遇到了一些麻烦:我有一个构建活动(例如个人和社会活动)的本体;我的目标是创建一个简单的不一致示例,以便使用此 API:我想声明足球是一项个人活动。
IndividualActivity
在 Protegè 中定义为Equivalent to (Activity and (hasActor exactly 1 Person))
。
/// PIECE OF CODE ///
OWLDataFactory df = Singleton_Ontologia.getFactory();
IRI soccerIRI=IRI.create(Singleton_Ontologia.getIribase(),"Soccer");
IRI paoloIRI = IRI.create(Singleton_Ontologia.getIribase(),"Paolo");
IRI marcoIRI = IRI.create(Singleton_Ontologia.getIribase(),"Marco");
OWLNamedIndividual soccer = df.getOWLNamedIndividual(soccerIRI);
OWLNamedIndividual paolo = df.getOWLNamedIndividual(paoloIRI);
OWLNamedIndividual marco = df.getOWLNamedIndividual(marcoIRI);
OWLClass person = df.getOWLClass(
IRI.create(Singleton_Ontologia.getIribase()+"Person"));
OWLClass individual_activity = df.getOWLClass(
IRI.create(Singleton_Ontologia.getIribase()+"IndividualActivity"));
OWLObjectProperty hasActor = df.getOWLObjectProperty(
IRI.create(Singleton_Ontologia.getIribase()+"hasActor"));
OWLClassAssertionAxiom assertionAxiom = df.getOWLClassAssertionAxiom(individual_activity, soccer);
OWLClassAssertionAxiom assertionAxiom2 = df.getOWLClassAssertionAxiom(person, paolo);
OWLClassAssertionAxiom assertionAxiom3 = df.getOWLClassAssertionAxiom(person, marco);
OWLObjectPropertyAssertionAxiom assertionAxiom4 = df.getOWLObjectPropertyAssertionAxiom(hasActor, soccer, paolo);
OWLObjectPropertyAssertionAxiom assertionAxiom5 = df.getOWLObjectPropertyAssertionAxiom(hasActor, soccer, marco);
Singleton_Ontologia.getManager().addAxiom(ontologiaattuale,assertionAxiom);
Singleton_Ontologia.getManager().addAxiom(ontologiaattuale,assertionAxiom2);
Singleton_Ontologia.getManager().addAxiom(ontologiaattuale,assertionAxiom3);
Singleton_Ontologia.getManager().addAxiom(ontologiaattuale,assertionAxiom4);
Singleton_Ontologia.getManager().addAxiom(ontologiaattuale,assertionAxiom5);
/// CONSISTENCY CHECK ///
System.out.println("Consistency:"+Singleton_Ontologia.getReasoner().isConsistent());
这是 Hermit reasoner 的配置:
public static void configReasoner() {
iribase = "http://webmind.dico.unimi.it/CARE/locont.owl#";
Configuration config=new Configuration();
config.ignoreUnsupportedDatatypes=true;
factory = manager.getOWLDataFactory();
reasonerFactory = new ReasonerFactory();
reasoner = reasonerFactory.createReasoner(ont,config);
}
我创建了个人 Paolo 和 Marco 以创建超过 1 个Person
存在Actors
,Soccer
但该isConsistent()
方法仍然返回 true,而我期望一个 false 值。另外,我打印了ABOX内容:
___________ABOX___________
/////////////////////// OBJECT number 1 ///////////////////////
ClassAssertion(<http://webmind.dico.unimi.it/CARE/locont.owl#IndividualActivity> <http://webmind.dico.unimi.it/CARE/locont.owl#Soccer>)
/////////////////////// OBJECT number 2 ///////////////////////
ClassAssertion(<http://webmind.dico.unimi.it/CARE/locont.owl#Person> <http://webmind.dico.unimi.it/CARE/locont.owl#Paolo>)
/////////////////////// OBJECT number 3 ///////////////////////
ObjectPropertyAssertion(<http://webmind.dico.unimi.it/CARE/locont.owl#hasActor> <http://webmind.dico.unimi.it/CARE/locont.owl#Soccer> <http://webmind.dico.unimi.it/CARE/locont.owl#Paolo>)
/////////////////////// OBJECT number 4 ///////////////////////
ObjectPropertyAssertion(<http://webmind.dico.unimi.it/CARE/locont.owl#hasActor > <http://webmind.dico.unimi.it/CARE/locont.owl#Soccer> <http://webmind.dico.unimi.it/CARE/locont.owl#Marco>)
/////////////////////// OBJECT number 5 ///////////////////////
ClassAssertion(<http://webmind.dico.unimi.it/CARE/locont.owl#Person> <http://webmind.dico.unimi.it/CARE/locont.owl#Marco>)
___________END_ABOX___________
老实说,我不明白我的错误在哪里,有人可以帮助我吗?