Semantic Web Technologies labs

The page for the lectures can be found here.

This page contains the schedule and contents of the lab exercises, part of the course Semantic Web Technologies.

Please send your solutions for the exercises by email to debruijn AT inf.unibz.it. The format for the solutions is mentioned under the heading Output for each exercise.

The exercises may be done in a group. Please indicate so when submitting the solutions for an exercise.

The lab exercises are mandatory. The exercises will be graded, and will make up 25% of the overall mark, if the average grade for the exercises is higher than the grade of the exam.

The deadline for all exercises but the last is the day before the next exercise starts; the deadline for the last exercise is 23 December, 2008.

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.

Results

Results of completed exercises

Schedule

The lab exercises will be on Fridays from 18:00-19:00 in computer room E431, from 3 October 3 until 19 December, 2008. The topics in the below schedule are subject to change.

  1. Oct 03 and 10. Your first ontology
  2. Oct 17 and 24. Querying your ontology
  3. Oct 31 and Nov 07. Extending your ontology to OWL
  4. Nov 14 and Nov 21. F-Logic Modeling and Reasoning with FLORA-2
  5. Nov 28 and Dec 05. F-Logic Implementation of RDFS
  6. Dec 12 and 19. Service Discovery with FLORA-2

1. Your first ontology

Model an ontology according to the methodology in the paper: Ontology Development 101. The domain to model is the university domain. Model universities, faculties, courses, university employees, professors, students, etc. Follow the steps in the paper for creating the ontology, and pay special attention to the competency questions in the first step of the methodology. 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.

Use the Protege tool for creating the ontology with RDFS. 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.

Protégé allows to model several features which are not present in RDFS. As these features will not be exported, when saving the project as RDF files, you should stick to the features offered by RDFS when modeling your ontology (see pages 5 and 6 of the lecture 2 slides)

Output

Make sure to create an "RDF Files" 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, as well as the list of competency questions you originally formulated in the first step of the methodology.

Reading

2. Querying your ontology

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 execute SPARQL queries. You may have to download the ARQ distribution separately to obtain the command line utilities.

Optionally, you can create a Java program for executing the queries.

Create the following queries for your ontology (both RDF and RDFS files):

Output

The output of the exercise consists of the queries in a separate file, the RDF(S) files, 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

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 combinations 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. F-Logic Modeling and Reasoning with FLORA-2

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.

Tip: use integers to model dates.

Any term starting with a question mark '?' is a variable.

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.

Output

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

Reading

5. F-Logic Implementation of RDFS

Create an F-Logic implementation of RDFS entailment. See either the RDF semantics specification or the RDF Definitions document for all the axiomatic triples and semantic conditions. You do not need to consider the semantics of literals, i.e., you may disregard the conditions 3, 4, and the second part of condition 6 in [RDF Definitions]. You may choose how the entailing and entailed graphs are represented in F-Logic.

Construct a number of tests to verify the correctness of your implementation, including at least:

  1. Test correctness of the handling of blank nodes.
  2. Test correctness of the ontology modeling functionality.
  3. Test correctness of the interaction between the axiomatic triples and the semantic conditions.
  4. Test that the following graph is entailed by the empty graph:
  5. rdf:_1 rdfs:domain rdfs:Resource .
    rdf:_4 rdf:type rdfs:ContainerMembershipProperty .
    rdf:XMLLiteral rdf:type rdfs:Class .
    rdf:XMLLiteral rdf:type rdfs:Resource .
    	

Tip: use the :- iriprefix directive to define prefixes and use compact URIs in the implementation. See section 25.2 of the FLORA-2 manual. An example:

      :- iriprefix ex = "http://example.org/example".
      ex#john[rdf#type -> ex#person].
    

Output

  1. Source code of the implementation.
  2. Sources of the tests.

Reading

6. Service Discovery with FLORA-2

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. Extend the categories if necessary.
  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 the goal created in step 1.

Output

  1. the extended services.flr

Reading