24
Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics [email protected] Model-Driven Semantic Web Workshop 21.09.2004

Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics [email protected] Model-Driven Semantic Web

Embed Size (px)

Citation preview

Page 1: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Ontology-Driven Software Development with Protégé and OWL

Holger KnublauchStanford Medical Informatics

[email protected]

Model-Driven Semantic Web Workshop21.09.2004

Page 2: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Protégé

Core System (since 1990s)

• Generic metamodel (OKBC)• Configurable• Open platform with “Plugins”

OWL Plugin (since 2003)

• OWL Full metamodel• Optimized user interface• Built-in reasoning access • Several thousand users

Page 3: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Protégé / OWL Plugin

Page 4: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Protégé / OWL Plugin

Page 5: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Overview

• How to develop Semantic Web applications?– Example– Architecture and OWL-Java mapping– Tool support

• Can we apply this to general purpose MDA?– OWL is often more suitable than UML– Major benefit: Semantics at edit-time & run-time

Page 6: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Example Scenario

Page 7: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Traditional Web Architecture

Travel PlanningPortal

Database

AccommodationPortal

Database

Cruise Operator

Boat Rental

Hotel

Submission Forms Query Interfaces

End User

Manual actionsAutomated actions

Page 8: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Semantic Web Architecture

Cruise Operator

Boat Rental

Hotel

Service Metadata

End User

OWL

OWL

OWL

CrawlerAgent

Travel ServicesDatabaseand Agent

OWL

User Profile

Query Interface

Manual actionsAutomated actions

Web

Ser

vice

Page 9: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

OntologiesTravel Ontology

ActivityProvider

ContactAddressActivity

AdventureActivity

providesActivity hasContact

BungeeJumping Caving

HeliBungeeJumping

Geography Ontology

GeographicArea

CountryCity

hasLocation

Travel Extension Ontologies

Page 10: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Software Architecture (1)

Travel.owl Customer.owl

HeliBungee.owl ...

Sem

antic

Web

Lay

erIn

tern

al L

ayer

Ontology representationas Java objects

ActivityX.owl

Reasoners (OWL DL, SWRL, ...)

End-UserInterface

(JSP)

Web ServiceInterface(WSDL)

Web Service, Control Logic(Java Code)

Cor

e O

ntol

ogie

s

Page 11: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Ontology Code in Java

OntModel model = ...;OntProperty nameProperty = model.getOntProperty(baseURI + “name”);Individual myActivity = model.getIndividual(baseURI + “test”);String name = myActivity.getPropertyValue(nameProperty);Bookings.book(myActivity);...

XYModel model = ...;Activity myActivity = model.getActivity(baseURI + “test”);String name = myActivity.getName();myActivity.book();...

Typical approach with a generic API (Jena):

Nicer approach with a customized API:

Page 12: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

UML to Java (conventional)

Activity

- name : String

ActivityProvider

providedBy

0..*

0..*

public class Activity {

private String name;

private Collection providers;

public String getName()

public void setName(String name)

public Iterator listProviders()

public void addProvider(ActivityProvider p)

public void removeProvider(ActivityProvider p)}

Page 13: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

OWL to Java (Jena)

Activity

- name : String

ActivityProvider

providedBy

0..*

0..*

public class Activity extends OntClassImpl {

public String getName()

public void setName(String name)

public Iterator listProviders()

public void addProvider(ActivityProvider p)

public void removeProvider(ActivityProvider p)}

Page 14: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Working with Jena Classes

Resource

OntProperty OntClass

RDFTriple Store

Customer Activity

Bungee

Generic Level

Application Level

Page 15: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Software Architecture (2)

Travel.owl Customer.owl

HeliBungee.owl ...

Sem

antic

Web

Lay

erIn

tern

al L

ayer

Activity.java...

Customer.java...

Dynamic Object Model (Jena)

ActivityX.owl

Reasoners (OWL DL, SWRL, ...)

End-UserInterface

(JSP)

Web ServiceInterface(WSDL)

Web Service, Control Logic(Java Code)

Cor

e O

ntol

ogie

s

Page 16: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Dynamic Object Model• Model is accessible at run-time:

– Generic algorithms/reasoners can be executed– Generic test cases available at run-time– Generic serialization, database storage etc.– Generic user interfaces can be generated– Classes can be handled as individuals

(Metaclasses are supported)– Instances can have multiple types

(dynamic polymorphism using Jena API)– Instances can be classified & change types

Page 17: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Other OWL to Java Benefits

Traditional Code:

Code based on generated Jena classes:

Collection patients = model.getPatients();for(Iterator it = patients.iterator(); it.hasNext(); ) { Patient patient = (Patient) it.next(); if(patient.isMale()) { patient.doSomething(); }}

for(Iterator it = model.listIndividuals(MALE, true); it.hasNext(); ) { Patient patient = (Patient) it.next(); patient.doSomething();}

Page 18: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Generalizing This Approach

• Every program has a “domain model”– Customers, Accounts, Products– Patients, Diseases, Treatments

• Domain model is potentially most reusable

• No real need for UML

• Paradigm shift to anew dialect of OO

Model

View Control

Page 19: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Dynamic Object Models and MDA

• MDA taken to extremes

• Design not only to generate code

• Design is part of the deployed system– Open ontologies to share between applications– Machine-accessible semantics at run-time– Built-in reflection across metalevels

• However: Limited expressivity of OWL; Coding needed (procedural attachment).

Page 20: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Advantages of OWL over UML

• Explicit, sharable modeling artifacts

• Open architecture of Semantic Web

• OWL has rich semantics– closer to domain than UML– built-in reasoning support (DL, SWRL)

• A single language across metalevels

Page 21: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Strengths of tools like Protégé

• Can be used by domain experts

• Better scalable than visual UML modeling

• Reasoning support at edit-time

• Rapid prototyping of models

• Individuals can be acquired using forms

• Open architecture / adaptability

• Start your application as a plugin

Page 22: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Ontology-Driven Development

Model

View ControlIncrem

ental Code

Generation

Agile Modeling

Agile Programming

Page 23: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Future Work with Protégé (1)

• Embrace UML, encourage use of OWL

• Incremental OWL-Java code generation1. Determine optimal mapping OWL to Java,

(using an example application)

2. Define rules for updating code in response to changes in the ontology (create, rename, etc).

3. Write Eclipse plugin to perform the updating (either directly or in batch mode)

Page 24: Ontology-Driven Software Development with Protégé and OWL Holger Knublauch Stanford Medical Informatics holger@smi.stanford.edu Model-Driven Semantic Web

Future Work with Protégé (2)

• Use Protégé as an ODM editor

• Map core Protégé metamodel to RDF(S)

Collaborations?

ODM Bridge