owl api state来自导入的个人之间的ObjectProperty关系

时间:2018-05-19 15:26:45

标签: ontology protege owl-api

我有一个导入其他本体实例的本体实例,我试图在导入的个人(ObjectPropertyprofessors-instance)之间使用acm-ccs-lite-core来表示关系主要本体实例的个体(curricula-instance)。

如果我使用protege手工完成它会创建:

<!-- http://www.semanticweb.org/lsarni/ontologies/professors-instance#Andrés_Calviño -->

<rdf:Description rdf:about="http://www.semanticweb.org/lsarni/ontologies/professors-instance#Andrés_Calviño">
    <curricula:inChargeOf rdf:resource="http://www.semanticweb.org/lsarni/ontologies/curricula-instance#Software_Architecture"/>
</rdf:Description>

<!-- http://www.semanticweb.org/lulas/ontologies/2018/acm-ccs-lite-core#10011119 -->

<rdf:Description rdf:about="http://www.semanticweb.org/lulas/ontologies/2018/acm-ccs-lite-core#10011119">
    <curricula:taughtIn rdf:resource="http://www.semanticweb.org/lsarni/ontologies/curricula-instance#Databases_1"/>
</rdf:Description>

但是我尝试使用owl api的方式在主要的本体中创建了NamedIndividual,并添加了这样的关系:

<!-- http://www.semanticweb.org/lsarni/ontologies/professors-instance#Andrés_Calviño -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/lsarni/ontologies/professors-instance#Andrés_Calviño">
    <curricula:inChargeOf rdf:resource="http://www.semanticweb.org/lsarni/ontologies/curricula-instance#Software_Architecture"/>
</owl:NamedIndividual>

这是我正在使用的代码:

File file = new File("C:\\Users\\lulas\\Documents\\Curricula Ontology\\curricula-instance.owl");
OWLOntology o = man.loadOntologyFromOntologyDocument(file);
OWLDataFactory df = o.getOWLOntologyManager().getOWLDataFactory();

IRI curriculaIOR = IRI.create("http://www.semanticweb.org/lsarni/ontologies/curricula");
IRI instanceIOR = IRI.create("http://www.semanticweb.org/lsarni/ontologies/curricula-instance");
IRI profInstanceIOR = IRI.create("http://www.semanticweb.org/lsarni/ontologies/professors-instance");

OWLObjectProperty charge = df.getOWLObjectProperty(curriculaIOR + "#inChargeOf");
OWLIndividual individual = df.getOWLNamedIndividual(profInstanceIOR + "#Andrés_Calviño");
OWLIndividual course = df.getOWLNamedIndividual(instanceIOR + "#Software_Architecture");

OWLObjectPropertyAssertionAxiom objAssertion = df.getOWLObjectPropertyAssertionAxiom(charge, individual, course);
AddAxiom addAxiom = new AddAxiom(o, objAssertion);
man.applyChange(addAxiom);

创建rdf:Description的正确方法是什么?

修改

我在Windows上使用Protege版本5.2.0。

正如你们两个都说代码是正确的,我使用了一个导入本体的不正确的IRI,这就是为什么它作为这个NamedIndividual的不同之处。

1 个答案:

答案 0 :(得分:2)

rdf:Description with an rdf:about`IRI等同于命名个体,因此两个版本之间没有真正的区别。它们将被OWL API解析为相同的东西。

不确定为什么Protege会以这种格式输出它 - 正如Henriette在评论中所说的那样,哪个版本的Protege正在这样做?