My First Ontology in Protegé
As explained in the first section of this tutorial, ontologies are an extremely important technology and basis of the semantic web that aim to provide systems with expert knowledge over a wide range of topics.
Due to how extensive some fields of knowledge are, its useful to have tools that allow one to visualize and reorder data to build the ontologies and while some advances have been made towards automatic ontology generation, lots of the hard work still has to be made manually. Protegé is one such tool that allows to create ontologies using RDF/XML, OWL 2 and lots of other formats through a GUI and an easy step by step procedure. In this tutorial we're going to show how to build a simple anime ontology. |
Starting Protegé
As shown previously we're going to start Protegé using the terminal. In this case we're using Protegé version 5.0-beta. We initialize it by going to the application's directory (were we decompressed it after download) and typing:
$ ./run.sh &
This will display the application interface as shown in the Figure.
$ ./run.sh &
This will display the application interface as shown in the Figure.
Now we need to give a name to our ontology which will help it distinguish from others. In this case we must type the new name and directory in the IRI field which by default will have a untitled-ontology-ver name as placeholder. In this case I'll name the ontology anime (creative, I know).
Classes, Properties and Instances
First of all we need to define the classes our system must manage. These are used to describe groups of entities and thus to expand a graph to include more objects we want to define.
Lets say that in this example we want to create an application to list the series according to genre and/or studio that produced them. We know that each studio has several producers, we also know that there're several genres and each has particular traits. As such we define that these along with the series must be classes rather than entities.
We also know that anime is a broad term describing japanese animation with certain style and traits that distinguish it from other genres like western cartoons. We know that anime is a type of show, so we'll have it descend from the Show class so that it can be used to link to other databases later if our application starts growing.
Lets say that in this example we want to create an application to list the series according to genre and/or studio that produced them. We know that each studio has several producers, we also know that there're several genres and each has particular traits. As such we define that these along with the series must be classes rather than entities.
We also know that anime is a broad term describing japanese animation with certain style and traits that distinguish it from other genres like western cartoons. We know that anime is a type of show, so we'll have it descend from the Show class so that it can be used to link to other databases later if our application starts growing.
This will open a dialog where we specify the class name. As shown in the graph of our ontology, we want Show to be the highest end of the hierarchy to act as a linking point if we later want to link our ontology to another shows application. We press the OK button.
We repeat this process with each of the objects in our graph. If we want something to be a subclass, we just position ourselves in the object we want the new class to be a subclass of and press the Create subclass button. Our hierarchy must have a shape similar to this one:
In this case we have that Animes are a subclass of Show and thus will inherit all properties Show gets. In the same way Series, Genre and Studio are subClasses of anime and will inherit the properties inherent to this object along with having properties of their own.
Notice how we don't define the series, genres or studios explicitly in this case, rather we want them to be Instances of each class. There's no set rule of how to make an ontology though and there're people that use only subclasses or prefer using lots of properties to define instances. It works to have a standard though and its expected that W3C will soon release some rules to deal with this. |
Object Properties
Now its time to define object properties. These represent a link between classes so that for example you can know a certain element from the Studio class produced a certain element from the Series class or that a certain Series belongs to one or more of the Genres in the ontology. For this example we decided to define:
This will open a new dialog where we must type the Object Property name and press OK. Just like with classes we can add sub properties to our previous data if necessary.
- isGenre which defines that a certain anime belongs to a certain genre.
- Produces which defines that a certain studio is the producer of a given anime.
This will open a new dialog where we must type the Object Property name and press OK. Just like with classes we can add sub properties to our previous data if necessary.
Next we need to define the Domain and Range of our properties, that is, link them to the defined classes. We know that:
- Domain defines the class that possesses the property (subject). For example, we know that a studio produces a certain series and as such the Produces domain is the Studio class.
- Range defines the object that its affected by the property. For this example we know that the Studio <Produces> a Series and as such the class Series is the range of our property.
This will open a new window where we must move to the Object restriction creator tab and select our object property. We select the class that will be affected by our property (become the domain). We press the OK button.
We repeat the process for our range and the isGenre property so that it looks like this.
Data Properties
Now its time to define the data properties on our ontology. Data properties represent literal properties that define each individual in our ontology. For example, in this case we know that each series has a particular name that defines it along with a year in which it was released.
A good thing to consider before defining if we are going to use a data property is to ask whether that given property is unique to each individual and whether its desirable to link it to some other element in the ontology. If we just plan to consult and update the value then we can use a data property.
In order to add one, we must move to the Data property hierarchy tab as shown in the figure.
We select the Add sub property button.
A good thing to consider before defining if we are going to use a data property is to ask whether that given property is unique to each individual and whether its desirable to link it to some other element in the ontology. If we just plan to consult and update the value then we can use a data property.
In order to add one, we must move to the Data property hierarchy tab as shown in the figure.
We select the Add sub property button.
This will open a new window where we must type the name of the desired property and click the OK button. Lets say in this case we only want to store the name of the anime and the release year. To do that we will add the name and releaseYear data properties as shown.
Individuals
Next is time to add some individuals to our ontology to work with. These will be some genres (horror, drama, fantasy, etc.), studios and animes to play with later with SPARQL. In order to do that we select the Individuals by class tab as shown.
We type the name of the instance and press the OK button. We do this for each element we want to add.
We repeat the process with every class until each of them has the desired elements. In this case we added several genres (comedy, drama, horror) and several studios (A-1, SHAFT, Ufotable) along with several series (Boku dake ga inai machi, Puella Magi Madoka Magica, White Album 2).
Appendix
animegraph.graphml | |
File Size: | 15 kb |
File Type: | graphml |