Scripting the Semantic Web Marian Babik Ladislav Hluchy
Scripting the Semantic Web Marian Babik, Ladislav Hluchy Intelligent and Knowledge-oriented Technologies Group Institute of Informatics, SAS 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Goals of the presentation Semantic Web p Object-oriented Systems p Introduce deep integration ideas p Show initial implementation of the Python integrated with OWL p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Semantic Web p Extension of the current Web, providing infrastructure for the integration of data on the Web n n n p 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: n n n Names for resources Common data model: RDF Access to the data: SPARQL, OWL-QL Define vocabularies: RDFS, OWL, SKOS Reasoning: OWL, Rules 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Description Logics, OWL-DL p Class definition, axioms n p Property definition, axioms n n p Complex class definitions based on the class descriptions RDF Schema constructs (rdfs: sub. Property. Of, rdfs: domain and rdfs: range) relations to other properties: owl: equivalent. Property and owl: inverse. Of) global cardinality constraints: owl: Functional. Property and owl: Inverse. Functional. Property logical property characteristics owl: Symmetric. Property and owl: Transitive. Property Individuals n facts about class membership and property values of individuals 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Object-oriented systems Data Structure is an Object that contains both Data and Methods p Relationships can exist between different Objects (inheritance etc) p Modular and easily extendible frameworks p Examples: Java, C++, Smalltalk, Python, Ruby, PHP p Web Frameworks p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Issues in mapping DL to OO p Similarities between DL and OO n n p p Differences between DL and OO Semantics n p Implicit Vs. Explicit Set Membership Interpretation Extensions n p Open Vs. Closed World Semantics Interpretations n p Class Hierarchy w/ Multiple Inheritance DL Properties correspond to OO Class fields Automatic Inferences Vs. Manual Modifications Behavior n None in DL, crucial to OO 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Deep integration ideas Import OWL classes alongside classes defined normally (native API) p Support for intensional definition of classes/properties (OWL statements) p Separation of concerns among declarative and procedural aspects p Similar to what SQLObject does for databases p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Benefits Definition of data and domain using Semantic Web tools (Protégé, SWOOP) p Native OWL API p OWL Inference and Web sharing of concepts p New programming paradigm for Python p Native interface for ontologies, developers can work directly with OWL classes and their instances p Existing Python Web frameworks and access to large set of libraries Ontologies Python p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Related Work p Jena, OWL API n n Java is statically-typed language Different notion of polymorphism means APIs have to introduce sophisticated design patterns Resource r = my. Model. get. Resource( my. NS + "Digital. Camera" ); Ont. Class cls = (Ont. Class) r. as( Ont. Class. class ); Restriction rest = (Restriction) cls. as( Restriction. class ); p p p Jastor Automatic Mapping of OWL Ontologies into Java [Kalyanpur, et. al] Protégé Bean-Generator FIPA, Jade [Poggi et. al. ] RDFReactor 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Related Work Python p RDFLib – statement-centric (Daniel Krech) p CWM – model centric p Pychinko – model, statement-centric, rule based p Meta. Log – statement, resource-centric, based on prolog p Sparta, Tramp – resource centric Others (see: http: //www. wiwiss. fu-berlin. de/suhl/bizer/toolkits/) p Active RDF (Ruby) – native mapping, RDF, integrated with Rails p RDFHomepage (PHP) – native mapping 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
OWL-DL and Python Ontology corresponds to Python module p OWL Class corresponds to Python Class p Instance of OWL Class corresponds to Python Object p OWL Property corresponds to Python Class or Python method p OWL Datatype. Property corresponds to Attribute p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Classes OWL Class corresponds to Python Class p Instances of OWL Class correspond to Python Objects p Class definition p n Each python class has two attributes: URI (owl: Class URI) p defined. By (intensional definition) p >>> from seth import Thing, Property >>> Person = Thing. new(‘ : Person a owl: Class. ') >>> print Person <class seth. Meta. Person> >>> Man = Thing. new(' : Man a owl: Class ; rdfs: sub. Class. Of : Person. ') 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Classes (2) >>> Person. With. Single. Son = Thing. new("""Person. With. Single. Son a owl: Class ; rdfs: sub. Class. Of [ a owl: Restriction ; owl: cardinality "1"^^ ; owl: on. Property : has. Son ]; rdfs: sub. Class. Of [ a owl: Restriction ; owl: cardinality "1"^^ ; owl: on. Property : has. Child ]. """) >>> model = Ont. Model() >>> model. bind(“people”, ”http: //somewhere. net/people#”) >>> Thing. set. Ont. Model(model) >>> Person = Thing. new(“ people: Person a owl: Class. ”) 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Properties p owl: Property corresponds to python objects n n Similar to Class definition But such classes don’t have instances >>> has. Child = Property. new('has. Child a owl: Object. Property. ') >>> print has. Child <class 'seth. Meta. has. Child'> >>> has. Son = Property. new('has. Son a owl: Object. Property ; rdfs: sub. Property. Of : has. Child. ') p owl: Property corresponds to python object attribute (method) >>> John. has. Child(Bob) 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Individuals p Individual is python object (class instance) >>> Bob = Person. With. Single. Son() >>> John = Person() >>> print John <seth. Meta. Person object at 0 xb 7 a 29 e 4 c> >>> has. Child(Bob, John) 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Ontologies p owl: Ontology corresponds to Python module >>> Module. Factory(“people”, “http: //somewhere. net/people. owl”) >>> import people >>> print people. Person <seth. people. Person : Man a owl: Class ; rdfs: sub. Class. Of : Person. >>> print people. John <seth. people. Person object at 0 xb 7 a 29 e 4 c> p serialization >>> people. serialize(“/tmp/test. owl”, “RDF/XML-ABBREV”) 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Queries p Triple like queries >>> for individual in Person. find. Instances(): . . . print individual, individual. name <seth. Meta. Man object at 0 xb 7 d 0 b 64 c> Peter <seth. Meta. Person object at 0 xb 7 d 0 b 50 c> John <seth. Meta. Person object at 0 xb 7 d 0 b 6 ec> Jane >>> for who in has. Son. q(Bob): . . . who. name 'John' >>> print has. Son. query(Bob, John) 1 OWL-QL, SPARQL p Native queries p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Prototype architecture p Interaction with Java-based libraries (reasoners) 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Python and Java Jython - Python implemented for the Java Virtual Machine p JPE(Java-Python Extension) - uses JNI to provide a bridging mechanism between Java and a Python interpreter p JPype - interfacing at the native level in both Virtual Machines p SPIRO - uses ORB (Object-Request Broker) technology p GCJ p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Issues Performance (conversion between JVMs) p Cache p Datatype reasoning p Open world semantics p Debugging p Rules p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Summary SETH Homepage: http: //seth-scripting. sourceforge. net p Available through CVS under MIT license p Discussion, support mailing list: seth. ui@savba. sk p Plans p p Contact: n Marian. Babik@gmail. com 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
References p Introduction to Semantic Web n p http: //www. w 3. org/2006/Talks/0524 -Edinburgh-IH/Overview. pdf Deep Integration n http: //www. semanticscripting. org/SFSW 2005/papers/Vrandecic. Deep_Integration. pdf http: //gigaton. thoughtworks. net/~ofernand 1/Deep. Integration. pdf n http: //www. semanticscripting. org/SFSW 2006/Paper 1. pdf n 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Resource Description Framework (RDF) p Based on triples (subject, predicate, object) n n n 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: //. . . /my. Calendar, http: //. . . /calendar ) (subject, predicate, object) can be seen as a labeled edge in a graph p Serialization XML, Turtle, N 3, etc. p 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Turtle (N 3) XML/RDF example <rdf: Description rdf: about="http: //www. tuke. sk/fei-cit/babik"> <s: has. Name>Marian Babik</s: has. Name> <s: has. Written rdf: resource="http: //www. semanticscripting. org/SFSW 2006/Paper 1. pdf"/> </rdf: Description> <http: //www. tuke. sk/fei-cit/babik> s: has. Name “Marian Babik”; s: has. Written <http: //www. semanticscripting. org/SFSW 2006/Paper 1. pdf>. 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
RDF Vocabulary Description Language (RDFS) RDF lacks vocabulary with semantic meaning p RDFS defines resources and classes and relationships among classes/resource p n n n p rdf: type, rdfs: Class, rdfs: sub. Class. Of rdfs: sub. Property. Of, Resource may belong to several classes (range, domain) Special kind of type system 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
RDFS example : Person rdfs: sub. Class. Of : Man. <rdf: Description rdf: ID=“John”> <rdf: type rdf: resource=“Man”/> : John rdf: type : Man. </rdf: Description> <rdf: Description rdf: ID=“Man”> <rdfs: sub. Class. Of rdf: resource=“Person”/> </rdf: Description> 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
RDFS example (2) : Person rdfs: sub. Class. Of : Man. : John rdf: type : Man. : is. Programmer rdf: type rdf: Property; rdf: domain : Person; rdf: range rdfs: Literal. 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
Web Ontology Language (OWL) p RDFS doesn’t solve all the issues n n n p Compromise btw n n p Reasoning about terms Behavior of properties (symmetric, transitive, etc. ) Cardinality constraints Equivalence of classes Enumeration (one. Of), union of classes Datatype properties Rich semantics Feasibility, implementability Three layers: n n n OWL-Lite, OWL-DL (based on Description Logic – SHOIN(D)) OWL-Full (might be undecidable) 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
OWL-DL example @prefix people: <http: //sample. org/people>. people: Person a owl: Class. people: Man a owl: Class; rdfs: sub. Class. Of people: Person people: has. Child a owl: Property. people: has. Son a owl: Propery; rdfs: sub. Property. Of people: has. Child Person. With. Single. Son a owl: Class ; rdfs: sub. Class. Of [ a owl: Restriction ; owl: cardinality "1"^^ ; owl: on. Property : has. Son ]; rdfs: sub. Class. Of [ a owl: Restriction ; owl: cardinality "1"^^ ; owl: on. Property : has. Child ]. People: John a people: Person. People: Bob a people: Person. With. Single. Son. 1 st Workshop on Intelligent and Knowledge-oriented Technologies, 28 -29. 11. , Bratislava
- Slides: 29