04a. Resource Description Framework

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 54

Module 3, Part 1

Resource Description Framework

Plaban Kumar Bhowmick


Assistant Professor
Centre of Excellence in Artificial Intelligence
Indian Institute of Technology Kharagpur
Semantic Web Stack: Layer Cake
Resource Description Framework
 Resources are core concepts of Semantic Web
 Everything is a resource
▪ Web page, image, video, person, product, device etc
▪ Everything that can be identified by a URI is resource

 Description of resources
 Description is a set of attributes, features and relation concerning a resource (metadata)
 Essential for understanding and reasoning about resources

 The Framework
 Provided models, languages and syntaxes for the descriptions
Resource Description Framework (RDF)
RDF is a graph based data model
dbr:Lionel_Messi

rdf:type
dbo:currentMember
dbo:position

dbr:FC_Barcelona dbo:SoccerPlayer

dbr:Forward_(association_football)

dbo: <http://dbpedia.org/ontology/>
dbr: <http://dbpedia.org/resource/>
RDF: Why Graph Model?

 Tree based models have been used to organize electronic


documents
 HTML, XML
 Why RDF is relying on graph?
 Describe relations not for structuring documents
▪ Descriptions form a graph
 Information in WWW is decentralized
▪ Connecting two graphs creates a graph
▪ Connecting two trees may not be a tree anymore
Triples as Atoms of Knowledge

rdf:type
dbr:Lionel_Messi dbo:SoccerPlayer

dbo:position dbr:Forward_(association_
dbr:Lionel_Messi
football)

dbo:currentMember dbr:FC_Barcelona
dbr:Lionel_Messi

PREDICATE OBJECT
SUBJECT
Triples as Atoms of Knowledge
Amitav Ghosh has written a thriller book ‘The Calcutta
Chromosome’
(The_Calcutta_Chromosome, author, Amitav_Ghosh)
(The_Calcutta_Chromosome, theme, “thriller”)

Literal
URI

(The_Calcutta_Chromosome, author, “Amitav Ghosh”)


Triples as Atoms of Knowledge

 RDF triples are axiomatic statements


 Facts that can be seen as binary predicates in logic

 RDF follows an open world assumption


 facts that are not explicitly claimed can be true
Graph Oriented Data Model
RDF is a distributed data model

ex:cites

ex:augments
ex:paper1 ex:paper2

ex:hasCoAuthor

Multi graph Directed graph Labelled graph


Graph Oriented Data Model
The book Foundations of Semantic Web Technologies (FSWT) has been authored by Sebastian Rudolph,
Markus Kroetzsch, Pascal Hitzler, the theme is semantic web and has 456 pages

Logic Predicates Triples


Book(FSWT) (FSWT, type, Book)
creator(FSWT, Sebastian Rudolph) (FSWT, creator, Sebastian Rudolph)
creator(FSWT, Markus Kroetzsch) (FSWT, creator, Markus Kroetzsch)
creator(FSWT, Pascal Hitzler) (FSWT, creator, Pascal Hitzler)
theme(FSWT, Semantic Web) (FSWT, theme, Semantic Web)
noPages(FSWT, 456) (FSWT, noPages, 456)
Graph Oriented Data Model
type http://...#Book
..#
: //..
http
or
c reat
/ / ....# http://...#Sebastian
:
http

tor
http://....#crea http://...#Kroetzsch

http://....#crea
http://...#FSWT.pdf tor
http://...#Hitzler

http:/
/....#
theme
http://...#SW
http:/
/....#
noPage
s
456
Conceptual Vocabularies through Namespaces

 Everything in SW is a resource
 So do types of resources and relations
 Relations and resource types are represented through customized vocabulary
▪ Each of the entries has a URI and is defined wrt a base URI
▪ Namespace
 Namespace
 rdf
▪ http://www.w3.org/1999/02/22-rdf-syntax-ns#
 rdf:type
▪ http://www.w3.org/1999/02/22-rdf-syntax-ns#type
Conceptual Vocabularies through Namespaces
(http://example.org/FSWT.pdf , rdf:type , exs:Book)
(http://example.org/ FSWT.pdf, dc:creator , exr:Sebastian)
(http://example.org/ FSWT.pdf, dc:creator , exr:Kroetzsch)
((http://example.org/ FSWT.pdf, dc:creator , exr:Hitzler)
(http://example.org/ FSWT.pdf, exs:theme , exr:SW)
(http://example.org/ FSWT.pdf, exs:noPages , ‘‘456’’)

• dc
• http://purl.org/dc/elements/1.1/
• exs
• http://example.org/schema#
• exr
• http://example.org#
Data Values in RDF

 URIs are means to identify resources


 e.g., a person can be identified by an URI
▪ What about age or height of a person?

 Data values are represented with literals


 Value string along with datatype
▪ “25” and “025” represent same value given Integer data type
 RDF uses XML datatypes

XML Datatypes: https://www.w3.org/TR/xmlschema-2/


Data Values in RDF

 Typed Vs Untyped literals


@prefix xsd: <http://www.w3.org/2001/XMLSchema.org#>

<http://example.org/FSWT.pdf>
<http://purl.org/dc/elements/1.1/title> “Foundation of SWT”^^xsd:string;
< http://purl.org/dc/elements/1.1/title> “2009-08-06”^^xsd:date.

 Language setting

<http://example.org/FSWT.pdf>
<http://purl.org/dc/elements/1.1/title> “Foundation of SWT”@en;
Data Values in RDF

Language, Typed and Untyped

@prefix xsd: <http://www.w3.org/2001/XMLSchema.org#>

<https://mitpress.mit.edu>
<http://example.org/name> “MIT Press”^^xsd:string,
“MIT Press”@en,
“MIT Press”.

Lexical Space Vs Value Space


RDF Serializations: N-Triples
<http://example.org/FSWT.pdf> N-Triples
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://example.org/schema#Book>.

<http://example.org/FSWT.pdf>
<http://example.org/schema#theme>
<http://example.org#Semantic_Web>.

<http://example.org/FSWT.pdf>
http://purl.org/dc/elements/1.1/creator>
<http://example.org#Sebastian>.

<http://example.org/ FSWT.pdf >


<http://example.org/schema#noPages>
‘‘456’’^^<http://www.w3.org/2001/XMLSchema#integer>.
RDF Serializations: Turtle
Turtle
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix exs: <http://example.org/schema#>.
@prefix dc: <http://purl.org/dc/elements/1.1/>.

<http://example.org/FSWT.pdf> rdf:type exs:Book ;


<http://example.org/FSWT.pdf> exs:theme
<http://example.org#Semantic_Web>;
<http://example.org/FSWT.pdf > dc:creator
<http://example.org#Sebastian> ;
<http://example.org/FSWT.pdf > dc:creator
<http://example.org#Kroetzsch> ;
<http://example.org/FSWT.pdf> exs:noPages ‘‘456’’^^xsd:int.
RDF Serializations: Turtle
Turtle

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


@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix exs: <http://example.org/schema#>.
@prefix exr: <http://example.org#>.
@prefix dc: <http://purl.org/dc/elements/1.1/>.

<http://example.org/FSWT.pdf> rdf:type exs:Book ;


exs:theme <http://example.org#Semantic_Web>;
dc:creator <http://example.org#Sebastian>;
dc:creator <http://example.org#Kroetzsch>;
exs:noPages ‘‘456’’^^xsd:int.
RDF Serializations: Turtle

Turtle
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix exs: <http://example.org/schema#>.
@prefix exr: <http://example.org/#>.
@prefix dc: <http://purl.org/dc/elements/1.1/>.

<http://example.org/FSWT.pdf> a exs:Book ;
exs:theme <http://example.org#SW>,
dc:creator <http://example.org#Sebastian>,
<http://example.org#Kroetzsch>;
exs:nbPages ‘‘23’’^^xsd:int.

a stands for rdf:type


RDF Serializations

RDF/XML
<?xml version=‘‘1.0’’?>
<rdf:RDF xmlns:rdf=‘‘http://www.w3.org/1999/02/22-rdf-syntax-ns#’’
xmlns:exs=‘‘http://example.org/schema#’’
xmlms:dc=‘‘http://purl.org/dc/elements/1.1/’’>

<rdf:Description rdf:about=‘‘http://example.org/FSWT.pdf’’>
<rdf:type rdf:resource=‘‘http://example.org/schema#Book’’/>
<exs:theme rdf:resource=‘‘http://example.org#Semantic_Web’’/>
<dc:creator rdf:resource=‘‘http://example.org#Sebastian’’/>
<exs:noPages>456</exs:nbPages>
</rdf:Description>
</rdf:RDF>
RDF Serializations

RDF/XML
<?xml version=‘‘1.0’’?>
<rdf:RDF xmlns:rdf=‘‘http://www.w3.org/1999/02/22-rdf-syntax-ns#’’
xmlns:exs=‘‘http://example.org/schema#’’
xmlms:dc=‘‘http://purl.org/dc/elements/1.1/’’>

<exs:Book rdf:about=‘‘http://example.org/FSWT.pdf’’ noPages=‘‘456’’


<exs:theme rdf:resource=‘‘http://example.org#Semantic_Web’’/>
<dc:creator rdf:resource=‘‘http://example.org#Sebastian’’/>
</exs:Book>
</rdf:RDF>

For more details: http://www.w3.org/TR/REC-rdf-syntax/


Existential Quantification: Blank Nodes

 How do we describe anonymous resource?

(http://example.org/FSWT.pdf , rdf:type , exs:Book)


(http://example.org/FSWT.pdf, dc:creator , exr:Sebastian)
(http://example.org/FSWT.pdf, dc:creator , _:abc)
(_:abc, foaf:firstName, ‘‘Markus’’^^xsd:string)
(_:abc, foaf:lastName, ‘‘Kroetzsch’’^^xsd:string)
(_:abc, rdf:type, foaf:Person)
(http://example.org/FSWT.pdf, exs:theme , exr:Semantic_Web)
(http://example.org/FSWT.pdf , exs:noPages , ‘‘456’’^^xsd:int)
Existential Quantification: Blank Nodes

t ype exs:Book
exs:SW rdf:

eator
dc:cr exr:Sebastian
``456’’^^xsd:int exs:theme
rdf:type foaf:Person

exs:noPages dc:creator
_:abc

exr:FSWT.pdf

foaf:firstName foaf:lastName

Blank Node ‘‘Markus’’^^xsd:string ‘‘Kroetzsch’’^^xsd:string


RDF: Open Containers

 Containers are open groups


 Contain unspecified number of resources or literals
 May have duplicate entries

 Three types of containers


 rdf:Bag defines an unordered group of resources or literals.
 rdf:Seq defines an ordered group of resources or literals.
 rdf:Alt represents a group of resources or literals that are alternatives
Open Container: Bag
The Indian Cricket Team has Virat Kohli, Rohit Sharma and Mahammad Shami as Players

rdf:Bag

exr:Virat
rdf:type _1
f:
rd

exr:Indian_Team rdf:_2
ex:hasPlayer exr:Rohit
rd
f :_
3

exr:Shami
Open Container: Bag
The Indian Cricket Team has Virat Kohli, Rohit Sharma and Mahammad Shami as Players

<?xml version="1.0" encoding="utf-8"?> RDF/XML


<!DOCTYPE rdf:RDF[<!ENTITY exr 'http://example.org/'>]>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:exs="http://example.org/schema#">
<rdf:Description rdf:about="&exr;Indian_Team">
<exs:hasPlayer>
<rdf:Bag>
<rdf:li rdf:resource="&exr;Virat"/>
<rdf:li rdf:resource="&exr;Rohit"/>
<rdf:li rdf:resource="&exr;Shami"/>
</rdf:Bag>
</ex:isAttendedBy>
</rdf:Description>
</rdf:RDF>

Validate RDF/XML: https://www.w3.org/RDF/Validator/


Open Container: Sequence (Seq)
The Innings was played by Dhawan, Rahul, Virat, …… [in that order]

rdf:Seq

exr:Dhawan
rdf:type _1
f:
rd

exr:Innings_x rdf:_2
ex:batsman exr:Rahul
rd
f :_
3
……….

exr:Virat
Open Container : Alternative (Alt)
The Indian Team can have the wicketkeeper to be one of Rishabh Pant, Wriddhiman Saha or KL Rahul

rdf:Alt

exr:Pant
rdf:type _1
f:
rd

exr:Indian_Team rdf:_2
ex:wicketkeeper exr:Rahul
rd
f :_
3
……….

exr:Wriddhiman
Closed Collections

 Containers cannot make sure the list is complete

 Collections
 To represent closed list
Closed Collections
Mahammad Shami took wickets of David Warner, Steve Smith and Aron Finch in order

exr:Shami

ex:wickets
rdf:first
pe exr:Warner
: ty
rdf rdf:rest
rdf:type rdf:first
rdf:List exr:Smith
rd
f :t rdf:rest
yp
e rdf:first exr:Finch
rdf:rest
rdf:nil
Closed Collection
Mahammad Shami took wickets of David Warner, Steve Smith and Aron Finch in order

<?xml version="1.0"?> RDF/XML


<!DOCTYPE rdf:RDF[<!ENTITY exr 'http://example.org/'>]>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ex="http://example.org#">
<rdf:Description rdf:about="&exr;Shami">
<ex:wickets rdf:parseType="Collection">
<rdf:Description rdf:about="&exr;Warner"/>
<rdf:Description rdf:about="&exr;Smith"/>
<rdf:Description rdf:about="&exr;Finch"/>
</ex:wickets>
</rdf:Description>
</rdf:RDF>
RDF Validator: http://www.w3.org/RDF/Validator/
Reification: Statement about Statement
Arthur Weasley suspected that Lucius did actually support the Dark Lord

Arthur suspected supported


Luicius Dark_Lord
Weasley
Reification
rdf:Statement

rdf:subject rdf:predicate rdf:object

Lucius did actually support the Dark Lord


Reification: RDF Graph
Arthur Weasley suspected that Lucius did actually support the Dark Lord

bject
rdf:su :Lucius
:Arthur_Weasley

:suspected rdf:predicate
:supported

rdf:object
:The_Dark_Lord

rdf:type

rdf:Statement
Reification: Turtle Descrption

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


@prefix : <http://example.org/HarryPotterStories#>.

:Arthur_Weasley :suspected _:abc


_:abc a rdf:Statement;
rdf:subject :Lucius;
rdf:predicate :supported;
rdf:object :The_Dark_Lord.
RDF Vocabulary
 RDF defines a number of resources and properties
 rdf:type, rdf:Bag. . .

 RDF vocabulary: http://www.w3.org/1999/02/22-rdf-syntax-ns#


 Classes:
 rdf:Property , rdf:Statement, rdf:XMLLiteral
 rdf:Seq , rdf:Bag, rdf:Alt, rdf:List

 Properties:
 rdf:type , rdf:subject, rdf:predicate, rdf:object,
 rdf:first , rdf:rest, rdf:_n
 rdf:value

 Resources:
 rdf:nil
RDF Vocabulary

 Typing using rdf:type:


<A, rdf:type, B>
“A belongs to class B”

 All properties belong to class rdf:Property:


<P, rdf:type, rdf:Property>
“P is a property”

<rdf:type, rdf:type, rdf:Property>


“rdf:type is a property”
RDF: Lack of Inferential Ability
 Fabien is a Man
Fabien is a Person
Fabien is an LivingBeing

 RDF representation L
 ex:Fabien rdf:type ex:Person P
 ex:Fabien rdf:type ex:Man
 ex:Fabien rdf:type ex:LivingBeing M

 Employ inference
 ex:Fabien rdf:type ex:Man
ex:Fabien rdf:type ex:Person
ex:Fabien rdf:type ex:LivingBeing
Terminological Vs. Assertional Knowledge
Terminological
isA LivingBeing
Person
isMotherOf Mother
Schema
isA isA isA
Man Woman

type
type
type

isMotherOf
Fabien Jane Data

Assertional
RDF Schema (RDFS)

 What is Schema?
 Impose intended structure over data
▪ Organization of data
▪ Schema helps in performing inference over data
 Defines the terminological knowledge

 RDF Schema
 Imposes structure over RDF data
RDFS: RDF Vocabulary Description Language

 Types in RDF:
<john, rdf:type, Student>

 What is a “Student”?

 RDF does not define vocabulary


 only to express statements

 “Student” identifies a set (a concept or a class)


RDFS: RDF Vocabulary Description Language

 We need a language for defining RDF types:

 Define classes:
▪ “Student is a class”
 Relationships between classes:
▪ “Student is a sub-class of Person”
 Properties of classes:
▪ “Person has a property hasName”

 RDF Schema is such a language


RDFS: RDF Vocabulary Description Language

 Classes:
<Student, rdf:type, rdfs:Class>

 Class hierarchies:
<Student, rdfs:subClassOf, Person>

 Properties:
<hasName, rdf:type, rdf:Property>

 Property hierarchies:
<hasMother, rdfs:subPropertyOf,hasParent>
RDFS: RDF Vocabulary Description Language
 Associating properties with classes (a):
 “The property hasName only applies to Person”
<hasName, rdfs:domain, Person>
 Associating properties with classes (b):
 “The type of value the property hasName is xsd:string”
<hasName, rdfs:range, xsd:string>

Domain Range
Person hasName xsd:string
Domain and Range
Restrict the possible values (instances) of subjects and object
of a given property to members of a specific class or type

PREDICATE
SUBJECT (PROPERTY) OBJECT

Domain: Range:
The subject of the property in The object of the property
the RDF triple must be a in the RDF triple must be a
member of a specific class member of a specific class
[or a literal]

Subproperties inherit the domain and range of their superproperties


Ontology and RDFS

 Classes
 Class-Subclass hierarchy
RDFS Ontology
 Properties
 Sub-properties

 Instances RDF Data


 Specific members of a class
Class Hierarchy Example
Property Example

hasChild

isChildOf

hasFather
hasMother
RDF Schema (RDFS)
RDF Vocabulary Description Language
• rdfs:Resource • rdfs:subClassOf
• class of all resources • relates a class to one of its
• rdfs:Class superclass
• class of all classes • rdfs:subPropertyOf
• rdfs:Literal • Relates a property to one of
• class of all literals its superproperties
• rdf:Property • rdfs:Domain
• class of all properties • Specifies the domain of a
• rdf:Type property
• relates a resource to its • rdfs:Range
class • Specifies the range of a
property
RDFS Example
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdfs:Class rdf:ID="Musician">
<rdfs:Class rdf:ID="IndianClassicalMusician">
<rdfs:subClassOf rdf:resource="#Musician"/>
</rdfs:Class>
<rdf:Property rdf:ID=“performsWith">
<rdfs:domain rdf:resource="#Instrumentalist"/>
<rdfs:range rdf:resource="#MusicInstrument"/>
</rdf:Property>
<rdf:Property rdf:ID=“performsIn">
<rdfs:domain rdf:resource="#Musician"/>
<rdfs:range rdf:resource="#Concert"/>
</rdf:Property>
</rdf:RDF>
Person
ISA ISA
Male ISA
Female
Musician
Concert
performsIn
ISA

RDFS RaagaMusic
plays
IndianClassicalMusician
Ontology ISA
ISA

Vocalist Instrumentalist

performsWith

MusicInstrument

Flute

RDF pe
r fo
rm
sW
Raaga_yaman it
Individual/ play
s
h

Instance performs
I n Hariprasad_Chaurasia
Dover_Lane_Music_Conference
S rdfs:Resource RDFS Vocabulary and Relation
rdfs:Literal
S T S
T
S S
rdfs:Class T rdf:type
rdf:Property
rdfs:XMLLiteral
T T
S T rdfs:label
rdfs:ConstraintResource
T
T T
S rdfs:comment
S
rdfs:ConstraintProperty
rdfs:subClassOf
T T

T rdfs:domain rdfs:range rdfs:subPropertyOf

rdfs:ContainerMembershipProperty
T T T
S = rdfs:subClassOf
rdf:_1 rdf:_2 rdf:_n
T = rdf:type
Coming up next…..

Resource Description Framework


and Logic

You might also like