RDF - PowerPoint PPT Presentation

Loading...

PPT – RDF PowerPoint presentation | free to download - id: 604767-ZGEyO



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

RDF

Description:

Title: RDF Author: Michael McCarthy Last modified by: Michael McCarthy Created Date: 2/7/2009 4:02:21 AM Document presentation format: On-screen Show (4:3) – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 63
Provided by: MichaelM219
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: RDF


1

Internet Technologies
The Resource Description Framework (RDF and RDFa)
2
RDF and RDFa
  • Notes from two articles on course schedule What
    is RDF by Tim Bray and Joshua Tauberer and the
    RDFa Primer from W3C

3
A Knowledge Graph
4
Triples
Start Node Edge Label End
Node vincent_donofrio starred_in
law__order_ci law__order_ci is_a
tv_show the_thirteenth_floor similar_plot_as
the_matrix
5
Notation 3 (N3) or Turtle Format
  • _at_prefix rdf lthttp//www.w3.org/1999/02/22-rdf-syn
    tax-nsgt .
  • _at_prefix ex lthttp//www.example.org/gt .
  • exvincent_donofrio exstarred_in
    exlaw_and_order_ci .
  • exlaw_and_order_ci rdftype extv_show .
  • exthe_thirteenth_floor exsimilar_plot_as
    exthe_matrix .

6
RDF/XML
  • ltrdfRDF xmlnsrdf"http//www.w3.org/1999/02/22-r
    df-syntax-ns"
  • xmlnsex"http//www.example.org/"gt
  • ltrdfDescription rdfabout"http//www.example
    .org/vincent_donofrio"gt
  • ltexstarred_ingt
  • ltextv_show rdfabout"http//www.exam
    ple.org/law_and_order_ci" /gt
  • lt/exstarred_ingt
  • lt/rdfDescriptiongt
  • ltrdfDescription rdfabout"http//www.example
    .org/the_thirteenth_floor"gt
  • ltexsimilar_plot_as rdfresource"http//w
    ww.example.org/the_matrix" /gt
  • lt/rdfDescriptiongt
  • lt/rdfRDFgt

7
Another RDF/XML
  • ltrdfRDF xmlnsrdf"http//www.w3.org/1999/02/22-r
    df-syntax-ns"
  • xmlnsdc"http//purl.org/dc/elements/1.1/"
  • xmlnsgeo"http//www. w3.org/2003/01/geo/wgs8
    4_pos"
  • xmlnsedu"http//www.example.org/"gt
  • ltrdfDescription rdfabout"http//www.princet
    on.edu"gt
  • ltgeolatgt40.35lt/geolatgt
  • ltgeolonggt-74.66lt/geolonggt
  • lteduhasDept rdfresource"http//www.cs.p
    rinceton.edu"
  • dctitle"Department of Computer
    Science"/gt
  • lt/rdfDescriptiongt
  • lt/rdfRDFgt

8
As A Table
  • Subject Predicate Object
  • ----------------------------- -----------
    --------
  • lthttp//www.princeton.edugt eduhasDept
    lthttp//www.cs.princeton.edugt
  • lthttp//www.princeton.edugt geolat
    "40.35"
  • lthttp//www.princeton.edugt geolong
    "-74.66"
  • lthttp//www.cs.princeton.edugt dctitle
    "Department of Computer Science"

9
Notation 3
  • _at_prefix rdf lthttp//www.w3.org/1999/02/22-rdf-syn
    tax-nsgt .
  • _at_prefix dc lthttp//purl.org/dc/elements/1.1/gt .
  • _at_prefix geo lthttp//www. w3.org/2003/01/geo/wgs84
    _posgt .
  • _at_prefix edu lthttp//www.example.org/gt .
  • lthttp//www.princeton.edugt geolat "40.35"
    geolong "-74.66" .
  • lthttp//www.cs.princeton.edugt dctitle
    "Department of Computer Science" .
  • lthttp//www.princeton.edugt eduhasDept
    lthttp//www.cs.princeton.edugt .

10
From the RDFa W3C Primer
When web data meant for humans is augmented with
hints meant for computer programs, these programs
become significantly more helpful.
11
XHTML Without and With RDFa
  • All content on this site is licensed under
  • lta href"http//creativecommons.org/licenses/by/3.
    0/"gt
  • a Creative Commons License
  • lt/agt
  • All content on this site is licensed under
  • lta rel"license" href"http//creativecommons.org/
    licenses/by/3.0/"gt
  • a Creative Commons License
  • lt/agt.

The rel, in a link, describes the relationship
between the current page and the linked page.
12
A Link with a Flavor
13
Labeling Title and Author
ltdivgt lth2gtThe trouble with Boblt/h2gt
lth3gtAlicelt/h3gt ... lt/divgt ltdiv
xmlnsdc"http//purl.org/dc/elements/1.1/"gt
lth2 property"dctitle"gtThe trouble with
Boblt/h2gt lth3 property"dccreator"gtAlicelt/h3gt
... lt/divgt
RDFa introduces the property attribute.
What kind of title? A title of a person or a
title to land or a title of a work?
14
In RDFa, all property names are, in fact, URLs.
15
Multiple Items Per Page
RDFa provides _at_about, an attribute for
specifying the exact URL to which the
contained RDFa markup applies
ltdiv xmlnsdc"http//purl.org/dc/elements/1.1/"gt
ltdiv about"/alice/posts/trouble_with_bob"gt
lth2 property"dctitle"gtThe trouble with
Boblt/h2gt lth3 property"dccreator"gtAlicelt/h3
gt ... lt/divgt ltdiv about"/alice/posts
/jos_barbecue"gt lth2 property"dctitle"gtJo's
Barbecuelt/h2gt lth3 property"dccreator"gtEve
lt/h3gt ... lt/divgt lt/divgt
16
As a Diagram
17
Alice Gives Bob Credit
ltdiv about"/alice/posts/trouble_with_bob"gt
lth2 property"dctitle"gtThe trouble with
Boblt/h2gt The trouble with Bob is
that he takes much better photos than I do
ltdiv about"http//example.com/bob/photos/sunset
.jpg"gt ltimg src"http//example.com/bob/ph
otos/sunset.jpg" /gt ltspan
property"dctitle"gtBeautiful Sunsetlt/spangt
by ltspan property"dccreator"gtBoblt/spangt.
lt/divgt lt/divgt
The inner about overrides the outer about.
18
As A Graph
19
Blog Contact Info
ltdivgt ltpgt Alice Birpemswick lt/pgt
ltpgt Email lta href"mailtoalice_at_example.com"
gtalice_at_example.comlt/agt lt/pgt ltpgt Phone
lta href"tel1-617-555-7332"gt1
617.555.7332lt/agt lt/pgt lt/divgt
This is mainly useful for viewing.
20
Blog w/FOAF Contact Info
The Dublin core has no vocabulary for describing
friendships. But foaf does.
ltdiv typeof"foafPerson"
xmlnsfoaf"http//xmlns.com/foaf/0.1/"gt
ltp property"foafname"gtAlice Birpemswicklt/pgt
ltpgtEmail lta rel"foafmbox"
href"mailtoalice_at_example.com"gt
alice_at_example.comlt/a
gt lt/pgt ltpgt Phone lta
rel"foafphone"
href"tel1-617-555-7332"gt1 617.555.7332lt/agt
lt/pgt lt/divgt
The typeof is an RDFa attribute that is
specifically meant to declare a new data item
with a certain type.
21
As A Graph
Alice didn't specify _at_about like she did when
adding blog entry metadata. What is she
associating these properties with, then? In
fact, the _at_typeof on the enclosing div
implicitly sets the subject of the properties
marked up within that div. The name, email
address, and phone number are associated with a
new node of type foafPerson. This node has no
URL to identify it, so it is called a blank node.
22
Social Networks
ltdivgt ltulgt ltligt lta
href"http//example.com/bob/"gtBoblt/agt
lt/ligt ltligt lta href"http//example.c
om/eve/"gtEvelt/agt lt/ligt ltligt
lta href"http//example.com/manu/"gtManult/agt
lt/ligt lt/ulgt lt/divgt
These people are all friends of Alice and she
Includes them in her normal HTML blog.
23
Adding RDFa
First,describe these as Persons.
ltdiv xmlnsfoaf"http//xmlns.com/foaf/0.1/"gt
ltulgt ltli typeof"foafPerson"gt lta
href"http//example.com/bob/"gtBoblt/agt
lt/ligt ltli typeof"foafPerson"gt lta
href"http//example.com/eve/"gtEvelt/agt
lt/ligt ltli typeof"foafPerson"gt lta
href"http//example.com/manu/"gtManult/agt
lt/ligt lt/ulgt lt/divgt
24
Add Homepages
Use rel for the link relationships.
ltdiv xmlnsfoaf"http//xmlns.com/foaf/0.1/"gt
ltulgt ltli typeof"foafPerson"gt lta
rel"foafhomepage" href"http//example.com/bob/"
gtBoblt/agt lt/ligt ltli typeof"foafPerson
"gt lta rel"foafhomepage"
href"http//example.com/eve/"gtEvelt/agt
lt/ligt ltli typeof"foafPerson"gt lta
rel"foafhomepage" href"http//example.com/manu/
"gtManult/agt lt/ligt lt/ulgt lt/divgt
25
Describe Text as Names
ltdiv xmlnsfoaf"http//xmlns.com/foaf/0.1/"gt
ltulgt ltli typeof"foafPerson"gt lta
property"foafname"
rel"foafhomepage" href"http//example.com/bob/"
gtBoblt/agt lt/ligt ltli typeof"foafPerson
"gt lta property"foafname"
rel"foafhomepage" href"http//example.com/eve/"
gtEvelt/agt lt/ligt ltli typeof"foafPerson
"gt lta property"foafname"
rel"foafhomepage" href"http//example.com/manu/
"gtManult/agt lt/ligt lt/ulgt lt/divgt
26
Claim in Primer
Alice is ecstatic that, with so little
additional markup, she's able to fully express
both a pleasant human-readable page and a
machine-readable dataset.
27
Using foafknows
ltdiv xmlnsfoaf"http//xmlns.com/foaf/0.1/"
about"me" rel"foafknows"gt ltulgt ltli
typeof"foafPerson"gt lta
property"foafname" rel"foafhomepage"
href"http//example.com/bob"gtBoblt/agt
lt/ligt ltli typeof"foafPerson"gt lta
property"foafname" rel"foafhomepage"
href"http//example.com/eve"gtEvelt/agt
lt/ligt ltli typeof"foafPerson"gt lta
property"foafname" rel"foafhomepage"
href"http//example.com/manu"gtManult/agt
lt/ligt lt/ulgt lt/divgt
Alice knows these people with these names and
homepages.
28
(No Transcript)
29
Building Custom Vocabularies
1. Selecting a URL where the vocabulary will
reside, e.g. http//example.com/photos/vocab.
2. Distributing an RDF document, at that URL,
which defines the classes and properties
that make up the vocabulary. For example, Alice
may want to define classes Photo and
Camera, as well as the property takenWith that
relates a photo to the camera with which it
was taken. 3. Using the vocabulary in
XHTMLRDFa with the usual prefix declaration
mechanism, e.g. xmlnsphoto"http//exampl
e.com/photos/vocab", and typeof"photoCamera".
30
Microformats Compete with RDFa
hCard Business card data XFN Friends and
contacts hCalendar Events hReview Review movies,
books, etc..
When web data meant for humans is augmented with
hints meant for computer programs, these
programs become significantly more helpful.
But, perhaps we will use microformats rather
than RDFa.
31
Microformats Compete with RDFa
As an exercise, visit http//microformats.org
and build an hCard and an hCalendar. Use hCard
creator and hCalendar creator.
32
RDF On Its Own
  • RDFa is RDF in XHTML.
  • The Resource Description Framework (RDF) is a
    W3C recommendation for
  • an XML encoding of metadata.
  • A standard for encoding metadata is important
    for finding and
  • describing resources. A resource is
    anything with a URI. This would
  • include people, books, devices and so on.
  • Card catalogs, for example, have been used for
    years to record metadata
  • about the collection of materials in
    libraries. Is Google the card catalogue
  • for the web? Are we done?

33
RDF Is All About Making Statements
  • An RDF Document contains Statements.
  • A statement can be thought of as an ordered
    triple composed of three items (resource,
    property-type, property-value)
  • A Resource is anything that can be identified.
  • A Predicate is a property name that has a URI.
    The Predicate may or may not actually be
    resolvable.
  • A Value is another Resource or a literal
  • Statements may be represented in RDF XML,
    abbreviated RDF XML, N-Triples or graphs.

34
RDF Triples
It is required that each resource have a URI.
http//www.andrew.cmu.edu http//www.andrew.cmu.ed
u/mm6/my.xmlroot().child(1) mailtomm6_at_andrew.cm
u.edu urnisbn0764532367
(resource, property-type, property-value)
A property is a specific characteristic,
attribute or relationship of a resource. Each
property has a specific meaning that can be
identified by the propertys name and the
associated schema. The schema must actually be
pointed to by the propertys namespace. Using
RDF Schema we can describe the property names,
values and value ranges that are permitted for
the property.
35
A Simple Description
  • ltRDFgt
  • ltDescription about "Some URI"gt
  • ltcreatorgtproperty value
  • lt/creatorgt
  • lttitlegtproperty value
  • lt/titlegt
  • lt/Descriptiongt
  • lt/RDFgt

36
Resource Valued Property
  • ltRDFgt
  • ltDescription about "Some URI"gt
  • ltcreator rdfresource
  • "www.andrew.cmu.edu/
    mm6"/gt
  • lt/Descriptiongt
  • ltDescription about "www.andrew.cmu.edu/mm6"gt
  • ltFNgtMike McCarthylt/FNgt
  • lt/Descriptiongt
  • lt/RDFgt

37
Making Many Statements
  • ltRDFgt
  • ltDescription about "Some URI"gt
  • ltcreatorgtproperty valuelt/creatorgt
  • lttitlegtproperty valuelt/titlegt
  • lt/Descriptiongt
  • ltDescription about "Some URI"gt
  • ltcreatorgtproperty valuelt/creatorgt
  • lttitlegtproperty valuelt/titlegt
  • lt/Descriptiongt
  • lt/RDFgt

38
Blank Nodes
  • ltRDFgt
  • ltDescription about "Some URI"gt
  • ltcreatorgt
  • ltDescriptiongt
  • ltFNgtJoe Smithlt/FNgt
  • ltEMAILgtjoes_at_mycom.comlt/EMAILgt
  • lt/Descriptiongt
  • lt/creatorgt
  • lt/Descriptiongt
  • lt/RDFgt

39
XML Valued Property
  • ltRDFgt
  • ltDescription about "Some URI"gt
  • ltgenerates rdfparseType"Literal"gt
  • lthtmlgtltbodygtlt/bodygtlt/htmlgt
  • lt/generatesgt
  • lt/Descriptiongt
  • lt/RDFgt

40
A Type Property
  • ltRDFgt
  • ltDescription about SomeURL"gt
  • ltrdftype rdfresource
  • "http//www.schemas.org/www/WebPage"/
    gt
  • lt/Descriptiongt
  • lt/RDFgt

41
An Abbreviated Type Property
  • ltRDFgt
  • ltTypeName about "Some URI"gt
  • ltcreatorgtproperty value
  • lt/creatorgt
  • lttitlegtproperty valuelt/titlegt
  • lt/TypeNamegt
  • lt/RDFgt

42
RDF Notations
  • English
  • RDF XML
  • Abbreviated RDF XML
  • N-Triples
  • Graph

43
Another RDF Application Composite
Capabilities/Preference Profiles
  • The CC/PP working group was formed in August
  • 1999.
  • Its mission was to develop an RDF-based
  • framework for the management of device profile
  • information.
  • Now under W3Cs Ubiquitous Web Applications
  • Working Group (UWAWG)

44
An RDF Application CC/PP
  • A composite capability/preference profile is a
    collection
  • of information which describes the capabilities,
  • hardware, system software and applications used
    by
  • someone accessing the web. Information might
  • include
  • Preferred language (Spanish, French, etc.)
  • Sound (on/off)
  • Images (on/off)
  • Class of device (phone, PC, printer, etc.)
  • Screen size
  • Available bandwidth
  • Version of HTML supported, and so on.

45
Composite Capability/Preference Profiles (CC/PP)
DEVICE PROFILE
CC/PP provides the equivalent of database fields
and associated model for formalizing the device
profiles
CC/PP
RDF
RDF is language which provides a standard way for
using XML to represent metadata in the form
of properties and relationships of items on the
Web.
XML
The device profile and user preferences might be
stored in a CC/PP repository. CC/PP is in turn
an RDF application.
46
Composite Capability/Preference Profiles
(CC/PP)
  • The location of the device profile is sent with
    a request for
  • a Web page.
  • The CC/PP data is accessed and on the basis of
    the
  • profile, a Web server can choose the right
    content. This
  • might be a certain XHTML file or perhaps a
    suitable
  • document would be generated on the fly.
  • A document on the server may refer to its own
    document
  • profile-describing the required capabilities
    of its client.
  • The server might match and send or generate and
    send.

47
Each variant of the document has a document
profile describing the browser support it needs
to display it
DEVICE PROFILES
DOCUMENT PROFILES
NEGOTIATE CORRECT CONTENT FOR DEVICES
If none of the document variants are
suitable, existing document may be transformed by
style sheet or tool for the purpose, or new
document generated
DEVICES RECEIVE RIGHT MARK-UP
48
Processing RDF in Java
  • XSLT?
  • DOM?
  • SAX?
  • StAX?
  • Open source Jena from HP Research provides
    another approach

49
Jena Example 1
  • // Modified from HP's Jena Tutorial
  • // /mm6/www/95-733/examples/Jena
  • import com.hp.hpl.jena.rdf.model.
  • import com.hp.hpl.jena.vocabulary.
  • public class Tutorial01 extends Object
  • // some definitions
  • static String personURI
    http//somewhere/JohnSmith
  • static String fullName "John Smith"

50
public static void main (String args)
// create an empty model (An empty RDF graph)
Model model ModelFactory.createDefaultMode
l() // create the resource
Resource johnSmith model.createResource(personUR
I) // add the property
johnSmith.addProperty(VCARD.FN, fullName)
model.write(System.out)
51
D\McCarthy\www\95-733\examples\Jenagtjava
Tutorial01 ltrdfRDF xmlnsrdf"http//www.w3.
org/1999/02/22-rdf-syntax-ns"
xmlnsvcard"http//www.w3.org/2001/vcard-rdf/3.0
" gt ltrdfDescription rdfabout"http//somewh
ere/JohnSmith"gt ltvcardFNgtJohn
Smithlt/vcardFNgt lt/rdfDescriptiongt lt/rdfRDFgt
52
A Resource Valued Predicate
  • // Modified from HP's Jena Tutorial
  • import com.hp.hpl.jena.rdf.model.
  • import com.hp.hpl.jena.vocabulary.
  • public class Tutorial03 extends Object
  • public static void main (String args)
  • String personURI "http//somewhere/Jo
    hnSmith"
  • String givenName "John"
  • String familyName "Smith"
  • String fullName givenName " "
    familyName
  • // create an empty model
  • Model model ModelFactory.createDefaultMo
    del()

53
// create the resource // and
add the properties cascading style
Resource johnSmith model.createResource(personU
RI)
.addProperty(VCARD.FN, fullName)

.addProperty(VCARD.N,
model.createResource
()
.addProperty(VCARD.Given,
givenName)
.addProperty(VCARD.Fa
mily, familyName))
54
// list the statements in the graph
StmtIterator iter model.listStatements()
// print out the predicate, subject and
object of each statement while
(iter.hasNext()) Statement
stmt iter.nextStatement() // get next
statement Resource subject
stmt.getSubject() // get the subject
Property predicate stmt.getPredicate()
// get the predicate RDFNode
object stmt.getObject() // get the
object System.out.print(subject.
toString()) System.out.print("
" predicate.toString() " ")
55
if (object instanceof Resource)
System.out.print(object.toString())
else // object
is a literal System.out.print("
\"" object.toString() "\"")
System.out.println(" .") //
end while System.out.println("
") model.write(System.out)

56
D\McCarthy\www\95-733\examples\Jenagtjava
Tutorial03 16fa474fd074695f6-8000
http//www.w3.org/2001/vcard-rdf/3.0Given
"John" . http//somewhere/JohnSmith
http//www.w3.org/2001/vcard-rdf/3.0FN "John
Smith" . 16fa474fd074695f6-8000
http//www.w3.org/2001/vcard-rdf/3.0Family
"Smith" . http//somewhere/JohnSmith
http//www.w3.org/2001/vcard-rdf/3.0N
16fa474fd074695f6-8000 . ltr
dfRDF xmlnsrdf"http//www.w3.org/1999/02/22
-rdf-syntax-ns" xmlnsvcard"http//www.w3.or
g/2001/vcard-rdf/3.0" gt ltrdfDescription
rdfnodeID"A0"gt ltvcardGivengtJohnlt/vcardGive
ngt ltvcardFamilygtSmithlt/vcardFamilygt
lt/rdfDescriptiongt ltrdfDescription
rdfabout"http//somewhere/JohnSmith"gt
ltvcardFNgtJohn Smithlt/vcardFNgt ltvcardN
rdfnodeID"A0"/gt lt/rdfDescriptiongt lt/rdfRDFgt
Notes 16fa is a blank node with family and
given properties. The main resource has a blank
node as the value of the N property. The main
resource also has a FN property with a value.
57
Reading OWL with Jena
  • import com.hp.hpl.jena.rdf.model.
  • import com.hp.hpl.jena.ontology.
  • import java.io.
  • import java.net.
  • public class ReadWineOntology extends Object
  • public static void main (String args)
    throws Exception
  • // create an empty model
  • OntModel model ModelFactory.createOntolo
    gyModel()

58
// read the wine.xml file either way
model.read("fileD/McCarthy/www/95-733/example
s/Jena/wine.xml")
//model.read("http//www.andrew.cmu.edu/user/mm6/o
ntology/wine.xml") // write
it to standard out model.write(System.out
)
The next step is to use Jena to make or verify
deductions.
59
The Semantic Web
These notes are from an article entitled The
Semantic Web by Tim Berners-Lee, James Hendler
and Ora Lassila appearing in Scientific American,
May 2001
By augmenting web pages with data directed at
computers and by adding documents solely for
computers, we will transform the web into the
Semantic Web. Intuitive software will be
developed that will allow anyone to create
Semantic Web Pages. For the semantic web to
function, computers must have access to
structured collections of information and sets of
inference rules that can be used to conduct
automated reasoning. XML has no built-in
mechanism to convey the meaning of the users new
tags to other users.
60
The Semantic Web
The challenge of the Semantic Web is to provide a
language that expresses both data and rules for
reasoning about the data and that allows rules
from an existing knowledge-representation system
to be exported unto the Web. Ontologies
Collections of statements written in a language
such as RDF that define the relations between
concepts and specify logical rules for reasoning
about them. Computers will understand the
meaning of semantic data on a web page
by following links to specified
ontologies. Consider the statement a hex-head
bolt is a type of machine bolt. We could encode
this in RDF. When writing code against
traditional XML data, the programmer must know
what the the document author uses each tag for.
Meaning is expressed by RDF, which encodes it
in a set of triples.

61
The Semantic Web
An RDF document makes assertions that particular
things (people, web pages, or whatever) have
properties (such as is sister of, is the
author of) with certain values (another person,
another Web page). We can remove ambiguity by
associating each of the three parts with a URI.
For example (filed 5 in database A) (is a
field of type) (zip code) could be replaced
with three URIs. An ontology is a
document or file that formally defines the
relations among terms. An ontology may express a
rule If a city code is associated with a state
code, and an address uses that city code, then
that address has the associated state code. A
program can then draw conclusions. The meaning
of terms or XML codes can be defined by pointers
from the page to an ontology.
62
The Semantic Web
Many automated web based services already exist
without semantics, but other programs such as
agents have no way to locate one that will
perform a specific function. Service Discovery
will happen only when there is a common language
to describe a service in a way that lets other
agents understand both the function offered
and how to take advantage of it. Services can
advertise their functions in directories
analogous to the Yellow Pages. Devices can
advertise their abilities with RDF.
About PowerShow.com