我正在努力学习如何正确使用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推理器的配置:
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,以便创建多个Person
Actors
Soccer
isConsistent()
但___________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___________
方法仍然返回true,而我预计会出现错误值。
另外,我打印了ABOX内容:
MyMethodToIgnore
老实说,我无法理解我的错误在哪里,有人可以帮助我吗?
答案 0 :(得分:2)
你需要指明Marco和Paolo是不同的人。没有这个公理,没有什么能阻止它们成为同一个并保持本体一致。