ontology - owl api state ObjectProperty 个人之间的关系来自进口
问题描述
我有一个导入其他本体实例的本体实例,并且我正在尝试使用ObjectProperty
导入的个体(professors-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,这就是为什么它在不同的地方充当 this 的原因NamedIndividual
。
解决方案
一个rdf:Description with an
rdf:about` IRI 相当于一个命名的个体,因此两个版本之间没有真正的区别。它们将被 OWL API 解析为相同的东西。
不知道为什么 Protege 以这种格式输出它 - 正如 Henriette 在评论中所问的那样,哪个版本的 Protege 正在这样做?
推荐阅读
- wpf - 如何在 ViewModel 上绑定 DecimalUpDown 控件的 ValueChanged?
- asp.net-core - 启动 Azure 应用服务的间歇性问题:“500.37 ANCM 无法在启动时间限制内启动”
- jenkins-pipeline - 如何删除 Jenkins 管道中的零宽度空间
- nlog - Hangfire 没有登录到 NLog
- google-analytics - Google Analytics - 如何为电子邮件打开率跟踪设置 Google Analytics?
- android - 从滚动视图中删除任何项目会导致它向上滚动一点
- javascript - javascript中Set和Map的时间复杂度
- arrays - Flutter/Dart - 如何处理包含逗号分隔列表的 Json 数据?
- javascript - 如何解决此仪表板中的超时问题?
- python-2.7 - 如果属性存在则删除标签