semantic pipes- web 3.0 information systems · columbia university bookinfo

27
Jarrar © 2011 1 RDF © Mustafa Jarrar Lecture Notes, Knowledge Engineering (SCOM7348) University of Birzeit 1 st Semester, 2011 Dr. Mustafa Jarrar University of Birzeit [email protected] www.jarrar.info Knowledge Engineering (SCOM7348)

Upload: truongngoc

Post on 27-Aug-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 1

RDF

© Mustafa Jarrar

Lecture Notes, Knowledge Engineering (SCOM7348)

University of Birzeit

1st Semester, 2011

Dr. Mustafa Jarrar

University of Birzeit

[email protected]

www.jarrar.info

Knowledge Engineering (SCOM7348)

Page 3: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 3

What is XML

• Provides a common syntax for marking up documents.

• Easy to exchange between computers (web)

• Data model: an XML Document is an ordered labeled tree (/collection

of trees).

• W3C standard since 1997.

<bookInfo>

<title>Orientalism</title>

<author>

<persName>

<title>Prof.</title>

<foreName>Edward</foreName>

<surName>Said</surName>

<roleName>University Professor

<placeName>Columbia University

</placeName>

</roleName>

</persName>

</author>

</bookInfo>

bookinfo

title

surNametitle

author

persName

foreName

placeName

roleName

Page 4: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 4

XML Example

<address>

<name>Universsity of Birzeit</name>

<street>Almarj 435</street>

<town>Birzeit</town>

</address>

Page 5: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 5

Address Example: XML to XML

<address>

<name>University of Birzeit</name>

<place>

<street>Almarj 435</street>

<town>Birzeit</town>

</place>

</address>

<address>

<name>University of Birzeit</name>

<street>Almarj 435</street>

<town>Birzeit</town>

</address>

XML Markup 1:

XML Markup 2:

XML stylesheets arealso usable to transformXML representations

Page 6: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 6

Why XML is Not Enough?

• It provides syntax, but not semantics, which is important when

exchanging/representing data over the Web.

• Not primitive. Same data can be represented in many ways, which is a

problem when exchanging/representing data over the Web.

<aaaa>

<bbbb>Universsity of Birzeit</aaaa>

<cccc>Almarj 435</cccc>

<dddd>Birzeit</dddd>

</aaaa>

<address>

<name>University of Birzeit</name>

<street>Almarj 435</street>

<town>Birzeit</town>

</address>

<address name=“University of Birzeit”>

<street>Almarj 435</street>

<town>Birzeit</town>

</address>

Page 7: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 7

Data Representation Models

Databases (Relational Data model)

XML (Tree Data Model)

RDF (Graph Data Model)

Page 8: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 8

What is RDF?

• RDF stands for Resource Description Framework.

• It is used for describing resources on the web.

• Makes use of URIs to identify web resources and is

written in XML.

• It is not a language but a framework• You see it as a way of writing XML making it meaningful and more

primitive.

• You may see it independent, RDF data might never occur in XML form

• W3C standard since 1999

Page 9: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 9

Designed to be read by Computers

• RDF was designed to provide a common way to describe

information so it can be read (and understood) by

computer applications.

• RDF descriptions are not designed to be displayed on the

web.

Page 10: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 10

Makes use of URIs

• RDF uses a URI (Uniform Resource Identifier) to identify aweb resource, and properties to describe the resource

• Unlike URLs, URIs are not limited to identifying things thathave a network location

• A URI reference (URIref) is a URI, together with anoptional fragment identifier at the end.http://www.example.org/index.html#section2

Page 11: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 11

Example

http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067Xc

Orientalism

Edward Said

11$

:Author

<?xml version="1.0"?>

<rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#

xmlns:a="http://www.example.com"

xmlns:w="http://en.wikipedia.org/wiki/">

<rdf:Description rdf:about="http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067X">

<a:Title>Orientalism</a:Title>

<a:Price>11$</a:Price>

<a:Author>Edward_Said</a:Author>

</rdf:Description>

</rdf:RDF>

Page 12: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 12

Example

<?xml version="1.0"?>

<rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#

xmlns:a="http://www.example.com/"

xmlns:w="http://en.wikipedia.org/wiki/">

<rdf:Description rdf:about="http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067X">

<a:Title>Orientalism</a:Title>

<a:Price>11$</a:Price>

<a:Author>

<rdf:Description rdf:about="w:Edward_Said">

<a:BirthCity>Jerusalem</a:BirthCity>

<a:BornAt>1/11/1935</a:BornAt>

<a:DiedA>25/9/2003</a:DiedA>

</rdf:Description>

</a:Author>

</rdf:Description>

</rdf:RDF>

<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>

http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067Xc

Orientalism

http://en.wikipedia.org/wiki/Edward_Said

11$ Edward Saïd

Jerusalem

1/11/1935

25/9/2003

a:Author

a:B

irth

Cit

y

Page 13: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 13

Example

<?xml version="1.0"?>

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:dc="http://purl.org/dc/elements/1.1/"

xmlns:a="http://www.example.com#"

xmlns:w="http://en.wikipedia.org/wiki/">

<rdf:Description rdf:about="http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067X">

<a:Title>Orientalism</a:Title>

<a:Price>11$</a:Price>

<a:Author>

<rdf:Description rdf:about="w:Edward_Said">

<a:BornAt>1/11/1935</a:BornAt>

<a:DiedA>25/9/2003</a:DiedA>

<a:BirthCity>

<rdf:Description rdf:about="http://en.wikipedia.org/wiki/Jerusalem">

<a:Population>760800</a:Population>

<a:CapitalOf>Palestine</a:CapitalOf>

</rdf:Description>

</a:BirthCity>

</rdf:Description>

</a:Author>

</rdf:Description>

</rdf:RDF>

http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067Xc

Orientalism

http://en.wikipedia.org/wiki/Edward_Said

11$ Edward Saïd

http://en.wikipedia.org/wiki/Jerusalem

1/11/1935

25/9/2003

760800 Palestine

:Author

:Bir

thC

ity

Page 14: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 14

Another Example

Page 15: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 15

Directed Graph Representation

Page 16: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 16

Simple Example

<?xml version="1.0"?>

<RDF>

<Description about="http://www.w3schools.com/default.asp">

<author>Jan Egil Refsnes</author>

<created>November 1, 1999</created>

<modified>February 1, 2004</modified>

</Description>

</RDF>

Page 17: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 17

Example Explained

• In the example:

– the URI "http://www.w3schools.com/-default.asp" isused to identify a web page,

– the property "author" describes the author of the page,

– the property value is "Jan Egil Refsnes".

– The property "created" tells when the page wascreated, and the property "modified" when it was lastmodified.

Page 18: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 18

Subject, Predicate & Object

• RDF terminology also use the words subject,

predicate and object.

• The resource http://www.w3schools.com/default.asp is

the subject

• The property "author" is the predicate

• The value "Jan Egil Refsnes" is the object

Page 19: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 19

RDF Important Concepts

• Data is represented in RDF as a directed labeled graph.

• An RDF graph is a set of triples, of the form <Subject, Predicate, Object>

Each Subject and each Predicate must be a URI; that is, it has to be a

unique identifier, not a literal. An Object can be either a URI or a literal.

Page 20: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 20

Example 2

<rdf:RDF>

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax ns#"

xmlns:cd="http://www.recshop.fake/cd">

<rdf:Description

rdf:about="http://www.recshop.fake/cd/Empire Burlesque">

<cd:artist>Bob Dylan</cd:artist>

<cd:country>USA</cd:country>

<cd:company>Columbia</cd:company>

<cd:price>10.90</cd:price>

<cd:year>1985</cd:year>

</rdf:Description>

. . . . . . . . . . . .

Page 21: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 21

Example 2 (cont)

<rdf:Description rdf:about="http://www.recshop.fake/cd/Hide your heart"> <cd:artist>Bonnie Tyler</cd:artist> <cd:country>UK</cd:country> <cd:company>CBS Records</cd:company> <cd:price>9.90</cd:price> <cd:year>1988</cd:year>

</rdf:Description></rdf:RDF>

Page 22: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 22

Details of the Example

• The first line in the XML file is the XML declaration, telling the version of

XML.

• The rdf:RDF element indicates that the content is RDF.

• The xmlns:rdf namespace, specifies that tags with the rdf: prefix are

from the namespace defined by "http://www.w3.org/1999/02/22-rdf-syntax-ns#".

• The xmlns:cd namespace, specifies that tags with the cd: prefix are

from the namespace defined by "http://www.recshop.fake/cd".

• The rdf:Description element contains the description of a resource

identified by the rdf:about attribute.

• The cd:artist element describes a property of the resource, and so

does cd:country, etc.

Page 23: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 23

List of Triples (Table Representation)

Subject Predicate Object

http://www.recshop.fake/cd/Empire

Burlesquehttp://www.recshop.fake/cdartist

"Bob

Dylan"

http://www.recshop.fake/cd/Empire

Burlesque

http://www.recshop.fake/cdcount

ry"USA"

http://www.recshop.fake/cd/Empire

Burlesque

http://www.recshop.fake/cdcomp

any"Columbia"

http://www.recshop.fake/cd/Empire

Burlesquehttp://www.recshop.fake/cdprice "10.90"

http://www.recshop.fake/cd/Empire

Burlesquehttp://www.recshop.fake/cdyear "1985"

Page 24: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 24

Main RDF Properties and Attributes

Main RDF Properties

• rdf:subject The subject of the resource in an RDF Statement

• rdf:predicate The predicate of the resource in an RDF Statement

• rdf:object The object of the resource in an RDF Statement

• rdf:type The resource is an instance of a class

Main RDF Attributes

• rdf:RDF The root of an RDF document

• rdf:about Defines the resource being described

• rdf:Description Container for the description of a resource

• rdf:resource Defines a resource to identify a property

• rdf:datatype Defines the data type of an element

Page 25: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 25

RDF Validator

• Check the correctness of an RDF document:

http://www.w3.org/RDF/Validator/

• Result shows the subject, predicate and object of each

element of the document and a graph of the model.

Page 26: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 26

XML into RDF (Example)

<XML>

<Article ID=B1 Year=“2000”>

<Author ID=A1>

<Name>Tom</Name>

<Affiliation ID=UoM>

<Name>University of Malta</Name>

<Country ID=mt>

<Name> Malta</Name>

<Capital>Valletta</Capital>

</Country>

</Affiliation>

<Author>

</Article>

<Article ID=B2 Year=“2005”>

<Author href=“#A1”/>

<Author ID=A2>

<Name>Bob</Name>

<Affiliation ID=UoC>

<Name>University of Cyprus</Name>

<Country ID=cy>

<Name> Cyprus</Name>

<Capital>Nicosia</Capital>

</Country>

</Affiliation>

<Author>

</Article>

<Article ID=B3 Year=“2007”>

<Author ID=A3>

<email>ps@uoc</email>

<Affiliation href=“#UoC”/>

<Author>

</Article>

<Article ID=B4 Year=“2008”>

<Publisher ID=ACM/>

</Article>

</XML>

XML

B1

A2

UoM

“Bob”

County

A1

“Tom”

B2UoC

Author

cy

mtCounty

Affiliation

p3@uoc

Affiliation

B3A3

“University of Malta”

“University of Cyprus”

2000

2005

2007

“Cyprus”

“Nicosia”

“Malta”

“Valletta”

Employs

Employs

Root

B4

2008

Artic

le

ACM

RDF

Page 27: Semantic Pipes- Web 3.0 Information Systems · Columbia University      bookinfo

Jarrar © 2011 27

Database into RDF (Example)

Person

ID Name Affiliation

A1 Tom Lara UoM

A2 Bob Hacker UoC

Article

ID Tile Year

B1 Data Web 2007

B2 Semantic Web 2005Author

Article Person

B1 A1

B1 A2

B2 A2

Country

ID Name

mt Malta

cy Cyprus

Affiliation

ID Country

UoM mt

UoC cy

RDFS P O

:B1 rdf:Type :Article:B1 :Title “Data Web”:B1 :Year 2007:B2 rdf:Type :Article:B2 :Title “Semantic Web”:B2 :Year 2005:B1 :Author :A1:B1 :Author :A2:B2 :Author :A1:A1 rdf:Type :Person:A1 :Name “Tom Lara”:A1 :Affiliation :UoM:A2 :Type :Person:A2 :Name “Bob Hacker”:A2 :Affiliation :UoC:UoM :Type :University:UoM :Country :mt:mt :Type :Country:mt :Name “Malta”:UoC :Type :University:UoC :Country :cy:cy :Type :Country:cy :Name “Cyprus”