2
votes

I have just started using the OWL API in order to generate some examples that use other ontologies. The situation is like this: I have two ontologies A and B that have many elements and imports from other ontologies. 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. 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?

2
Please show some code that you tried, so that any advice can be specific. In ontologies, people don't usually talk about "elements" - what do you mean?Ben Companjen
Are you asking about creating a single new ontology whose contents are the axioms from the others (but might not have any owl:imports), or a new ontology that owl:imports A and owl:imports B?Joshua Taylor
I'm asking about the first one :) I want to define some namespaces to use axioms for other ontologies!user2083783

2 Answers

1
votes

You could add a prefix using PrefixOWLOntologyFormat

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

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:

<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:

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

I hope this is what you were looking for.