简体   繁体   English

创建使用OWL-API导入其他本体的OWL本体

[英]Creating an OWL ontology that imports other ontologies with OWL-API

I have just started using the OWL API in order to generate some examples that use other ontologies. 我刚刚开始使用OWL API,以生成一些使用其他本体的示例。 The situation is like this: I have two ontologies A and B that have many elements and imports from other ontologies. 情况是这样的:我有两个本体A和B,它们具有许多元素,并且是从其他本体导入的。 These two ontologies are part of a standard so they are closely related. 这两个本体是标准的一部分,因此它们紧密相关。 I need to generate an example of the standard's element that involves importing this two ontologies and using and combining classes and elements from both, but I don't know how to start. 我需要生成一个标准元素的示例,其中涉及导入这两种本体以及使用和组合两者中的类和元素,但是我不知道如何开始。 I have tried using the API but the only I have achieved is loading one of the ontologies, taking some classes and properties and combining them into a new ontology. 我已经尝试过使用API​​,但是我唯一实现的就是加载一种本体,获取一些类和属性并将它们组合成一个新的本体。 I also don't know how to define some namespace imports and some ontologies imports. 我也不知道如何定义一些名称空间导入和一些本体导入。 Also, I don't know how to define some shortcuts to use short namespaces instead of the large ones. 另外,我不知道如何定义一些快捷方式来使用短名称空间而不是大名称空间。 How can I do this? 我怎样才能做到这一点?

You could add a prefix using PrefixOWLOntologyFormat 您可以使用PrefixOWLOntologyFormat添加前缀

PrefixOWLOntologyFormat pf = (PrefixOWLOntologyFormat) manager.getOntologyFormat(ontology);
pf.setPrefix("aprefix" , "http://someurl/a.owl");

I don't know how you built your ontologies, but I suggest you add a namespace for the imported ontologies. 我不知道您是如何构建本体的,但是我建议您为导入的本体添加一个名称空间。

You can either do this in Protege by generating a prefix mapping in the "Ontology Prefixes" tab on the bottom of the "Active Ontology Tab" or manually in a text editor of your choice by adding a line like: 您可以在Protege中执行此操作,方法是在“活动本体选项卡”底部的“本体前缀”选项卡中生成前缀映射,或者在您选择的文本编辑器中手动添加以下行:

<Prefix name="your_desired_prefix" IRI="http://www.your.ontology/abc/xyz#"/>

Once you've done that, you can get hold of classes or individuals from different ontologies by using the namespace you defined. 完成此操作后,您可以使用定义的名称空间来掌握来自不同本体的类或个人。 In Java using the OWLAPI this would look something like: 在使用OWLAPI的Java中,这看起来像:

OWLClass yourClass = factory.getOWLClass("your_desired_prefix:Classname", pm);

I hope this is what you were looking for. 我希望这是您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM