Custom properties

In this section a transportation ontology (called trans) is used to illustrate the mechanism to add custom properties. Two properties, beyond the standard ones in tOKo, are defined: hasNoWheels and canTransport. These properties allow statements such as "A bicycle has two wheels" and "A train can transport a bicycle" to be represented.

Two steps are required to make custom properties available to the user of an application: (1) Defining the properties in RDFS; (2) Adding buttons for the properties to the user interface.

Defining the properties

Each application defines a set of meta-classes in the file trans_meta.rdfs (if the application is called trans). This file is automatically created with the application. The two properties required for the transportation ontology are given below:

<rdf:Property rdf:about="&trans;hasNoWheels"
    rdfs:comment="Number of wheels"
    rdfs:label="hasNoWheels">
  <rdfs:domain rdf:resource="&trans;TRANS_Class"/>
  <rdfs:range rdf:resource="&rdfs;Literal"/>
  <rdfs:subPropertyOf rdf:resource="&trans;property"/>
</rdf:Property>

<rdf:Property rdf:about="&trans;canTransport"
    rdfs:comment="Subject can transport the object"
    rdfs:label="canTransport">
  <rdfs:domain rdf:resource="&trans;TRANS_Class"/>
  <rdfs:range rdf:resource="&trans;TRANS_Class"/>
  <rdfs:subPropertyOf rdf:resource="&trans;property"/>
</rdf:Property>

Note that hasNoWheels has an rdfs:range that is a literal and canTransport a range that is any other trans concept. The line with subPropertyOf tells tOKo it should display the property value on the terminology tab.

The custom property definitions are normally added to trans_meta.rdfs.

Buttons for the properties

The default toolbar contains buttons to create sub-concepts, define synonyms and so forth. The buttons for custom properties are defined in the knowledge base for the application (trans_fill.xml). Examples of button definitions are:

  <button name="button for hasNoWheels">
    <property name="trans:hasNoWheels"/>
    <icon colour="green" shape="circle" tooltip="Number of wheels"/>
  </button>

  <button name="button for canTransport">
    <property name="trans:canTransport"/>
    <icon src="canTransport.xpm" tooltip="Add property: canTransport"/>
  </button>

The name given with property corresponds to the property as defined in the meta definition. The icon can either be a simple shape (circle or box) with a coloured interior or an image (16x16 pixels in either gif, jpeg or XPM format). Icons should be stored in the icons directory of the application.

User interface

The user interface for defining custom properties is precisely the same as that for the built-in properties:

  1. Select the concept for which a property value is to be defined in the ontology.
  2. Enter the value into the selection box.
  3. Click the button for the property.

The screenshot shows the two buttons added at the upper right and the terminology tab after stating that a "train hasNoWheels > 10" and "train canTransport bicycle".