5. Creating a Topic Map-based Ontology

Table of Contents

Subclassing TOPIC
Constraining Topic Type
Creating a Controlled Occurrence
Creating a Controlled Name
Creating an Association-specifying slot
Subclassing Association

As we have seen in the previous sections, creating a topic map with the base ontology is relatively easy, but it is very unconstrained. It is not possible to express that a 'born-in' association must have a 'person' role and a 'place' role that should be played by topics of type 'Person' and 'Place' respecitvely. It is also a relatively long-winded operation to create an association between two topics, requiring the creation of an instance of ASSOCIATION and two new instances of MEMBER. TMTab makes use of Protégé's subclassing features to enable an ontology designer to specify constraints on both topics and associations and also provides some internal conventions which enable more convenient creation of topic names, occurrences and of associations between topics.

Subclassing TOPIC

By subclassing topic, we can create a class which constrains the characteristics of the topic objects which are generated from the instances of the derived class. These constraints include:
A fixed set of types
A controlled set of occurrences
A controlled set of names
A controlled set of roles played in associations.

When subclassing from TOPIC, it is important to be aware that you are not implicitly creating a 'typing topic', you are simply defining a set of constraints which may be applied to a class of topics. You still need to create the topic or topics which define the subclass your are providing constraints for.

Constraining Topic Type

To specify a default type of al topics of this class, simply provide a template value for the Types slot at the class level.

Example 5.1. Creating the Person Topic Class

  1. On the Instances tab, select the TOPIC class and in the Direct Instances pane, click the button marked C to create a new instance. Give this new instance the Model Name "Person".
  2. On the Classes tab, select the TOPIC class and click the button marked "C" to create a new subclass.
  3. Change the name of the subclass to "Person"
  4. Double-click on the "Types" slot of the new Person class. In the dialog that is displayed, select "View slot at class" and click OK.
  5. In the displayed dialog, click the button marked "+" over the list labelled "Template Values". In the dialog that is displayed, select "Person" (Note that you can select an instance of any class which is subclassed from TOPIC).

The procedure outlined above ensures that any instance of the Person class created in the second step will, when exported as a topic map, result in a topic which is an instance of the topic generated from the Person TOPIC instance created in the first step.

As an exercise, create a Place subclass of TOPIC and a Place topic. Constrain the Place subclass to have the Place topic as its type. Once you have done this, create and instance of the Person class for yourself and an instance of the Place class for the place where you were born.

Creating a Controlled Occurrence

You can create an constrained occurence slot for your derived topic class simply by adding a new slot which accepts as its value a single instance of the OCCURRENCE class or any class derived from OCCURRENCE. A controlled occurrence can be used for a number of reasons:
To mandate that a particular piece of information always be entered for a given class of topic.
To mandate that a particular piece of information is given a specific occurrence type.
To make it more convenient for a person creating instances of a given topic class to specify occurrences of that topic.

Example 5.2. Creating a controlled occurrence of Person

In this example we will add a "homepage" occurrence slot to the Person class

  • Create a new instance of TOPIC and give it the Model Name "Homepage"
  • Create a new subclass of OCCURRENCE and give it the class name "Homepage"
  • Select the "Homepage" class on the Classes tab and then double-click the "Types" slot
  • Choose to edit the slot at the class level
  • Add a value to the Template Values list. Select the topic named "Homepage" we created in the first step of this excercise. This means that any instance of the Homepage class will automatically be typed by the "Homepage" topic.
  • Select the "Person" class on the Classes tab and add a new slot.
  • Give the slot the name "Homepage_occ"; and set its allowed value to be an Instance and the allowed class to be the "Homepage" class.

Having completed the above steps, you should now be able to go to the Person instance you created in the previous exercise and see that the form has a new, empty slot called "Homepage occ". Click on the C button on this slot to create and add a new value. Type your homepage URL (if you don't have one, make something up!) into the "Resource Locator" slot.

Note

You will notice that the "Homepage" occurrence class actually still allows us to enter either a Resource Locator or a Resource. Ideally, we would want to prevent users from entering a value into the Resource slot. This can be easily done by modifying the form for the Homepage class to remove the Resource slot from the form, but this is beyond the scope of this tutorial. See the Protégé documentation for more details on how you can customise forms.

Creating a Controlled Name

You can create an constrained occurence slot for your derived topic class simply by adding a new slot which accepts as its value a single instance of the NAME class or any class derived from NAME. Using constrained slots for names enables you to mandate a particular scope be applied to a given name, as well as providing separately labelled slots for different names in the UI.

Example 5.3. Adding User Name to the Person topic

Lets add a slot which is used to record the person's system user name.

  • Create a new instance of the TOPIC class and give it the Model Name "User Name"
  • Create a new subclass of NAME and give it the name "User Name"
  • Select the "User Name" class on the Classes tab and then double-click the "Types" slot
  • Choose to edit the slot at the class level
  • Add a value to the Template Values list. Select the topic named "User Name" we created in the first step of this excercise. This means that any instance of the "User Name" class will automatically be typed by the "User Name" topic.
  • Select the "Person" class on the Classes tab and add a new slot.
  • Give the slot the name "User Name_occ"; and set its allowed value to be an Instance and the allowed class to be the "User Name" class.

You should now be able to return to the instance of Person and add a value for the new "User Name occ" slot.

Creating an Association-specifying slot

To make data entry more convenient, it is possible to specify slots on a TOPIC subclass which are provided for the purposes of recording the topic(s) which are associated with the current topic. Any slot which accepts an instance of TOPIC or one of its subclasses is treated as defining the other topic(s) in the association. Each such slot may be combined with up to three other slots to provide additional information. These additional information slots use the same name as the slot defining the other topics, but with an additional suffix. So, if your slot is named "EmployedBy", then:

The slot "EmployedBy_assoc" may be used to specify the TOPIC which defines the class of associations to which this association belongs.
The slot "EmployedBy_thisrole" may be used to specify the TOPIC which defines the role played by the this topic in the association.
The slot "EmployedBy_otherrole" may be used to specify the TOPIC which defines the role played in the association by the TOPIC(s) provided in the "EmployedBy" slot.

Example 5.4. Creating a works-for association

In this example, we will create a slot in which the ontology editor need only select an organisation from a list of all organisations in the ontology in order to establish a works-for relationship between the Person instance on the Organisation instance.

  • Create the 4 new instances of TOPIC with the following Model Names:
    Organisation
    Works For
    Employee
    Employer
  • Create a subclass of "TOPIC" and give it the name "Organisation"
  • Set the template value of the Types slot of the Organisation class to the "Organisation" topic created in the first step.
  • Select the Person class on the Classes tab and add a new slot. The slot should be named "Employed By"; has allowed value "Instance" and allowed classes "Organisation"
  • Add another slot to the Person class. This slot should be named "Employed By_assoc"; has allowed value "Instance"; allowed classes "TOPIC"; and the Template Value should be the "Works For" topic.
  • Add a third slot to the Person class. This slot should be named "Employed By_thisrole". This slot defines the role played in the "Works For" association by the Person instance. Give the slot the allowed value "Instance"; allowed classes "TOPIC" and template value "Employee"
  • Add one more slot to the Person class. This slot should be named "Employed By_otherrole". This slot defines the role played in the "Works For" association by the value assigned to the "Employed By" slot (in other words, the role played by the "Organisation" instance). Givethe slot the allowed value "Instance"; allowed classes "TOPIC" and template value "Employer".

You should now create an instance of the Organisation class to represent your employer. Then go to the Person instance you created for yourself and add that new instance to the "Employed By" slot. Once again, notice that although all of the other slots you just created are displayed on the form by default, they could equally well be hidden as the user cannot modify the values of those slots. See the Protégé documentation for how to customise the appearance of the form.