MappingOntology

From Protege Wiki
Revision as of 15:07, June 23, 2014 by TaniaTudorache (talk | contribs) (Created page with "= Mapping Ontology = Prompt saves the mappings in a mapping ontology developed over the years at SMI. (Contributors include John Park, John Gennari, and Monica Crubezy). Here...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Mapping Ontology

Prompt saves the mappings in a mapping ontology developed over the years at SMI. (Contributors include John Park, John Gennari, and Monica Crubezy). Here are some tips on representing complex mapping in this ontology.

Specifying a conditional mapping

Conditions are evaluated in a language. The default language is TCL. To use Python as the language, prefix the condition with <LANG:PYTHON> (7SU)

The default condition is t If you want a more complex condition, such as mapping a person to another class depending on age, you need to do a more complex condition, such as (7T1)

<LANG:PYTHON> *<Person:age>* > 65    (7SV)

Note two things: (7SW)

  • as always, the *< ... >* syntax is a string replacement for the actual value. (7SX)
  • this is a numerical comparison. Which means Person:age should be a number, otherwise the interpreter will throw an error (7SY)

There is a subtlety here when you want to do string comparisons: strings should be quoted in Python. So, if you want to do a string operation, you should quote the replacement value: <LANG:PYTHON> '*<Person:name>*' != 'Bob' (7SZ)

Note well: PYTHON means Jython. Latest version of Jython, as of this writing, is equivalent to Python 2.1


Map a relationship i.e. map an object propert

Relationship mapping is a direct use of the recursive slot mapping. The recursive slot mapping goes from the relationship slot in the source ontology to the equivalent relationship slot in the target ontology. The recursive instance map should be the mapping that converts the type on the range end of the object relationship. (83C)

For example: in ontology A we have Person ‘drives’ Car and in ontology B we have Employee ‘uses’ Vehicle (83D)

There are two instance maps: Person to Employee (P2E) and Car to Vehicle (C2V). The P2E map is associated to a recursive slot map that maps ‘drives’ to ‘uses’. The recursive instance map is C2V. (83E)

An example of a relationship mapping can be found here: (83F)

  • XXXXX conditional mapping based on object property (link) existence


Splitting a class into two classes with a link between them

Note: At the time of writing, PROMPT itself is lacking some of the power of the underlying mapping ontology. So, in our descriptions here, we will assume that you are editing the mapping ontology directly, either because you are a masochist, or because I haven't had time to add more user-friendly operations to the PROMPT interface. (7MM)

One of the simple kinds of changes you might make when editing an ontology is to take one class (say, Person) and create a new class based on some attribute. (7MN)

Our example has a Person class in one ontology with the attributes (name, car). The new ontology (imaginitively called PersonCar) has the class Person(name, drives) and Car(model). The Person.drives attribute is an object attribute (also known as a link) 'drives', which points to Car. (7MO)

The tools that PROMPT provides for mapping are the following: (7MP)

  • slot mapping (the terminology for mapping attributes) (7MQ)
    • renaming slot mapping (7MR)
    • functional slot mapping (7MS)
    • constant slot mapping (7MT)
    • lexical slot mapping (7MU)
    • recursive slot mapping (7MV)
  • instance mapping (this is how one class is mapped to another class) (7MW)

There is no obvious way to create new classes or to create links. This is mostly due to a terminology issue, however. (7MX)

To map Person to Person, you create a new instance mapping. To map the 'name' attribute, all you have to do is create a new 'renamingSlotMapping' and add it to the Person instance mapping. (7MY)

To create the Car object, based on the Person.car attribute, you add a 'recursive slot mapping' from '<SELF>' to 'drives'. You then create a new instance mapping (as a child of the recursive slot mapping) that maps Person to Car, which has a renaming slot mapping to map 'car' to 'model'. (7MZ)

The trick here is the '<SELF>' syntax. What this means is that the mapping for the Person class will be placed in the object property 'drives'. Note that this Person mapping (the Person-to-Car instance mapping) should have the 'on-demand' checkbox marked. This means that this mapping will only be executed when the recursive slot mapping (from <SELF> to drives) is executed. If this box is not checked, then this mapping will end up being executed twice: once for every Person, and once for every recursive slot mapping for the 'drives' target slot. (7N0)

This trick also works for creating new classes that have multiple slots that are all required to create a unique Car object. The compound example shows an example of this where Car has the key attributes 'model' and 'year'.