In this post I'm going to discuss some issues related to how IRIs are utilized in Desktop Protégé and Web Protégé. For the rest of this post, Protégé refers to the Desktop version. Like many of my posts, this is based on some recent experience I had where a problem took me some time to figure out and I'm hoping this will help people avoid the same problem. To begin with make sure you understand the difference between an rdfs:label, a user supplied IRI, and a UUID. If you don't I suggest reading this previous blog post first.
In Protégé, when you create a new ontology a new IRI will be generated for you. Something like: http://www.semanticweb.org/mdebe/ontologies/2022/11/untitled-ontology-252 The first thing I always do is to change that to something more intuitive. E.g., I named the ontology in a previous post on the UN Sustainable Development Goals: http://www.semanticweb.org/mdebe/ontologies/2022/10/UNSDG I'm going to use this ontology as my example. To change the IRI in desktop Protégé, just go to the Active Ontology tab and edit the Ontology IRI at the top. You will get a message when you do so asking if you want to update the IRIs of any existing entities. You should say yes.
At the bottom of the Active Ontology tab you will see three long sub-tabs. If you click on the Ontology prefixes tab you will see mappings that look like this:
On the left is every prefix your ontology uses and then next to the prefix is the IRI that it maps to. Protégé generates a default mapping from the empty prefix to your ontology IRI. That way when you refer to entities in your ontology you don't have to use a prefix. However, you still have the option of using a prefix to refer to entities in other ontologies. For example, if you go to the Annotation Properties tab you will see that all of those properties have prefixes because they come from different ontologies, specifically rdfs and owl. Also, note that in the UNSDG ontology I added a prefix for Dublin Core (dc). This is a practice I've started to use and I encourage others to consider. Often we'll have properties (e.g., identifier) and classes (e.g., Agent) that already exist in commonly reused vocabularies (Dublin Core and FOAF respectively). I think it's a good idea to re-use the entities from these common vocabularies rather than creating entities with the same name that are in your ontology. This makes your ontology more reusable and there are various tools that will look for these properties and know what to do with them. The most common example is rdfs:label but there are many more.
In the UNSDG ontology I started to create a property called identifier but it occurred to me that there was probably such a property in Dublin Core which there was. So I added a new mapping to the Dublin Core ontology by using the icon in the upper left corner of the Ontology prefixes tab that looks like two circles with a plus sign superscript. That generates an empty mapping with the prefix p0. I edited p0 to be dc and then I pasted in the IRI for the Dublin Core model. Then I added dc:identifier in the Annotation properties tab. Like most Dublin Core properties identifier is meta-data and hence can apply to classes and properties as well as individuals so it should be an annotation property.
So far, this is all straight forward. The issue was when I uploaded the UNSDG ontology to Web Protégé and added a class called SDG_Indicator. I expected the class to have the IRI: http://www.semanticweb.org/mdebe/ontologies/2022/10/UNSDG#SDG_Indicator. To my surprise instead it had the IRI: http://webprotege.stanford.edu/RJQ3VnUaMd6YlqtJYuI0F1 This was due to two issues:
When you upload an ontology into Web Protégé, rather than pick up the default ontology IRI from your file, Web Protégé assigns the IRI Prefix: http://webprotege.stanford.edu/
When you upload an ontology into Web Protégé, rather than pick up the default new entity IRI from the preferences (which I had set to user supplied name) it defaults to UUIDs.
Both of these are easy to fix. In Web Protégé go to Project>Settings (Project is a link in the upper left corner). In New Entity Settings you will see that the default IRI prefix is: http://webprotege.stanford.edu/. Change that to the IRI that is the IRI for your ontology defined in Protégé. Note: make sure to copy from the mappings in the Ontology prefixes tab not from the Ontology IRI at the top of the Active Ontology tab. The difference is that in the Ontology prefixes tab there will be an extra / or # character which you need in order to correctly map to an individual entity. Also, in New Entity Settings in Web Protégé, if needed (assuming you aren't using UUIDs) change the IRI suffix to whatever format you were using in Protégé. Here is what it looks like after I changed it for the UNSDG ontology: