Semantic Web Technologies labs

The page for the lectures can be found here.

This page contains the exercises for the labs which are on Wednesdays from 14:00 - 16:00 in computer room E331.

Please send your solutions for the exercises by email to jos.debruijn AT deri.org by the next Tuesday. The format for the solutions is mentioned under the heading Output for each exercise.

The goal of the lab exercises is to give you hands-on experience in using Semantic Web Technologies. The tools we use in the labs are Protege, an ontology modeling tool, Jena, a Java framework for RDF and OWL, and FLORA-2, an F-Logic reasoner based on XSB.

Contents

  1. Your first ontology
  2. Querying your ontology
  3. Extending your ontology to OWL
  4. Manipulating your ontology with Jena
  5. F-Logic Modeling and Reasoning with FLORA-2
  6. Information Integration with FLORA-2
  7. Service Discovery with FLORA-2

1. Your first ontology (26 April 2006)

Use Protege to model an ontology. The domain to model is the university domain. Model universities, faculties, courses, university employees, professors, students, etc. Make sure to include also some instance information; include at least the university of Bolzano, yourself, a number of courses and a number of professors you know at the university, and the relations between them.

Save the project as RDF files and have a look inside. You will see an RDFS file which contains the ontology and an RDF file which contains the instance data.

Output

Make sure to create an "RDF" project in Protege. The output consists of all the files generated by Protege.
Make sure to select "plain RDF" when saving the project.

The output of the exercise consists of the RDF and RDFS files included in the project.

Reading

2. Querying your ontology (3 May 2006)

Use Jena to query your ontology. Find a simple introduction into using Jena to query SPARQL here.

You can use the ARQ command line utilities to test SPARQL queries. You may have to download the ARQ distribution separately to obtain the command line utilities.

Create a Java application to query your ontology (both RDF and RDFS files). Issue (variants of) the following queries:

Output

The output of the exercise consists of the java sources which you used to query the ontology, the queries in a separate file and RDF data and, finally, a file containing the query results. Please include some comments in the query files to indicate what the query is meant to do.

Reading

3. Extending your ontology to OWL (10 May 2006)

Use the OWL functionality of Protege to extend your ontology with constraints and Boolean class combinations.

In order to use the full OWL functionality of Protege, follow the following steps:

  1. Open your RDFS ontology
  2. Choose File -> Export to Format -> OWL to export your ontology in OWL format.
  3. Close your project
  4. Create a new project of type OWL Files and make sure to check the box Create from Existing Sources.
  5. Select the OWL file which you exported
  6. As default namespace choose http://example.org/name-of-ontology#.
  7. Choose the language profile OWL DL.
  8. Choose the Logic View

Extend the universities using property restrictions and boolean conclusions as you see fit. Make sure you use at least some cardinality restrictions, some existential and universal restrictions and some boolean combinations.

Output

The OWL files of the ontology.

Reading

4. Manipulating your ontology with Jena (17 May 2006)

Use the Jena 2 ontology API to manipulate your ontology using a Java program:

Output

  1. Java sources of the program
  2. OWL and RDF files used as input
  3. Output OWL file

Reading

5. F-Logic Modeling and Reasoning with FLORA-2 (24 May 2006)

Create an F-Logic ontology and use FLORA-2 to reason over this ontology. Consult the FLORA-2 manual to check the actual syntax and the commands to use for loading F-Logic files into FLORA-2 and executing these queries.

Model the following information using FLORA-2 F-Logic syntax:

Write queries to check the following:

Make sure the programs use the extension flr, e.g. myOntology.flr. Load the program in flora using flLoad myOntology. Execute query by entering the body of the query, following by a dot '.', e.g. ?- X:person.

Any term starting with a capital is a variable! Object identifiers start with a lower-case letter!

End every fact and every rule with a dot '.'!

Find an example program here. Queries you might want to try are ?- X:person. and ?- X:singleParent. Find example output for the query ?- X:person. here

Output

  1. FLORA-2 program
  2. A separate file for each query with the query and the answers

Reading

6. Information Integration with FLORA-2 (31 May 2006)

Use FLORA-2 to create mappings between ontologies in an information integration scenarion. You are provided with one central ontology, without instance data, and two local ontologies which contain instance information (see Figure 1 for an overview). Your task is to implement mappings between the local ontologies and the global ontology.


Figure 1: Global and local ontologies


In detail, do the following:

  1. import the cars, carsmanufacturing, and carssales ontologies in the main module and the modules carsmanufacturing, and carssales, respectively. You can load a file in a particular module using flora2 ?- [file>>modulename]. You can load a file in the main module using flora2 ?- flLoad file..
  2. create a file mapping.flr which contains the mapping rules from the local ontologies to the global ontology. Use @modulenameafter a molecule to indicate the module. For example: X:car :- X:car@cars-sales. specifies a mapping between the class 'cars' in the modules cars-sales, to the class 'cars' in the module cars.
  3. Query the global ontology for all cars, with all part, all customers and the size of the cars. Make sure this includes also all smallCars and all bigCars.

Output

  1. mapping.flr
  2. A separate file for each query with the query and the answers

Reading

7. Service Discovery with FLORA-2 (6 June 2006)

Use FLORA-2 to model ontologies and services and implement a simple discovery mechanism. A simple services ontology in which services and goals can be described using categories and preconditions/effects can be found here.

The example file also contains services categories in the areas of book selling and computer selling. Additionally, a number of preconditions and effects are given. For simplicity, conditions are simply constants organized in a hierarchy using ::.

The example file additionally contains an example goal description and an example service description, as well as a simple matching mechanism based on categories. You will see that the example goal and service match.

Assignment

  1. Create a service and a goal description which do not match using the simple category mechanism.
  2. Implement a matching mechanism based on preconditions and effects such that if the precondition of the goal is a subclass of the precondition of the service and the effect of the service is a subclass of the effect of the goal, then the service and the goal match.
  3. You will see that the example service and goal do not match using this new matching mechanism. Create two service descriptions with different preconditions and effects which both match with either the example goal or the goal created in step 1.

Output

  1. the extended services.flr

Reading