owl api state ObjectProperty 个人之间的关系从进口
owl api state ObjectProperty relation between individuals from imports
我有一个导入其他 ontology 实例的 ontology 实例,我正在尝试使用导入个体之间的 ObjectProperty
来说明关系(professors-instance
或 acm-ccs-lite-core
) 和主要 ontology 个体 (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 的方式会在主 ontology 中创建一个 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
s 的原因。
一个rdf:Description with an
rdf:about` IRI相当于一个具名个体,所以这两个版本之间没有真正的区别。它们将被 OWL API.
解析为同一事物
不确定为什么 Protege 以那种格式输出它 - 正如 Henriette 在评论中所问,哪个版本的 Protege 正在这样做?
我有一个导入其他 ontology 实例的 ontology 实例,我正在尝试使用导入个体之间的 ObjectProperty
来说明关系(professors-instance
或 acm-ccs-lite-core
) 和主要 ontology 个体 (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 的方式会在主 ontology 中创建一个 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
s 的原因。
一个rdf:Description with an
rdf:about` IRI相当于一个具名个体,所以这两个版本之间没有真正的区别。它们将被 OWL API.
不确定为什么 Protege 以那种格式输出它 - 正如 Henriette 在评论中所问,哪个版本的 Protege 正在这样做?