124
Tools & Frameworks for the Semantic Web Semantic Web - Fall 2005 Computer Engineering Department Sharif University of Technology

Tools & Frameworks for the Semantic Web

Embed Size (px)

DESCRIPTION

Tools & Frameworks for the Semantic Web. Semantic Web - Fall 2005 Computer Engineering Department Sharif University of Technology. Outline. Jena A Semantic Web framework Sesame An architecture for storing and querying RDF data. Protégé - PowerPoint PPT Presentation

Citation preview

Page 1: Tools & Frameworks for the Semantic Web

Tools & Frameworksfor the Semantic Web

Semantic Web - Fall 2005

Computer Engineering Department

Sharif University of Technology

Page 2: Tools & Frameworks for the Semantic Web

Outline Jena

A Semantic Web framework Sesame

An architecture for storing and querying RDF data.

Protégé An environment for creating and editing

ontologies and knowledge bases.

Page 3: Tools & Frameworks for the Semantic Web

Jena

Page 4: Tools & Frameworks for the Semantic Web

Introduction Jena is a Java framework for building

Semantic Web applications. Jena is open source software developed in

HP Labs. The Jena framework includes:

A RDF API Reading and writing RDF in RDF/XML, N3 and N-

Triples An OWL API In-memory and persistent storage RDQL support

Page 5: Tools & Frameworks for the Semantic Web

Jena Versions Two versions:

Jena 1 Expressive support for RDF Limited reasoning facilities (RDQL)

Jena 2 Ontology API included Support for OWL included

Page 6: Tools & Frameworks for the Semantic Web

RDF Model

Resource: Anything that can be described with an RDF

expression. Property:

Trait, attribute or relation used to describe a resource.

Literal: Simple data type (String, Integer, etc).

Statement: Resource, united with the property and its associated

value. An RDF Model is a set of statements.

Page 7: Tools & Frameworks for the Semantic Web

RDF API of Jena

Allows creating and manipulating RDF Models from Java applications.

Provides Java classes to represent: Models. Resources. Properties. Literals. Statements.

Page 8: Tools & Frameworks for the Semantic Web

Example: vcards

Page 9: Tools & Frameworks for the Semantic Web

Create an RDF ModelString personURI = "http://somewhere/JohnSmith";

String givenName = "John";

String familyName = "Smith";

String fullName = givenName + " " + familyName;

// create an empty model

Model model = ModelFactory.createDefaultModel();

Resource johnSmith = model.createResource(personURI);

johnSmith.addProperty(VCARD.FN, fullName);

johnSmith.addProperty(VCARD.N, model.createResource()

.addProperty(VCARD.Given, givenName)

.addProperty(VCARD.Family, familyName));

Page 10: Tools & Frameworks for the Semantic Web

Writing and Reading the Model

To serialize the model in XML:

model.write(System.out);

To load a model in the memory:

Model model = ModelFactory.createDefaultModel();

model.read(“file:c:/example.owl”);

Page 11: Tools & Frameworks for the Semantic Web

Navigating the Model Getting information via the URI of the

resource:

// retrieve the resource John SmithString johnSmithURI = "http://somewhere/JohnSmith";Resource jSmith = model.getResource(johnSmithURI);

// retrieve the value of the property NResource name = (Resource) jSmith.getProperty(VCARD.N) .getObject();

// retrieve the value of the property FNString fullName = (String) jSmith.getProperty(VCARD.FN) .getObject();

Page 12: Tools & Frameworks for the Semantic Web

Referring to a Model Searching information in a model:

// retrieve all the resources of the type vcard // (assuming that all such resources have a property FN)ResIterator it = model.listSubjectsWithProperty(VCARD.FN);while (it.hasNext()) { Resource r = it.nextResource(); System.out.println(r);}

More advanced querying: Use of construction listStatements(Selector s). Use of RDQL.

Page 13: Tools & Frameworks for the Semantic Web

Operations on Models A model is a set of statements. Support of the following operations:

Union. Intersection. Difference.

// reading the RDF models

model1.read(new InputStreamReader(in1), "");

model2.read(new InputStreamReader(in2), "");

// unifying RDF models

Model model = model1.union(model2);

Page 14: Tools & Frameworks for the Semantic Web

Ontology API of Jena Supports RDF Schema, DAML, DAML+OIL

and OWL. Language independent.

Page 15: Tools & Frameworks for the Semantic Web

Example: Camera Ontology

Page 16: Tools & Frameworks for the Semantic Web

Creation of an Ontology Model Use of method createOntologyModel(). Possible to specify:

Used language. Associated reasoning.

String fileName = "c:/ejemplo.owl";

String baseURI = "file:///" + fileName;

OntModel model =

ModelFactory.createOntologyModel(ProfileRegistry.OWL_DL_LANG);

model.read(new FileReader(schemaFileName), baseURI);

Page 17: Tools & Frameworks for the Semantic Web

Classes Classes are basic construction blocks. Represented as OntClass.

Example: Obtain subclasses of class Camera.

OntClass camera = model.getOntClass(camNS + "Camera");

for (Iterator i = camera.listSubClasses(); i.hasNext();) {

OntClass c = (OntClass) i.next();

System.out.println(c.getLocalName());

}

Page 18: Tools & Frameworks for the Semantic Web

Properties Represented via OntProperty.

OntModel m = ModelFactory.createOntologyModel();

OntClass Camera = m.createClass(camNS + "Camera");

OntClass Body = m.createClass(camNS + "Body");

ObjectProperty part = m.createObjectProperty(camNS + "part");

ObjectProperty body = m.createObjectProperty(camNS + "body");

body.addSuperProperty(part);

body.addDomain(Camera);

body.addRange(Body);

Page 19: Tools & Frameworks for the Semantic Web

Complex Classes It is possible to define classes by means of

operations for union, intersection, difference.

Example:<owl:Class rdf:ID="SLR"> <owl:intersectionOf rdf:parseType="Collection"> <owl:Class rdf:about="#Camera"/> <owl:Restriction> <owl:onProperty rdf:resource="#viewFinder"/> <owl:hasValue rdf:resource="#ThroughTheLens"/> </owl:Restriction> </owl:intersectionOf></owl:Class>

Page 20: Tools & Frameworks for the Semantic Web

// create instance throughTheLensOntClass Window = m.createClass(camNS + "Window");Individual throughTheLens =

m.createIndividual(camNS + "ThroughTheLens", Window);

// create property viewfinderObjectProperty viewfinder =

m.createObjectProperty(camNS + "viewfinder");

// create restriction hasValueHasValueRestriction viewThroughLens =

m.createHasValueRestriction(null, viewfinder, throughTheLens);

// create class CameraOntClass Camera = m.createClass(camNS + "Camera");

// create intersection for defining class SLRIntersectionClass SLR = m.createIntersectionClass(camNS + "SLR", m.createList(new RDFNode[] {viewThroughLens, Camera}));

Page 21: Tools & Frameworks for the Semantic Web

Schema vs Instance Data Schema

Possible to define: Classes Properties (DataTypeProperty, ObjectProperty) Restrictions

Types of Data Cardinality

Instance Data Defining instances (individuals) of the Schema

elements.

Page 22: Tools & Frameworks for the Semantic Web

<owl:Class rdf:ID="Camera"> <rdfs:subClassOf rdf:resource="#Item"/> </owl:Class><owl:DatatypeProperty rdf:ID="name"> <rdfs:domain rdf:resource="#Camera"/> <rdfs:range rdf:resource=“xsd:string"/></owl:DatatypeProperty>

<camera:Camera rdf:ID="camera1"><camera:name>Kodak</

camera:name> </camera:Camera>

Page 23: Tools & Frameworks for the Semantic Web

Managing Instance Data

URI = http://test/camera/#CameraOntClass c = model.getOntClass(URI +#Camera")OntProperty p = model.getOntProperty(URI +#name")

Individual ind = model.getIndividual(URI +#camera1")if (ind.hasProperty(p))

Statement st = ind.getProperty(p);Object l = (Object)st.getObject();

Page 24: Tools & Frameworks for the Semantic Web

Managing Instance Data Other operations:

model.listIndividuals() Returns all instances of the model

individual.hasProperty(Property p,Object o) Returns True if there is an individual having property p

with value o ontClass.listInstances();

Returns all instances of the class

Page 25: Tools & Frameworks for the Semantic Web

Jena Inference Support Inference Deduce additional information

The task of inferencing is carried out by reasoners

Jena comprises a set of basic reasoners OWL Reasoner DAML Reasoner RDF Rule Reasoner Generic Rule Reasoner

There is a way to include new reasoners For example:

(?A rdfs:subClassOf ?B) (?B rdfs:subClassOf ?C)

(?A rdfs:subClassOf ?C)

Page 26: Tools & Frameworks for the Semantic Web

Jena Inference Support

To reason, an Inference Model should be created

Example:Reasoner reasoner = ReasonerRegistry.getOWLReasoner();reasoner = reasoner.bindSchema(schema);InfModel modelInf = ModelFactory.createInfModel(reasoner,data);

Page 27: Tools & Frameworks for the Semantic Web

Ontology Validation in JenaModel schema = ModelLoader.loadModel("file:c:/Schema.owl");Model data = ModelLoader.loadModel("file:c:/example.owl");Reasoner reasoner = ReasonerRegistry.getOWLReasoner();reasoner = reasoner.bindSchema(schema);InfModel modelInf = ModelFactory.createInfModel(reasoner, data);

ValidityReport vrp1 = modelInf.validate();if (vrp1.isValid()){

System.out.println(“Valid OWL");}else {

System.out.println(“Not valid OWL");for (Iterator i = vrp1.getReports(); i.hasNext();){

System.out.println(" - " + i.next()); }

Page 28: Tools & Frameworks for the Semantic Web

<camera:Camera rdf:ID="camera1"><camera:name>KODAK</camera:name>

</camera:Camera><owl:DatatypeProperty rdf:ID="name"> <rdfs:domain rdf:resource="#Camera"/>

<rdfs:range rdf:resource=“xsd:integer"/></owl:DatatypeProperty>

Error (range check): Incorrectly typed literal due to range (prop, value)

Culprit = http://www.xfront.com/owl/ontologies/camera/#camera1

Implicated node: http://www.xfront.com/owl/ontologies/camera/#name

Implicated node: 'KODAK‘

Page 29: Tools & Frameworks for the Semantic Web

<owl:Class rdf:ID="Camera"><rdfs:subClassOf> <owl:Restriction>

<owl:onProperty rdf:resource="#name" /> <owl:maxCardinality rdf:datatype=“xsd:nonNegativeInteger">1</owl:maxCardinality>

</owl:Restriction> </rdfs:subClassOf></owl:Class><camera:Camera rdf:ID="camera1">

<camera:name>KODAK</camera:name><camera:name>OLIMPUS</camera:name>

</camera:Camera>

Error (too many values): Too many values on max-N property (prop, class)Culprit = http://www.xfront.com/owl/ontologies/camera/#camera1Implicated node: http://www.xfront.com/owl/ontologies/camera/#nameImplicated node: http://www.xfront.com/owl/ontologies/camera/#Camera

Page 30: Tools & Frameworks for the Semantic Web

RDQL q1 contains a query:

SELECT ?x

WHERE (?x <http://www.w3.org/2001/vcard-rdf/3.0#FN> "John Smith")

For executing q1 with a model m1.rdf:

java jena.rdfquery --data m1.rdf --query q1

The outcome is:

x

=============================

<http://somewhere/JohnSmith/>

Page 31: Tools & Frameworks for the Semantic Web

Using RDQL from Java Code It is possible to run RDQL queries from the

Java application. The following classes are to be used for

this: Query QueryExecution QueryEngine QueryResults ResultBinding

Page 32: Tools & Frameworks for the Semantic Web

RDQL ExampleSELECT ?x, ?fname

WHERE (?x <http://www.w3.org/2001/vcard-rdf/3.0#FN> ?fname)

Query query = new Query("SELECT...") ;

query.setSource(model);

QueryExecution qe = new QueryEngine(query) ;

QueryResults results = qe.exec();

for (Iterator iter = results; iter.hasNext();)

{

ResultBinding res = (ResultBinding) iter.next();

Resource x = (Resource) res.get("x");

Literal fname = (Literal) res.get("fname");

System.out.println("x: " + x + " fname: " + fname);

}

Page 33: Tools & Frameworks for the Semantic Web

Persistent Models Jena permits to create persistent models:

such as with relational databases. Jena 2 supports:

MySQL Oracle PostgreSQL

To create a persistent model: ModelFactory.createModelRDBMaker(conn).createModel()

Page 34: Tools & Frameworks for the Semantic Web

Example// Create a connection to DB

DBConnection c = new DBConnection(DB_URL, DB_USER, DB_PASS, DB_TYPE);

// Create a ModelMaker for persistent models

ModelMaker maker = ModelFactory.createModelRDBMaker(c);

// Create a new model

Model model = maker.createModel("modelo_1");

// Start transaction

model.begin();

// Read a model from an XML archive

model.read(in, null);

// Commit a transaction

model.commit();

Page 35: Tools & Frameworks for the Semantic Web

Sesame

When they were out of sight Ali Baba came down, and, going up to the rock, said, "Open, Sesame.“

--Tales of 1001 Nights

Page 36: Tools & Frameworks for the Semantic Web

Querying Levels RDF documents can be considered at three

different levels of abstraction:1. At the syntactic level they are XML documents.2. At the structure level they consist of a set of triples.3. At the semantic level they constitute one or more

graphs with partially predefined semantics.

Querying at what level is the best?

Page 37: Tools & Frameworks for the Semantic Web

Querying at the Syntactic Level In this level we just have an XML document. So we can Query RDF using an XML query

language. (e.g. XQuery) But RDF is not just an XML dialect.

XML: Has a tree structure data model. Only nodes are labeled.

RDF: Has a graph structure data model. Both edges (properties) and nodes (subjects/objects) are

labeled. Different ways of encoding the same information

in XML are possible.

Page 38: Tools & Frameworks for the Semantic Web

Querying at the Structure Level In this level RDF document represents a

set of triples: (type, Book, Class) (subClassOf, FamousWriter, Writer) (hasWritten, twain/mark, ISBN00023423442) (type, twain/mark, FamousWriter)

Advantage: Independent of the specific XML syntax.

A successful query: SELECT ?x FROM … WHERE (type ?x FamousWriter)

An unsuccessful query: SELECT ?x FROM … WHERE (type ?x Writer)

Page 39: Tools & Frameworks for the Semantic Web

Querying at the Semantic Level We need a query language that is sensitive to the

RDF Schema primitives: e.g. Class, subClassOf, Property, …

RQL RDF Query Language The first proposal for a declarative query language for

RDF and RDF Schema. Output of queries is again legal RDF schema code, which

can be used as input of another query. A sample query:

SELECT Y FROM FamousWriter {X}. hasWritten {Y}

Page 40: Tools & Frameworks for the Semantic Web

Sesame – Introduction & History Sesame: An Architecture for Storing and

Querying RDF Data and Schema Information. The European On-To-Knowledge project kicked

off in Feb. 2000: This project aims at developing ontology-driven

knowledge management tools. In this project Sesame fulfills the role of storage and

retrieval middleware for ontologies and metadata expressed in RDF and RDF Schema.

Page 41: Tools & Frameworks for the Semantic Web

On-To-Knowledge Project Sesame is positioned as a central tool in this project. OntoExtract: extracts ontological conceptual structures

from natural-language documents. OntoEdit: An ontology editor. RDF Ferret: A user front-end, that provides search and

query.

RDF Ferret

OntoExtract

Sesame OntoEdit

Page 42: Tools & Frameworks for the Semantic Web

What is Sesame? Sesame is an open source Java framework for

storing, querying and reasoning with RDF and RDF Schema.

It can be used as: Standalone Server: A database for RDF and RDF

Schema. Java Library: For applications that need to work with

RDF internally.

Page 43: Tools & Frameworks for the Semantic Web

Sesame’s Architecture

Repository

Repository Abstraction Layer (RAL)

Admin Module Export ModuleQuery Module

HTTP Protocol Handler SOAP Protocol Handler

Sesa

me

SO

AP

HTTP

Page 44: Tools & Frameworks for the Semantic Web

The Repository DBMSs

Currently, Sesame is able to use PostgreSQL MySQL Oracle (9i or newer) SQL Server

Existing RDF stores RDF flat files RDF network services

Using multiple sesame server to retrieve results for queries.

This opens up the possibility of a highly distributed architecture for RDF(S) storing and querying.

Page 45: Tools & Frameworks for the Semantic Web

Repository Abstraction Layer (RAL) RAL offers stable, high-level interface for talking

to repositories. It is defined by an API that offers these

functionalities: Add data Retrieve data Delete data

Data is returned in streams. (Scalability) Only small amount of data is kept in memory. Suitable for use in highly constrained environments such

as portable devices. Caching data (Performance)

E.g. caching RDF schema data which is needed very frequently.

Page 46: Tools & Frameworks for the Semantic Web

Stacking Abstraction Layers

Page 47: Tools & Frameworks for the Semantic Web

Admin Module Allows incrementally inserting or deleting RDF data in/from

repository. Retrieves its information form an RDF(S) source Parses it using an RDF parser Checks each (S, P, O) statement it gets from the parser for

consistency with the information already present in the repository and infers implied information if necessary for instance: If P equals type, it infers that O must be a class. If P equals subClassOf, it infers that S and O must be classes. If P equals subPropertyOf, then it infers that both S and O

must be properties. If P equals domain or range, then it infers that S must be a

property and O must be a class.

Page 48: Tools & Frameworks for the Semantic Web

Query Module Evaluates RQL queries posed by the user It is independent of the underlying repository. So

it can not use optimizations and query evaluations offered by specific DBMSs.

RQL queries are translated into a set of calls to the RAL. e.g. when a query contains a join operation over two

subqueries, each of the subqueries is evaluated, and the join operation is then executed by the query engine on the results.

Page 49: Tools & Frameworks for the Semantic Web

RDF Export Module This module allows for the extraction of the

complete schema and/or data from a model in RDF format.

It supplies the basis for using Sesame with other RDF tools.

Page 50: Tools & Frameworks for the Semantic Web

Important Features of Sesame Powerful query language Portability

It is written completely in Java. Repository independence Extensibility

Other functional modules can be created and be plugged in it.

Flexible communication by using protocol handlers The architecture separates the communication details

from the actual functionality through the use of protocol handlers.

Page 51: Tools & Frameworks for the Semantic Web

SeRQL (Sesame RDF Query Language) It combined the best features of other

query languages: RQL, RDQL, N-Triples, N3 Some of the built-in predicates:

{X} serql:directSubClassOf {Y} {X} serql:directSubPropertyOf {Y} {X} serql:directType {Y}

Page 52: Tools & Frameworks for the Semantic Web

Using PostgreSQL as Repository PostgreSQL is an open-source object-relational

DBMS. It supports subtable relations between its tables. Subtable relations are also transitive. These relations can be used to model the

subsumption reasoning of RDF schema.

Page 53: Tools & Frameworks for the Semantic Web

Example RDF Schema & Data

Writer

FamousWriter

…/ISBN00023423442…/twain/mark

BookhasWritten

Schema

type

hasWritten

type

subClassOf

rangedomain

Data

Page 54: Tools & Frameworks for the Semantic Web

Storing Schema (in an RDBMS)

uri

ResourceWriterFamousWriterBook

uri

hasWritten

source target

WriterFamousWriterBook

ResourceWriterResource

source target

hasWritten Writer

source target

hasWritten Book

source target

Class SubClassOf SubPropertyOf

Property Domain Range

Page 55: Tools & Frameworks for the Semantic Web

uri

uri uri

…/ISBN00023423442

uri

…/twain/mark source target

…/twain/mark …/ISBN00023423442

FamousWriter

WriterBook

Resource

hasWritten

Storing Data (PostgreSQL)

In order to decrease the database size another table, called resources, is added to database which maps resource descriptions to unique IDs.

Page 56: Tools & Frameworks for the Semantic Web

There are many ambiguities in RDFS: RDF Schema is defined in natural language. No formal description of its semantic is given. E.g. about subClassOf it only says that it is a property with

class as its domain and range. RDF Schema is self-describing:

The definition of its terms is itself done in RDF schema. As a result it consists some inconsistencies. Circular dependencies in terms definitions:

Class is both a subclass of and an instance of Resource. Resource is an instance of Class.

RDF Schema Ambiguities

Page 57: Tools & Frameworks for the Semantic Web

Scalability Issues An experiment using Sesame:

Uploading and querying a collection of nouns from Wordnet (http://www.semanticweb.org/library)

Consisting of about 400,000 RDF statements. Using a desktop computer (Sun UltraSPARC 5

workstation, 256MB RAM) Uploading the Wordnet nouns took 94 minutes. Querying was quite slow.

Because data is distributed over multiple tables, and retrieving data needs doing many joins on tables.

Page 58: Tools & Frameworks for the Semantic Web

Protégé

Page 59: Tools & Frameworks for the Semantic Web

Protégé - Introduction Protégé is an extensible, platform-

independent environment for creating and editing ontologies and knowledge bases.

Current version is 3.1.1 but the tutorial in the next slides is based on version 2.1.1

Page 60: Tools & Frameworks for the Semantic Web

Tutorial Scenario Semantic Web for Tourism/Traveling Goal: Find matching holiday destinations

for a customer

I am looking for a comfortable destination

with beach access

Tourism Web

Page 61: Tools & Frameworks for the Semantic Web

Tourism Semantic Web

OWLMetadata

(Individuals)

OWLMetadata

(Individuals)

OWLMetadata

(Individuals)

OWLMetadata

(Individuals)

Tourism Ontology

Web Services

Destination

AccomodationActivity

Page 62: Tools & Frameworks for the Semantic Web

OWL (in Protégé)

Individuals (e.g., “FourSeasons”) Properties

ObjectProperties (references) DatatypeProperties (simple values)

Classes (e.g., “Hotel”)

Page 63: Tools & Frameworks for the Semantic Web

Individuals Represent objects in the domain Specific things Two names could represent the same

“real-world” individual

SydneysOlympicBeachBondiBeach

Sydney

Page 64: Tools & Frameworks for the Semantic Web

ObjectProperties Link two individuals together Relationships (0..n, n..m)

Sydney

BondiBeachhasPart

FourSeasonshasAccomodation

Page 65: Tools & Frameworks for the Semantic Web

Inverse Properties Represent bidirectional relationships Adding a value to one property also adds a

value to the inverse property

Sydney

BondiBeachhasPart

isPartOf

Page 66: Tools & Frameworks for the Semantic Web

Transitive Properties If A is related to B and B is related to C

then A is also related to C Often used for part-of relationships

Sydney

BondiBeach

hasPart

NewSouthWales

hasPart

hasPart (derived)

Page 67: Tools & Frameworks for the Semantic Web

DatatypeProperties Link individuals to primitive values

(integers, floats, strings, booleans etc) Often: AnnotationProperties without formal

“meaning”

Sydney

hasSize = 4,500,000isCapital = truerdfs:comment = “Don’t miss the opera house”

Page 68: Tools & Frameworks for the Semantic Web

Classes Sets of individuals with common

characteristics Individuals are instances of at least one

class

City

Sydney

Beach

Cairns

BondiBeach

CurrawongBeach

Page 69: Tools & Frameworks for the Semantic Web

Range and Domain Property characteristics

Domain: “left side of relation” (Destination) Range: “right side” (Accomodation)

Sydney

BestWestern

FourSeasonshasAccomodation

DestinationAccomodation

hasAccomodation

Page 70: Tools & Frameworks for the Semantic Web

Domains Individuals can only take values of

properties that have matching domain “Only Destinations can have Accomodations”

Domain can contain multiple classes Domain can be undefined:

Property can be used everywhere

Page 71: Tools & Frameworks for the Semantic Web

Superclass Relationships Classes can be organized in a hierarchy Direct instances of subclass are also

(indirect) instances of superclasses

Cairns

Sydney

Canberra

Coonabarabran

Page 72: Tools & Frameworks for the Semantic Web

Class Relationships Classes can overlap arbitrarily

City

Sydney

CairnsBondiBeach

RetireeDestination

Page 73: Tools & Frameworks for the Semantic Web

Class Disjointness All classes could potentially overlap In many cases we want to make sure they

don’t share instances

Sydney

UrbanArea RuralArea

SydneyWoomera

CapeYork

disjointWith

City Destination

Page 74: Tools & Frameworks for the Semantic Web

Creating a new OWL project

Page 75: Tools & Frameworks for the Semantic Web

Creating simple classes

Page 76: Tools & Frameworks for the Semantic Web

Creating class hierarchy and set disjoints

Page 77: Tools & Frameworks for the Semantic Web

Creating Contact class with datatype properties

Page 78: Tools & Frameworks for the Semantic Web

Editing details of datatype properties

Page 79: Tools & Frameworks for the Semantic Web

Createing an object property hasContact

Page 80: Tools & Frameworks for the Semantic Web

Creating an object property with inverse

Page 81: Tools & Frameworks for the Semantic Web

Creating the remaining classes and properties

Page 82: Tools & Frameworks for the Semantic Web

Class Descriptions Classes can be described by their logical

characteristics Descriptions are “anonymous classes”

Things with three star accomodation

Things with sightseeing opportunities

RetireeDestination

SydneySanJose

BlueMountains

Page 83: Tools & Frameworks for the Semantic Web

Class Descriptions Define the “meaning” of classes Anonymous class expressions are used

“All national parks have campgrounds.” “A backpackers destination is a destination

that has budget accomodation and offers sports or adventure activities.”

Expressions mostly restrict property values (OWL Restrictions)

Page 84: Tools & Frameworks for the Semantic Web

Class Descriptions: Why? Based on OWL’s Description Logic support Formalize intentions and modeling

decisions (comparable to test cases) Make sure that individuals fulfill conditions Tool-supported reasoning

Page 85: Tools & Frameworks for the Semantic Web

Reasoning with Classes Tool support for three types of reasoning

exists: Consistency checking:

Can a class have any instances? Classification:

Is A a subclass of B? Instance classification:

Which classes does an individual belong to? For Protégé we recommend RACER.

Page 86: Tools & Frameworks for the Semantic Web

Restrictions (Overview) Define a condition for property values

allValuesFrom someValuesFrom hasValue minCardinality maxCardinality cardinality

An anonymous class consisting of all individuals that fulfill the condition

Page 87: Tools & Frameworks for the Semantic Web

Cardinality Restrictions Meaning: The property must have at least/at

most/exactly x values is the shortcut for and

Example: A FamilyDestination is a Destination that has at least one Accomodation and at least 2 Activities

Page 88: Tools & Frameworks for the Semantic Web

allValuesFrom Restrictions Meaning: All values of the property must be

of a certain type Warning: Also individuals with no values

fulfill this condition (trivial satisfaction) Example: Hiking is a Sport that is only

possible in NationalParks

Page 89: Tools & Frameworks for the Semantic Web

someValuesFrom Restrictions Meaning: At least one value of the property must be

of a certain type Others may exist as well Example: A NationalPark is a RuralArea that has at

least one Campground and offers at least one Hiking opportunity

Page 90: Tools & Frameworks for the Semantic Web

hasValue Restrictions Meaning: At least one of the values of the property

is a certain value Similar to someValuesFrom but with Individuals

and primitive values. Example: A PartOfSydney is a Destination where

one of the values of the isPartOf property is Sydney

Page 91: Tools & Frameworks for the Semantic Web

Enumerated Classes Consist of exactly the listed individuals

OneStarRating

TwoStarRatingThreeStarRating

BudgetAccomodation

Page 92: Tools & Frameworks for the Semantic Web

Logical Class Definitions Define classes out of other classes

unionOf (or) intersectionOf (and)

complementOf (not)

Allow arbitrary nesting of class descriptions (A and (B or C) and not D)

Page 93: Tools & Frameworks for the Semantic Web

unionOf The class of individuals that belong to class A

or class B (or both) Example: Adventure or Sports activities

Adventure Sports

Page 94: Tools & Frameworks for the Semantic Web

intersectionOf The class of individuals that belong to both

class A and class B Example: A BudgetHotelDestination is a

destination with accomodation that is a budget accomodation and a hotel

BudgetAccomodation

Hotel

Page 95: Tools & Frameworks for the Semantic Web

Implicit intersectionOf When a class is defined by more than one class

description, then it consists of the intersection of the descriptions

Example: A luxury hotel is a hotel that is also an accomodation with 3 stars

AccomodationWith3StarsHotel

LuxuryHotel

Page 96: Tools & Frameworks for the Semantic Web

complementOf The class of all individuals that do not belong to a

certain class Example: A quiet destination is a destination that

is not a family destination

DestinationFamilyDestination

QuietDestination (grayed)

Page 97: Tools & Frameworks for the Semantic Web

Class Conditions Necessary Conditions:

(Primitive / partial classes)“If we know that something is a X,then it must fulfill the conditions...”

Necessary & Sufficient Conditions:(Defined / complete classes)“If something fulfills the conditions...,then it is an X.”

Page 98: Tools & Frameworks for the Semantic Web

Class Conditions (2)

QuietDestination

NationalPark

(not everything that fulfills these conditions is a NationalPark)

(everything that fulfills these conditions is a QuietDestination)

Page 99: Tools & Frameworks for the Semantic Web

ClassificationNationalPark

BackpackersDestination

A RuralArea is a Destination

A Campground is BudgetAccomodation

Hiking is a Sport Therefore:

Every NationalPark is a Backpackers-Destiantion

Page 100: Tools & Frameworks for the Semantic Web

Classification (2) Input: Asserted class definitions Output: Inferred subclass relationships

Page 101: Tools & Frameworks for the Semantic Web

Creating an enumerated class out of individuals

Page 102: Tools & Frameworks for the Semantic Web

Creating a hasValue restriction

Page 103: Tools & Frameworks for the Semantic Web

Creating a hasValue restriction

Page 104: Tools & Frameworks for the Semantic Web

Creating a defined class

Page 105: Tools & Frameworks for the Semantic Web

Classifying Campground

Page 106: Tools & Frameworks for the Semantic Web

Adding restrictions to City and Capital

Page 107: Tools & Frameworks for the Semantic Web

Creating defined class BackpackersDestination

Page 108: Tools & Frameworks for the Semantic Web

Creating defined class FamilyDestination

Page 109: Tools & Frameworks for the Semantic Web

Creating defined class QuietDestination

Page 110: Tools & Frameworks for the Semantic Web

Creating defined class RetireeDestination

Page 111: Tools & Frameworks for the Semantic Web

Classification

Page 112: Tools & Frameworks for the Semantic Web

Consistency Checking

Page 113: Tools & Frameworks for the Semantic Web

Visualization with OWLViz

Page 114: Tools & Frameworks for the Semantic Web

OWL Wizards

Page 115: Tools & Frameworks for the Semantic Web

Ontology Import Adds all classes, properties and individuals

from an external OWL ontology into your project

Allows to create individuals, subclasses, or to further restrict imported classes

Can be used to instantiate an ontology for the Semantic Web

Page 116: Tools & Frameworks for the Semantic Web

Tourism Semantic Web (2)

OWLMetadata

(Individuals)Tourism Ontology

Web Services

Destination

AccomodationActivity

Page 117: Tools & Frameworks for the Semantic Web

Ontology Import with Protégé On the Metadata tab:

Add namespace, define prefix Check “Imported” and reload your project

Page 118: Tools & Frameworks for the Semantic Web

Individuals

Page 119: Tools & Frameworks for the Semantic Web

Individuals

Page 120: Tools & Frameworks for the Semantic Web

Generated OWL File<?xml version="1.0"?>\<rdf:RDF xmlns="http://protege.stanford.edu/plugins/owl/owl-library/heli-bunjee.owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:travel="http://protege.stanford.edu/plugins/owl/owl-library/travel.owl#" xml:base="http://protege.stanford.edu/plugins/owl/owl-library/heli-bunjee.owl">

<owl:Ontology rdf:about=""> <owl:imports rdf:resource="http://protege.stanford.edu/plugins/owl/owl-library/travel.owl"/> </owl:Ontology>

<owl:Class rdf:ID="HeliBunjeeJumping"> <rdfs:subClassOf rdf:resource="http://protege.stanford.edu/plugins/owl/owl-library/travel.owl#BunjeeJumping"/> </owl:Class>

<HeliBunjeeJumping rdf:ID="ManicSuperBunjee"> <travel:isPossibleIn> <rdf:Description rdf:about="http://protege.stanford.edu/plugins/owl/owl-library/travel.owl#Sydney"> <travel:hasActivity rdf:resource="#ManicSuperBunjee"/> </rdf:Description> </travel:isPossibleIn> <travel:hasContact> <travel:Contact rdf:ID="MSBInc"> <travel:hasEmail rdf:datatype="http://www.w3.org/2001/XMLSchema#string">[email protected] </travel:hasEmail> <travel:hasCity rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Sydney</travel:hasCity> <travel:hasStreet rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Queen Victoria St</travel:hasStreet> <travel:hasZipCode rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1240</travel:hasZipCode> </travel:Contact> </travel:hasContact> <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Manic super bunjee now offers nerve wrecking jumps from 300 feet right out of a helicopter. Satisfaction guaranteed.</rdfs:comment> </HeliBunjeeJumping>

</rdf:RDF>

Page 121: Tools & Frameworks for the Semantic Web

Lots of other tools RDFStore

RDF framework for Perl Raptor

RDF parser library Kowari, Gateway

triple based database systems RAP

RDF framework for PHP Validators

For RDF W3C RDF

For OWL WonderWeb Pellet

Page 122: Tools & Frameworks for the Semantic Web

References Sesame

User Guide for Sesame http://www.openrdf.org/doc/sesame/users/us

erguide.html Broekstra J., Sesame: A Generic Architecture for

Storing and Querying RDF and RDF Schema, ISWC’02 http://sesame.aidministrator.nl http://www.openRDF.org

Protégé http://protege.stanford.edu/ http://www.co-ode.org

Page 123: Tools & Frameworks for the Semantic Web

References Jena

Official site of Jena 2 http://jena.sourceforge.net/

Jena 2 Ontology API http://jena.sourceforge.net/ontology/

An Introduction to RDF and the Jena RDF API http://jena.sourceforge.net/tutorial/RDF_API/

A Programmer's Introduction to RDQL http://jena.sourceforge.net/tutorial/RDQL/

Jena 2 Database Interface http://jena.sourceforge.net/DB/

Jena 2 Inference support http://jena.sourceforge.net/inference/

Other tools http://www.daml.org/tools/

Page 124: Tools & Frameworks for the Semantic Web

The End