Ontology engineering with Protege

Before the lab


Lab instructions

This lab aims to get you familiar with the Protégé ontology editor and chosen OWL constructs. You are encouraged to continue developing and refining your ontology at home.


  1. The lab is divided into sections. You should allow aprox. 10 minutes for each section.
  2. You can follow the instructions and build an ontology for multimedia OR you can do all the tasks on your SME ontology started in WebProtege. Your choice.
  3. If you work on your SME ontology, mark in the report which class corresponds to:
    1. JazzMusicCD,​ ClassicalMusicCD,​ RockMusicCD,​ MetalMusicCD
    2. BaroqueOrganMusicCD
    3. ACapellaMusicCD

0 Using Protégé on charon

To run Protégé type:

$ protege 

If it doesn't work, try to create an alias:

$ alias protege='bash /usr/local/Protege_4.1/run.sh'
$ protege 

1 Protégé. Primitive class hierarchy

  1. Start Protégé.
  2. If you use Protege 4.1:
    1. Select Create new OWL ontology
    2. Set the Ontology ID → Select Physical location → Set Ontology Format to RDF/XML → Finish
  3. You will now have an empty ontology.

    Begin to create the primitive classes in your model. This begins with a couple of top-level concepts. Create the following tree by using the Create Subclass and Create Sibling Class buttons in the Asserted Hierarchy.

  4. Create further subclasses of the library item categories producing a hierarchy. We recommend suffixing each book with …Book, each CD with CD and so on. Make sure you have at least included the following as they will be used later: JazzMusicCD, ClassicalMusicCD, RockMusicCD, MetalMusicCD. Notice that we are adding a suffix of MusicCD to all the subclasses of MusicCD – this is to allow for the later possibility of extending our ontology to talk about other types of multimedia such as computer games, where FrenchArtistMusicCD might be different from FrenchArstistMovie
  5. Where required, add additional superclasses using the SuperclassesSubClass Of button and the Class hierarchy tab.

    Notice that classes with multiple parents appear in several places in the asserted hierarchy.
  6. Create a RiversideBandMusicCD class as a subclass of PolishMusicCD and ProgressiveRockMusicCD (:!: create the class once, then choose the class, click on the SuperclassesSubClass Of button in the class description, and choose appropriate classess from Class hierarchy tab).

  7. You should now have a small hierarchy of MusicCDs/Movies/Books. Add to these whenever you have a few minutes as they will allow you to create a larger ontology of multimedia later on.

2 Disjoints

  1. You will need to run a reasoner supporting the DIG interface to check the consistency of your ontology. The reasoner software being used may change from time to time (check the Protégé- OWL webpages to check the currently recommended reasoners).
  2. To make sure a Book cannot be a MusicCD at the same time, add disjoints in to your primitive tree.
  3. Select one of your top level concepts (eg Book)
  4. Select Make primitive siblings disjoint in the Edit Menu

  5. Repeat this where appropriate, for each level of your ontology, selecting a class and making all of its siblings disjoint.
  6. In Reasoner Menu choose HermiT. Start the reasoner. Once your reasoner is running, periodically classify your ontology by pressing the Synchronize reasoner button on the toolbar
    1. :!: 8-) If you get inconsistencies (some classes are highlighted red in the hierarchy), check what to do here. Take a screenshot of the inconsistent class hierarchy, see what is wrong with Explanation button and repair the ontology. Write in the report how you repaired it.
  7. Add more multimedia categories if you have time, making sure these are disjoint where necessary.

3 Properties and Restrictions

In order to describe our classes we need properties, which are used to relate members of a class. We then add restrictions on the class to state logically how these properties are used. At this stage we are creating Primitive Classes, which only have Necessary Conditions (in this case, restrictions) on them – these are conditions that must be satisfied by all members of this class.

  • For this exercise create classes as in the picture: (note the new class: Artist :!:)

  1. Step 1: Create Properties
    1. Select the Properties Tab
    2. Create a new Object Property, containsMusicPerformedBy

    3. Create 2 more properties: containsMusic and containsMusicPerformedOn
  2. Step 2: Create restrictions
    1. Select the Classes Tab
    2. Select the MusicCD class
    3. In the rigth panel for this class, select SuperclassesSubClass Of (click the circle with + to add new superclass), then choose Object restriction creator tab
    4. In the left window choose containsMusicPerformedBy and in the right choose the Artist class. Make sure that Restriction Type is set to Some (existential). This means that for every MusicCD there exist an artist who performs the music in this MusicCD. Note that by default, restrictions are created as Necessary Conditions unless the Necessary & Sufficient heading is selected – for creating primitive classes, only create Necessary Conditions.

  3. Step 3: Define a class BaroqueOrganMusicCD
    1. Create a new subclass of MusicCD BaroqueOrganMusicCD
    2. Select BaroqueOrganMusicCD (note the superclass inherited from the MusicCD)

    3. Select SuperclassesSubClass Of → Object restriction creator
    4. Using Existential restriction choose containsMusicPerformedOn in the left window and OrganInstrument in the class hierarchy in the right window. Set another restriction saying that BaroqueOrganMusicCD - containsMusic - BaroqueMusicGenre. Eventually you should have a primitive class defined as follows:

  4. Create a class JimiHendrixMusicCD as a subclass of the MusicCD, define that it contains music performe on an electric guitar

  5. Create some other kinds of MusicCD, books or movies (if you haven't exceeded your 10minutes/section yet)

4 Defined Classes and Additional Modelling Constructs in OWL

Creating a defined class is similar to creating a primitive class, but a defined class has one or more Necessary & Sufficient Condition. Classes can easily be migrated between primitive and defined. We wish to model the statement: „Any MusicCD that contains music played on any kind of guitar is a GuitarMusicCD”.

  1. Create a new subclass of MusicCD called GuitarMusicCD. In general, defined classes are not disjoint from their siblings
  2. Create a restriction on GuitarMusicCD to state that it contains music performed on guitar.
  3. Select both conditions (the new restriction and the superclass, MusicCD) and in the context menu choose Convert selected rows to defined class.

    They should move to the Equivalent classes section and the class icon (see class hierarchy) should change to contain an equivalence symbol. You can also create restrictions under this heading automatically by selecting it before pressing Create Restriction. The result should be as below:

  4. Classify your ontology (Synchronize the reasoner) and check in the Class hierarchy (inferred) to see what has been classified under the new class. An Inferred Hierarchy panel appears: All MusicCDs that are set to contain music performed on any kind of guitar should now be subclasses of GuitarMusicCD.

  5. Click on the JimiHendrixMusicCD which should be classified as a GuitarMusicCD. Choose Explain inference question mark button and analyze the inference the reasoner did to classify the subclass relationship.
    • This option may be unavailable if you use a reasoner older than HermiT 1.3.4 :-(

  6. If you have time, create several other defined classes of your choosing and classify each time to see if their definition has „captured” the correct named CDs.

5 Union in OWL

In order to define an ACappellaMusicCD, we are going to model the idea of a music performed without instruments. This class is going to be covered by all of the Music that are not InstrumentalMusic. GregorianChant, JewishCantillation, MuslimAnaseheed etc. are all to be classified as ACapellaMusic.

  • Create a Music class.
  • Create the following subclasses of the Music class: GregorianChant, JewishCantillation, MuslimAnaseheed.
  1. Create a new subclass of Music called ACapellaMusic
  2. Click on the Equivalent classes Add button
  3. Click the Class expression editor
  4. In the expression editor that appears type a list of the Music you would like to be considered ACapella, separated by the union symbol (which can be added by typing „or” (lowercase).

  5. Click OK to accept the changes. This can only be done when the expression is correct (e.g. the class names are valid)
  6. Classify your ontology – check that all the expected Music classes are now subsumed by ACapellaMusic.

6 Universal Restriction and Open World Assumption

To state that members of a class can only have a specific relationship with individuals from a specific class we use a Universal (AllValuesFrom) restriction. We need to model the fact that: Any MusicCD that only has music from ACapellaMusic is a ACapellaMusicCD

  1. Create a new subclass of MusicCD called ACapellaMusicCD
  2. (With the Add button in Superclasses) create an Only (universal) restriction on this class along the containsMusic property with a filler of ACapellaMusic.

  3. Convert this class into a defined class by selecting the conditions and choosing Convert selected rows to defined class
  4. Create a ACapellaMixMusicCD as a subclass od the MusicCD.
  5. Add restrictions as in the picture: the CD should contain some GregorianChant, JewishCantillation and some MuslimAnasheed music.

  6. Classify your ontology.

Answer the questions:

  • 8-) What happens? Do you get the expected results? Is the ACapellaMixMusicCD classified as an ACapellaMusicCD?

7 Closing the classes

Why the ACapellaMixMusicCD wasn't classified as a ACapellaMusicCD, although it has only ACapellaMusic on it? Because reasoning in OWL-DL is based on the Open World Assumption:

  • Non-existence cannot be assumed, it has to be stated explicitly
  • CD could have additional kinds of music on it
  • Definitions in OWL-DL need closure axiom (to explicitly say class has only the referred restrictions)

Therefore, we need to close our MusicCD descriptions in order for them to classify correctly.

  1. Select the ACapellaMixMusicCD
  2. Create a new Only (universal) restriction along the containsMusic property. The filler will be a union of all of the music kinds on the CD – ie the union should match all of the music kinds of the existing Some (existential) restrictions using the contains property. Select Add Superclass button, then Class expression editor and type the following:

  3. Classify your ontology to check if this class classifies under ACapellaMusicCD.

  4. If you have time, repeat the experiment for other classes.p

8 DataProperties

  1. Create a DataProperty in the Data Properties tab.
  2. Set the property's domain to MusicCD, range to gYear (or other appropriate datatype if gYear isn't available), set the property as „functional”

Property Domain

Setting a domain on a property may lead to unexpected classifier results if the property is misused (eg if the domain has been over-constrained).

  1. Add a new existential restriction the the class Book saying that has to be published somewhen

  2. Run the reasoner: what happens? why?

  3. Remove the disjoint axioms and run the reasoner again. What happens now?

  4. 8-) Take a screenshot of the inconsistent hierarchy and the explanation. Then solve the problem so both MusicCDs and Books can be published in the ontology.

8-) Upload the report and the ontology file.

Control questions

  • what is Ontology?
  • what is an ontology?
  • what are the ontologies for?
  • what are the main components of an ontology?
  • what are Description Logics?
  • What are the consequences of OWL being grouned in DL?
  • What is Closed World Assumption, what Open World Assumption? Which is valid in OWL?
  • what are the reasoning tasks for a DL ontology?

If you want to know more

pl/dydaktyka/semantic_web/new-semweb-owl.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0