Ontology-based modelling and querying

 

Part 1: Ontology-based modelling

The purpose of this lab is to give you with the basics of ontology modelling using Protégé tool.  The main goal is to design the ‘family’ ontology, create individuals and infer new relations.

1. Classes and subclasses

The first step is to design classes and subclasses of family ontology according to the following figure (Fig.1):

familyImage

Fig. 1 : Family ontology

Remark: to declare a class C as subclass of two classes A and B, you have to add A and B in asserted condition box (with Logic View)

2. Class properties

1.       Datatype properties (Fig. 2): create the properties  name, age and nationality of a person in properties tab which are single properties (functional)

    1. create a datatype property name with domain Person and range xsd:string
    2. create a datatype property age with domain Person range xsd:int
    3. create a datatype property nationality with domaine Person and range xsd:string
  1. Object properties (Fig. 3): create the 11 following properties:
    1. Create an object property isMarriedWith with Person as domain and range

Fig. 2: DataType properties

b.      A person is parent of another person

                                                              i.      Create the object property isParentOf with Person as domain and range

    1. A Male is father of person

                                                              i.      Create the object property isFatherOf which is sub property of isParentOf with domain Male and range Person

    1. A Female is mother of person

                                                              i.      Create the object property isMotherOf which is sub property of isParentOf with domain Female and range Person

    1. A person belongs to another person’s siblings

                                                              i.      Create the object property isSiblingOf with domain Person and range Person

    1. A man is the brother of a person

                                                              i.      Create the object property isBrotherOf which is sub property of isSiblingOf with domain Male and range Person

    1. A Female is the sister of a person

                                                              i.      Create the object property isSisterOf which is sub property of isSiblingOf with domain Female and range Person

    1. A person is a child of another person

                                                              i.      Create the object property isChildOf with domain Person and range Person

    1. A Male is the son of a person

                                                              i.      Create the object property isSonOf which is sub property of isChildOf  with domain Male and range Person

    1. A woman is the daughter of a person

                                                              i.      Create the object property isDaughterOf which is sub property of isChildOf  with domain Female and range Person

Fig. 3 : Object property

3. Class and properties restrictions

NECESSARY AND SUFFICIENT CONDITION :

·         An uncle has the restriction : is brother of a parent

Fig. 4 : Sister class restriction

DISJOINTS CLASSES: (in Disjoint boxes)

·         Male and Female are disjoints

4. Assign types to properties

·         iMarriedWith and isSiblingOf properties are  symmetric

5. Individuals

1.       create individuals to Male class :

    1. Peter, 70, isMarriedWith Marie. He is French
    2. Thomas, 40, isSonOf Peter. He is French
    3. Paul, 38 isSonOf Peter
    4. John, 45, is italian
    5. Pedro, 10, isSonOf John
    6. Tom, 10, isSonOf Thomas and Alex
    7. Michael, 5, isSonOf Thomas and Alex
  1. create individuals to Female class :
    1. Marie, 69, french
    2. Sylvie, 30, isDaughterOf Marie and Peter
    3. Chloé, 18, isDaughterOf Marie and Peter
    4. Sylvie isMarriedWith John
    5. Claude, 5, isDaughterOf Sylvie, french
    6. Alex, 25, isMarriedWith Thomas

6. Check ontology consistency with PELLET

1.       configure the inference engine,  menu : OWL/Preferences/Reasoner URL -> http://localhost:8081

  1. Extract pellet-2.3.0.zip.
  2. Execute LaunchServer.bat to launch the pellet server
  3. Check consistency  menu  OWL/Check Consistency
  4. Infer instances of the following classes Person, Uncle, Son, Sister, Grandparent, Grandfather, Grandmother; check the instances generated automatically in the classes Person, Grandparent, Grandfather, Grandmother.  No individual is generated in the classes Brother, Sister and Uncle. Why? How to infer for example the relations isBrotherOf or isSister starting from childOf?

 

In the next Lab (Lab 3), we will see how to express these kinds of restrictions using a rule language. Indeed, inference rules will solve this problem.


Part 2: SPARQL queries

  1. Execute this java program (java –jar tpjena_fat.jar).
  2. Load the family ontology (owl) that you created in part 1.
  3. Write the following queries by checking with OWL inference:

1.      How old is Peter?

2.       Who are Sylvie’s parents?

3.       The women over 30 years?

4.       What are the instances of Person?

 

 

Example of a SPARQL query:

PREFIX ns: <...#>

SELECT <variable>

WHERE{

<triplet>.

<triplet>.

<fonction>.

}

 

Prefix defines the used namespaces.

? is used to denotes variables (example ?age)

 

Details about SPARQL can be found at: http://jena.sourceforge.net/ARQ/Tutorial/

Part 3: query dbpedia.org

Open the public SPARQL endpoint: http://dbpedia.org/snorql/ and test the following query to get information related to the resource http://dbpedia.org/resource/Thomas_Edison

SELECT ?property ?hasValue ?isValueOf

WHERE {

  { <http://dbpedia.org/resource/Thomas_Edison> ?property ?hasValue }

  UNION

  { ?isValueOf ?property <http://dbpedia.org/resource/Thomas_Edison> }

}

 

Based on the dbpedia page of Thomas Edison http://dbpedia.org/page/Thomas_Edison, the results of the previous query and using the following public SPARQL endpoint: http://dbpedia.org/snorql/, specify and test the following queries:

1.       On what date was Thomas Edison Born?

2.       What date did Edison Die?

 

Other queries:

1.       US Presidents born in XXth Century

Note: use ?President rdf:type <http://dbpedia.org/class/yago/PresidentsOfTheUnitedStates>.

2.       US Presidents born in XXth Century and if available their death date.

3.       List the American recipients of MacArthur Fellowships.