Title: Scripting the Semantic Web
1Scripting the Semantic Web
- Marian Babik, Ladislav Hluchy
- Intelligent and Knowledge-oriented Technologies
Group - Institute of Informatics, SAS
2Goals of the presentation
- Semantic Web
- Object-oriented Systems
- Introduce deep integration ideas
- Show initial implementation of the Python
integrated with OWL -
3Semantic Web
- Extension of the current Web, providing
infrastructure for the integration of data on the
Web - Data should be available for further processing
- It should be possible to combine and merge data
on a Web scale - Metadata, reasoning
- Making data machine processable
- Names for resources
- Common data model RDF
- Access to the data SPARQL, OWL-QL
- Define vocabularies RDFS, OWL, SKOS
- Reasoning OWL, Rules
4Description Logics, OWL-DL
- Class definition, axioms
- Complex class definitions based on the class
descriptions - Property definition, axioms
- RDF Schema constructs (rdfssubPropertyOf,
rdfsdomain and rdfsrange) - relations to other properties owlequivalentPrope
rty and owlinverseOf) - global cardinality constraints
owlFunctionalProperty and owlInverseFunctionalPr
operty - logical property characteristics
owlSymmetricProperty and owlTransitiveProperty - Individuals
- facts about class membership and property values
of individuals
5Object-oriented systems
- Data Structure is an Object that contains both
Data and Methods - Relationships can exist between different Objects
(inheritance etc) - Modular and easily extendible frameworks
- Examples Java, C, Smalltalk, Python, Ruby, PHP
- Web Frameworks
6Issues in mapping DL to OO
- Similarities between DL and OO
- Class Hierarchy w/ Multiple Inheritance
- DL Properties correspond to OO Class fields
- Differences between DL and OO
- Semantics
- Open Vs. Closed World Semantics
- Interpretations
- Implicit Vs. Explicit Set Membership
Interpretation - Extensions
- Automatic Inferences Vs. Manual Modifications
- Behavior
- None in DL, crucial to OO
7Deep integration ideas
- Import OWL classes alongside classes defined
normally (native API) - Support for intensional definition of
classes/properties (OWL statements) - Separation of concerns among declarative and
procedural aspects - Similar to what SQLObject does for databases
8Benefits
- Definition of data and domain using Semantic Web
tools (Protégé, SWOOP) - Native OWL API
- OWL Inference and Web sharing of concepts
- New programming paradigm for Python
- Native interface for ontologies, developers can
work directly with OWL classes and their
instances - Existing Python Web frameworks and access to
large set of libraries
Ontologies Python
9Related Work
- Jena, OWL API
- Java is statically-typed language
- Different notion of polymorphism means APIs have
to introduce sophisticated design patterns
Resource r myModel.getResource( myNS
"DigitalCamera" ) OntClass cls (OntClass)
r.as( OntClass.class ) Restriction rest
(Restriction) cls.as( Restriction.class )
- Jastor
- Automatic Mapping of OWL Ontologies into Java
Kalyanpur, et.al - Protégé Bean-Generator
- FIPA, Jade Poggi et.al.
- RDFReactor
10Related Work
- Python
- RDFLib statement-centric (Daniel Krech)
- CWM model centric
- Pychinko model, statement-centric, rule based
- MetaLog statement, resource-centric, based on
prolog - Sparta, Tramp resource centric
- Others (see http//www.wiwiss.fu-berlin.de/suhl/b
izer/toolkits/) - Active RDF (Ruby) native mapping, RDF,
integrated with Rails - RDFHomepage (PHP) native mapping
11OWL-DL and Python
- Ontology corresponds to Python module
- OWL Class corresponds to Python Class
- Instance of OWL Class corresponds to Python
Object - OWL Property corresponds to Python Class or
Python method - OWL DatatypeProperty corresponds to Attribute
12Classes
- OWL Class corresponds to Python Class
- Instances of OWL Class correspond to Python
Objects - Class definition
- Each python class has two attributes
- URI (owlClass URI)
- definedBy (intensional definition)
gtgtgt from seth import Thing, Property gtgtgt Person
Thing.new( Person a owlClass .') gtgtgt print
Person ltclass seth.Meta.Persongt gtgtgt Man
Thing.new(' Man a owlClass rdfssubClassOf
Person .')
13Classes (2)
- gtgtgt PersonWithSingleSon Thing.new("""PersonWithS
ingleSon - a owlClass
- rdfssubClassOf
- a owlRestriction owlcardinality "1"
- owlonProperty hasSon
- rdfssubClassOf
- a owlRestriction owlcardinality "1"
- owlonProperty hasChild .""")
gtgtgt model OntModel() gtgtgt model.bind(people,ht
tp//somewhere.net/people) gtgtgt
Thing.setOntModel(model) gtgtgt Person Thing.new(
peoplePerson a owlClass .)
14Properties
- owlProperty corresponds to python objects
- Similar to Class definition
- But such classes dont have instances
- owlProperty corresponds to python object
attribute (method)
gtgtgt hasChild Property.new('hasChild a
owlObjectProperty .') gtgtgt print hasChild ltclass
'seth.Meta.hasChild'gt gtgtgt hasSon
Property.new('hasSon a owlObjectProperty
rdfssubPropertyOf hasChild .')
gtgtgt John.hasChild(Bob)
15Individuals
- Individual is python object (class instance)
gtgtgt Bob PersonWithSingleSon() gtgtgt John
Person() gtgtgt print John ltseth.Meta.Person object
at 0xb7a29e4cgt gtgtgt hasChild(Bob, John)
16Ontologies
- owlOntology corresponds to Python module
gtgtgt ModuleFactory(people, http//somewhere.net/
people.owl) gtgtgt import people gtgtgt print
people.Person ltseth.people.Person Man a
owlClass rdfssubClassOf Person . gtgtgt print
people.John ltseth.people.Person object at
0xb7a29e4cgt
gtgtgt people.serialize(/tmp/test.owl,
RDF/XML-ABBREV)
17Queries
gtgtgt for individual in Person.findInstances() ...
print individual, individual.name ltseth.Meta.M
an object at 0xb7d0b64cgt Peter ltseth.Meta.Person
object at 0xb7d0b50cgt John ltseth.Meta.Person
object at 0xb7d0b6ecgt Jane gtgtgt for who in
hasSon.q(Bob) ... who.name 'John' gtgtgt print
hasSon.query(Bob, John) 1
- OWL-QL, SPARQL
- Native queries
18Prototype architecture
- Interaction with Java-based libraries (reasoners)
19Python and Java
- Jython - Python implemented for the Java Virtual
Machine - JPE(Java-Python Extension) - uses JNI to provide
a bridging mechanism between Java and a Python
interpreter - JPype - interfacing at the native level in both
Virtual Machines - SPIRO - uses ORB (Object-Request Broker)
technology - GCJ
20Issues
- Performance (conversion between JVMs)
- Cache
- Datatype reasoning
- Open world semantics
- Debugging
- Rules
21Summary
- SETH Homepage
- http//seth-scripting.sourceforge.net
- Available through CVS under MIT license
- Discussion, support mailing list
- seth.ui_at_savba.sk
- Plans
- Contact
- Marian.Babik_at_gmail.com
22References
- Introduction to Semantic Web
- http//www.w3.org/2006/Talks/0524-Edinburgh-IH/Ove
rview.pdf - Deep Integration
- http//www.semanticscripting.org/SFSW2005/papers/V
randecic-Deep_Integration.pdf - http//gigaton.thoughtworks.net/ofernand1/DeepInt
egration.pdf - http//www.semanticscripting.org/SFSW2006/Paper1.p
df
23Resource Description Framework (RDF)
- Based on triples (subject, predicate, object)
- Labelled connection btw. two resources (subject,
object) - Subject, predicate are URI-s Object is URI (e.g.
Subject) or Literal - ( http//www.marianbabik.org, http//.../myCalenda
r, http//.../calendar ) - (subject, predicate, object) can be seen as a
labeled edge in a graph - Serialization XML, Turtle, N3, etc.
-
24RDF example
ltrdfDescription rdfabout"http//www.tuke.sk
/fei-cit/babik"gt ltshasNamegtMarian
Babiklt/shasNamegt ltshasWritten
rdfresource"http//www.semanticscripting.org/SFS
W2006/Paper1.pdf"/gt lt/rdfDescriptiongt
Turtle (N3) XML/RDF
- lthttp//www.tuke.sk/fei-cit/babikgt
- shasName Marian Babik
- shasWritten lthttp//www.semanticscripting.org/
SFSW2006/Paper1.pdfgt .
25RDF Vocabulary Description Language (RDFS)
- RDF lacks vocabulary with semantic meaning
- RDFS defines resources and classes and
relationships among classes/resource - rdftype, rdfsClass, rdfssubClassOf
- rdfssubPropertyOf,
- Resource may belong to several classes (range,
domain) - Special kind of type system
26RDFS example
Person rdfssubClassOf Man . John rdftype
Man .
ltrdfDescription rdfIDJohngt ltrdftype
rdfresourceMan/gt lt/rdfDescriptiongt ltrdfDescr
iption rdfIDMangt ltrdfssubClassOf
rdfresourcePerson/gt lt/rdfDescriptiongt
27RDFS example (2)
- Person rdfssubClassOf Man .
- John rdftype Man .
- isProgrammer
- rdftype rdfProperty
- rdfdomain Person
- rdfrange rdfsLiteral .
28Web Ontology Language (OWL)
- RDFS doesnt solve all the issues
- Reasoning about terms
- Behavior of properties (symmetric, transitive,
etc.) - Cardinality constraints
- Equivalence of classes
- Enumeration (oneOf), union of classes
- Datatype properties
- Compromise btw
- Rich semantics
- Feasibility, implementability
- Three layers
- OWL-Lite,
- OWL-DL (based on Description Logic SHOIN(D))
- OWL-Full (might be undecidable)
29OWL-DL example
_at_prefix people lthttp//sample.org/peoplegt
. peoplePerson a owlClass . peopleMan a
owlClass rdfssubClassOf peoplePerson peopleha
sChild a owlProperty . peoplehasSon a
owlPropery rdfssubPropertyOf
peoplehasChild PersonWithSingleSon a owlClass
rdfssubClassOf a owlRestriction
owlcardinality "1" owlonProperty
hasSon rdfssubClassOf a
owlRestriction owlcardinality "1"
owlonProperty hasChild . PeopleJohn a
peoplePerson . PeopleBob a peoplePersonWithSing
leSon .