Of 41 lecture 4: rdf – basics and language. of 41 RDF basic ideas the fundamental concepts of RDF ...

Post on 03-Jan-2016

223 views 0 download

Transcript of Of 41 lecture 4: rdf – basics and language. of 41 RDF basic ideas the fundamental concepts of RDF ...

of 41

lecture 4: rdf – basics and language

of 41

RDFbasic ideas

the fundamental concepts of RDF resources properties statements

ece 720, winter ‘12 2

of 41

RDFbasic ideas – resources

“things” we can/want to talk about for example – authors, books, publishers,

places, people, hotels, rooms, search queries …

anything that has an identity every resource has a URI

ece 720, winter ‘12 3

of 41

RDFbasic ideas – resources

URI (Uniform Resource Identifier) a character string that identifies an abstract

or physical resource on the Web it can be a URL (Uniform Resource Locator) or

some other kind of unique identifier

ece 720, winter ‘12 4

of 41

RDFbasic ideas – properties

special kind of resources they describe relations between resources for example, written by, age, title, … also identify by URIs (and in practice by URLs)

ece 720, winter ‘12 5

of 41

RDFbasic ideas – statements

assert the properties of resources it is a triple:

object-attribute-value in other words:

resource-property-value

values can either be resources or literals

ece 720, winter ‘12 6

of 41ece 720, winter ‘12 7

RDFbasic ideas – statements – three views

a triple a piece of a graph a piece of XML code

thus an RDF document can be viewed as: a set of triples a graph (semantic net) an XML document

of 41

RDFbasic ideas – statement 1st view

John Smith is the owner of the Web page http://www.ualberta.ca/~js

(http://www.ualberta.ca/~js, http://www.mydomain.org/site-owner, #JohnSmith)

ece 720, winter ‘12 8

of 41

RDFbasic ideas – statement 1st view

(http://www.ualberta.ca/~js, http://www.mydomain.org/site-owner, #JohnSmith)

(x, P, y) – logical formula P(x, y)also(S, P, O) – Subject-Property-Object

ece 720, winter ‘12 9

of 41

RDFbasic ideas – general comment

RDF offers only binary predicates (properties)

ece 720, winter ‘12 10

of 41

RDFbasic ideas – statement 2nd view

a directed graph with labeled nodes and arcs from the resource (the subject of the

statement) to the value (the object of the statement)

in AI community it is known as a semantic net

ece 720, winter ‘12 11

www.ualberta.ca/~js

#JohnSmithsite-owner

of 41

RDFbasic ideas – statement 2nd view

(http://www.ualberta.ca/~js, http://www.mydomain.org/site-owner, #JohnSmith)

(#JohnSmith, http://www.mydomain.org/phone, “7801234567”)

(#JohnSmith, http://www.mydomain.org/uses, http://www.ualberta.ca/~mk/file.cgi)

(http://www.ualberta.ca/~mk/file.cgi, http://www.mydomain.org/site-owner, “Mike Knot”)

ece 720, winter ‘12 12

of 41

RDFbasic ideas – statement 2nd view

ece 720, winter ‘12 13

www.ualberta.ca/~js

#JohnSmithsite-owner

Andrew Rockwww.ualberta.ca/

~mk/file.cgi

site-owner

7801234567

uses

phone

of 41

RDFbasic ideas – statement 3rd view

<rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:mydomain="http://www.mydomain.org/my-rdf-ns">

<rdf:Description rdf:about="http://www.ualberta.ca/js"> <mydomain:site-owner rdf:resource=“#John Smith“/>

</rdf:Description>

</rdf:RDF>

ece 720, winter ‘12 14

of 41

RDFbasic ideas – reification

it is possible to make statements about statements

Mike believes that John Smith is the creator of the web page http://www.ualberta.ca/~js

the solution: to assign a unique identifier to each statement, which can be used to refer to the statement

ece 720, winter ‘12 15

of 41

RDFbasic ideas – data types

“7801234567” – integer or string?

explicit information is needed to indicate that the literal is intended to represent a number, and which number the literal is supposed to represent – information about data type

ece 720, winter ‘12 16

of 41

RDFcritical view

only binary relations (to express: X is the referee in a chess

game between Y and Z – we need three triples: ref, player1, player2)

properties a especial kind of resourcesstatements about statementsXML-based syntax of RDF not human-friendly

ece 720, winter ‘12 17

of 41

RDFXML-based syntax

XML notation for RDF statements

ece 720, winter ‘12 18

of 41

RDFrunning example

(http://www.cat.ca/docs#R20301, http://www.mydomain.org/creator, http://www.cat.ca/author#R051156)

(http://www.cat.ca/docs#R20301, http://www.mydomain.org/title, “Karin Homepage”)

(http://www.cat.ca/docs#R20301, http://www.mydomain.org/date, “2012-12-12”)

ece 720, winter ‘12 19

of 41

RDFrunning example - graph

ece 720, winter ‘12 20

http://www.cat.ca/

docs#R20301

http://www.mydomain.org/date

2012-12-12 Karin Homepage

http://www.cat.ca/

author#R051156

http://www.mydomain.org/title

http://www.mydomain.org/creator

of 41

RDFrunning example

1 <?xml version=“1.0”?>2 <rdf:RDF3 xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# ”4 xmlns:md="http://www.mydomain.org/my-rdf-ns">

5 <rdf:Description 6 rdf:about="http://www.cat.ca/docs#R20301">7 <md:creater8 rdf:resource=“http://www.cat.ca/author#R051156“/>9 </rdf:Description>

ece 720, winter ‘12 21

of 41

RDFrunning example

10 <rdf:Description 11 rdf:about="http://www.cat.ca/docs#R20301">12 <md:title>Karin Homepage</md:title>13 </rdf:Description>

14 <rdf:Description 15 rdf:about="http://www.cat.ca/docs#R20301">16 <md:date>2012-12-12</md:date>17 </rdf:Description>

18 </rdf:RDF>

ece 720, winter ‘12 22

of 41

RDFXML-based syntax

line 3 and line 4: introduction of the rdf and md vocabularies so we can use abbreviated names

line 5: rdf:Description – indication of the beginning of a new RDF statement

line 6: rdf:about – indication of the subject of the RDF statement, its value is URI

ece 720, winter ‘12 23

of 41

RDFXML-based syntax

line 7: md:creator – it is a name from a given vocabulary (here: mydomain), it is a property of the RDF statement

line 8: rdf:resource – indication of the object of the RDF statement, its value is URI

line 9: indicates that the definition of the RDF statement is completed

ece 720, winter ‘12 24

of 41

RDFXML-based syntax

other lines – similar meaning

line 12: md:title – it is a name from a given vocabulary (here: mydomain), it is a property of the RDF statement; this line contains the value “Karin Homepage” which the object

ece 720, winter ‘12 25

of 41

RDFXML-based syntax: first modification

usage of relative URIs as a values of rdf:about or rdf:resource

done with xml:base

ece 720, winter ‘12 26

of 41

RDFrunning example – after 1st modification

1 <?xml version=“1.0”?>2 <rdf:RDF3 xml:base=http://www.cat.ca/docs”4 xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# ”5 xmlns:md="http://www.mydomain.org/my-rdf-ns">

6 <rdf:Description rdf:about=”#R20301">7 <md:creater8 rdf:resource=“http://www.cat.ca/author#R051156“/>9 </rdf:Description>

ece 720, winter ‘12 27

of 41

RDFrunning example – after 1st modification

10 <rdf:Description rdf:about=”#R20301">11 <md:title>Karin Homepage</md:title>12 </rdf:Description>

13 <rdf:Description rdf:about=”#R20301">14 <md:date>2012-12-12</md:date>15 </rdf:Description>

16 </rdf:RDF>

ece 720, winter ‘12 28

of 41

RDFXML-based syntax: second modification

rdf:ID that can be used as attribute of rdf:Description instead of rdf:about

plus property elements can be nested within an rdf:Descirption element indicating that the properties apply to the same resource

ece 720, winter ‘12 29

of 41

RDFrunning example – after 2nd modification

1 <?xml version=“1.0”?>2 <rdf:RDF xml:base=http://www.cat.ca/docs”3 xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# ”4 xmlns:md="http://www.mydomain.org/my-rdf-ns">

5 <rdf:Description rdf:ID=”R20301">6 <md:creater7 rdf:resource=“http://www.cat.ca/author#R051156“/>8 <md:title>Karin Homepage</md:title>9 <md:date>2012-12-12</md:date>10 </rdf:Description>11 </rdf:RDF>

ece 720, winter ‘12 30

of 41

RDFXML-based syntax: third modification

rdf:typethe statement (S, rdf:type, O) indicates that resource O represents a category or a class of resources, of which resource S is an instancesuch resources are called typed node elements

ece 720, winter ‘12 31

of 41

RDFrunning example – after 3rd modification

1 <?xml version=“1.0”?>2 <rdf:RDF xml:base=http://www.cat.ca/docs”3 xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# ”4 xmlns:md=http://www.mydomain.org/my-rdf-ns>5 <rdf:Description rdf:about=”#R20301">6 <rdf:type

rdf:resource=“http://www.cat.ca/schema/PersonalDoc“/> 7 <md:creater8 rdf:resource=“http://www.cat.ca/author#R051156“/>9 <md:title>Karin Homepage</md:title>10 <md:date>2012-12-12</md:date>11 </rdf:Description>12 </rdf:RDF>

ece 720, winter ‘12 32

of 41

RDFrunning example – after 3rd modification

line 6: rdf:type – indication that Karin’s homepage is a personal document, which is represented as the name http://www.cat.com/schema/PersonalDoc (vocabulary is in www.cat.com/schema)

ece 720, winter ‘12 33

of 41

RDFXML-based syntax: forth modification

rdf:type can be removed and the rdf:Description can be replaced by an element whose name is the name corresponding to the value of the removed rdf:type property

ece 720, winter ‘12 34

of 41

RDFrunning example – after 4th modification

1 <?xml version=“1.0”?>2 <rdf:RDF xml:base=http://www.cat.ca/docs”3 xmlns:cs=http://www.cat.ca/schema”4 xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# ”5 xmlns:md=http://www.mydomain.org/my-rdf-ns>6 <cs:PersonalDoc rdf:about=”#R20301”> 7 <md:creater8 rdf:resource=“http://www.cat.ca/author#R051156“/>9 <md:title>Karin Homepage</md:title>10 <md:date>2012-12-12</md:date>11 </cs:PersonalDoc>12 </rdf:RDF>

ece 720, winter ‘12 35

of 41

RDFXML-based syntax: fifth modification

rdf:datatype is an attribute of a property element and assumes as value an XML Schema datatype

ece 720, winter ‘12 36

of 41

RDFrunning example – after 5th modification1 <?xml version=“1.0”?>2 <rdf:RDF xml:base=http://www.cat.ca/docs”3 xmlns:cs=http://www.cat.ca/schema”4 xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# ”5 xmlns:md=http://www.mydomain.org/my-rdf-ns>6 <cs:PersonalDoc rdf:about=”#R20301”> 7 <md:creater8 rdf:resource=“http://www.cat.ca/author#R051156“/>9 <md:title>Karin Homepage</md:title>10 <md:date11 rdf:datatype=“http://www.w3.org/2001/XMLSchema#date”>12 2012-12-1213 </md:date>14 </cs:PersonalDoc>15 </rdf:RDF>

ece 720, winter ‘12 37

of 41

RDFXML-based syntax: reification

to address needs of representing information about RDF statements themselves

a description of a statement using RDF built-in vocabulary is called a reification of the statements

ece 720, winter ‘12 38

of 41

RDFXML-based syntax: reification

rdf:Statement is a type, and there are the properties rdf:subject, rdf:predicate, and rdf:object

ece 720, winter ‘12 39

of 41

RDFXML-based syntax: reification example

DocR20301 was created by AuthorR051156

(http://www.cat.ca/docs#R20301, http://www.mydomain.org/creator, http://www.cat.ca/author#R051156)

Sam says that DocR20301 was created by AuthorR051156

???

ece 720, winter ‘12 40

of 41

RDFXML-based syntax: reification example

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

xmlns:my="http://www.mydomain.org/schema/"> <rdf:Description> <rdf:subject resource="http://www.cat.ca/docs#R20301" /> <rdf:predicate resource="http://www.mydomain.org/creator" /> <rdf:object>http://www.cat.ca/author#R051156</rdf:object> <rdf:type resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement" /> <my:attributedTo>Sam</my:attributedTo> </rdf:Description> </rdf:RDF>

ece 720, winter ‘12 41