660 likes | 836 Views
RDF: Resource Description Framework. Jianguo Lu University of Windsor. Contents. Ontology Syntax of RDF and RDFS Axiomatic Semantics for RDF and RDFS Applications of RDF and RDFS Querying of RDF/RDFS Documents . Web Today. [Hendler & Miller 02]. The semantic web. Ontology.
E N D
RDF: Resource Description Framework Jianguo Lu University of Windsor
Contents • Ontology • Syntax of RDF and RDFS • Axiomatic Semantics for RDF and RDFS • Applications of RDF and RDFS • Querying of RDF/RDFS Documents
Web Today [Hendler & Miller 02]
Ontology • Long history coming from Philosophy, introduced by Aristotle • “a branch of metaphysics concerned with the nature and relations of being” --Webster • Picked up by the Artificial Intelligence • “For AI systems, what ‘exists’ is that which can be represented” • “a shared and common understanding of some domain that can be communicated between people and application systems” – Gruber
What is Ontology • An ontology is a formal, explicit specification of a shared conceptualization - Gruber • Conceptualizationrefers to an abstract model of phenomena. • Explicit means that the type of concepts used, and the constraints on their use are explicitly defined. • For example, in medical domains, the concepts can be diseases and symptoms, the relations between them are causal and a constraint is that a disease cannot cause itself. • Formal refers to the fact that the ontology should be machine readable. • Not described in natural language • Shared reflects that ontology should capture consensual knowledge accepted by the communities. • it is not private to some individual, but accepted by a group
Main components of an Ontology • Classes: concepts of the domain or tasks, which are usually organized in taxonomies • in a university ontology, student and professor are two classes • Relations: a type of interaction between concepts of the domain • such as: subclass-of, is-a • Axioms: model sentences that are always true • such as: if the student attends both A and B course, then he or she must be a second year student • Instances: to represent specific elements • such as: a student called Peter is the instance of Student class
Contents • Ontology • Syntax of RDF and RDFS • Semantics • Applications
RDF is a Web Standard • RDF Model and Syntax Specification became a W3C (World Wide Web Consortium) Recommendation in February 1999. • It has a “long” history, considering that XML became W3C Recommendation in 1998. • The purpose of RDF (Resource Description Framework) is to give a standard way of specifying data "about" something.
XML vs. RDF <company> <treatmentOffered>Physiotherapy</treatmentOffered> <companyName>Agilitas Physiotherapy Centre </companyName> <staff> <therapist>Lisa Davenport</therapist> <therapist>Steve Matthews</therapist> <secretary>Kelly Townsend</secretary> </staff> … … </company> • How to answer the query “give me the list of staff members in this company”? • XML provides semantic information as a by-product of defining the structure of the document • XML prescribes a tree structure for documents and the different leaves of the tree have a well-defined tag and context the information can be understood with. • That is, structure and semantics of documents are interwoven • there is no intended meaning associated with the nesting of tags • It is up to each application to interpret the nesting.
staff subClassOf subClassOf therapist secretary RDF and RDF Schema • RDF isA therapist Lisa • RDF Schema How to encode the rule that “a person can not be a secretary and therapist at the same time”?
OWL (Web Ontology Language) isA therapist Lisa RDF isA secretary staff RDFS subClassOf therapist secretary OWL Disjoint (therapist, secretary)
Basic Ideas of RDF • David Billington is a lecturer of Discrete Maths <course name="Discrete Maths"> <lecturer>David Billington</lecturer> </course> <lecturer name="David Billington"> <teaches>Discrete Maths</teaches> </lecturer> • Opposite nesting, same information! • Basic building block of rdf: subject-predicate-object triple • It is called a statement; • Sentence about Billington is such a statement; <rdf:RDF xmlns: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.cit.gu.edu.au/DiscreteMath"> <mydomain:taughtBy> David Billington </mydomain:taughtBy> </rdf:Description> </rdf:RDF>
predicate Subject Object Equivalent! property Resource Value Statements • Statements assert the properties of resources • A statement is an resource-property-value triple • Sometimes also called subject, predicate, and value • Values can be resources or literals • Literals are atomic values (strings)
Resource in a statement • We can think of a resource as a “thing” we want to talk about • E.g. authors, books, publishers, places, people, hotels; • Every resource has a URI, a Universal Resource Identifier; • A URI can be • a URL (Web address), or • some other kind of unique identifier. • In the following example, “http://www.cit.gu.edu.au/DiscreteMath” is a resource that we want to talk about. <rdf:RDF xmlns: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.cit.gu.edu.au/DiscreteMath"> <mydomain:taughtBy> David Billington </mydomain:taughtBy> </rdf:Description> </rdf:RDF>
Properties • Properties are a special kind of resources • They describe relations between resources • E.g. “taught by”, “written by”, “age”, “title”, etc.; • Properties are also identified by URIs. • Advantages of using URIs: • Α global, worldwide, unique naming scheme; • Reduces the homonym problem of distributed data representation. • <rdf:RDF xmlns: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.cit.gu.edu.au/DiscreteMath"> • <mydomain:taughtBy> David Billington </mydomain:taughtBy> • </rdf:Description> • </rdf:RDF>
Three Views of a Statement • 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.
RDF Example • The statement: http://www.example.org/index.html has a creation-date whose value is August 16, 1999 <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exterms="http://www.example.org/terms/"> <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date>August 16, 1999</exterms:creation-date> </rdf:Description> </rdf:RDF>
Its XML representation • A complete representation <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date>August 16, 1999</exterms:creation-date> </rdf:Description> <rdf:Description rdf:about="http://www.example.org/index.html"> <dc:language>en</dc:language> </rdf:Description> <rdf:Description rdf:about="http://www.example.org/index.html"> <dc:creator rdf:resource="http://www.example.org/staffid/85740"/> </rdf:Description> • An abbreviation <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date> August 16, 1999 </exterms:creation-date> <dc:language> en </dc:language> <dc:creator rdf:resource="http://www.example.org/staffid/85740"/> </rdf:Description>
Two different kinds of nodes • Nodes that are URIrefs are shown as ellipses • Nodes that are literals are shown as boxes • Using URIref to identify resource and property
Structured Property Values and Blank Nodes Problem with this approach: may generate many intermediate URIRefs.
Corresponding RDF/XML <?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:exterms="http://example.org/terms/"> <rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar"> <dc:title>RDF/XML Syntax Specification (Revised)</dc:title> <exterms:editor rdf:nodeID="abc"/> </rdf:Description> <rdf:Description rdf:nodeID="abc"> <exterms:fullName>Dave Beckett</exterms:fullName> <exterms:homePage rdf:resource="http://purl.org/net/dajobe/"/> </rdf:Description> </rdf:RDF>
Typed literals • 27 is an integer or a string?
A Typed Literal for a Web Page's Creation Date <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exterms="http://www.example.org/terms/"> <rdf:Description rdf:about="http://www.example.org/index.html"> <exterms:creation-date rdf:datatype="&xsd;date">1999-08-16 </exterms:creation-date> </rdf:Description> </rdf:RDF>
RDF Containers • Container is a resource to contain things • RDF defines three types of containers: • Bag: contains an unordered list of value elements • Seq: contains an ordered list of value elements • Alt: contains a list of alternative values for an element:
Bag (cont.) <rdf:Description rdf:about="http://example.org/courses/6.001"> <s:students> <rdf:Bag> <rdf:li rdf:resource="http://example.org/students/Amy"/> <rdf:li rdf:resource="http://example.org/students/Mohamed"/> <rdf:li rdf:resource="http://example.org/students/Johann"/> <rdf:li rdf:resource="http://example.org/students/Maria"/> <rdf:li rdf:resource="http://example.org/students/Phuong"/> </rdf:Bag> </s:students> </rdf:Description>
Alt container (cont.) <rdf:Description rdf:about="http://example.org/packages/X11"> <s:DistributionSite> <rdf:Alt> <rdf:li rdf:resource="ftp://ftp.example.org"/> <rdf:li rdf:resource="ftp://ftp1.example.org"/> <rdf:li rdf:resource="ftp://ftp2.example.org"/> </rdf:Alt> </s:DistributionSite> </rdf:Description>
RDF Collection • A container only says that certain resources are members • It does not say that other members do not exist • <rdf:Description rdf:about="http://example.org/courses/6.001"> • <s:students rdf:parseType="Collection"> • <rdf:Description rdf:about="http://example.org/students/Amy"/> • <rdf:Description rdf:about="http://example.org/students/Mohamed"/> • <rdf:Description rdf:about="http://example.org/students/Johann"/> • </s:students> • </rdf:Description>
RDF Reification • In RDF it is possible to make statements about statements • Grigoris believes that David Billington is the creator of http://www.cit.gu.edu.au/~db • Such statements can be used to describe belief or trust in other statements • The solution is to assign a unique identifier to each statement • It can be used to refer to the statement • Introduce an auxiliary object (e.g. belief1) • relate it to each of the 3 parts of the original statement through the properties subject, predicate and object • In the preceding example • subject of belief1 is David Billington • predicate of belief1 is creator • object of belief1 is http://www.cit.gu.edu.au/~db
Reification in XML <?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc=“http://purl.org/dc/elements/1.1/” xmlns:exterms=“http://www.example.com/terms/” xml:base="http://www.example.com/2002/04/products"> <rdf:Description rdf:ID="item10245"> <exterms:weight rdf:datatype="&xsd;decimal">2.4 </exterms:weight> </rdf:Description> <rdf:Statement rdf:about="#triple12345"> <rdf:subject rdf:resource="http://www.example.com/2002/04/products#item10245"/> <rdf:predicate rdf:resource="http://www.example.com/terms/weight"/> <rdf:object rdf:datatype="&xsd;decimal">2.4</rdf:object> <dc:creator rdf:resource="http://www.example.com/staffid/85740"/> </rdf:Statement> </rdf:RDF>
rdf:about vs rdf:ID • An element rdf:Descriptionhas • anrdf:about attribute indicating that the resource has been “defined” elsewhere • An rdf:ID attribute indicating that the resource is defined • Formally, there is no such thing as “defining” an object in one place and referring to it elsewhere • Sometimes it is useful (for human readability) to have a defining location, while other locations state “additional” properties.
Connecting two resources <rdf:Description rdf:about="CIT1111"> <uni:courseName>Discrete Mathematics</uni:courseName> <uni:isTaughtBy rdf:resource="949318"/> </rdf:Description> <rdf:Description rdf:about="949318"> <uni:name>David Billington</uni:name> <uni:title>Associate Professor</uni:title> </rdf:Description>
Nested description <rdf:Description rdf:about="CIT1111"> <uni:courseName>Discrete Maths</uni:courseName> <uni:isTaughtBy> <rdf:Description rdf:ID="949318"> <uni:name>David Billington</uni:name> <uni:title>Associate Professor</uni:title> </rdf:Description> </uni:isTaughtBy> </rdf:Description> <?xml version="1.0"?> <Resource-A> <property-A> <Resource-B> <property-B> <Resource-C> <property-C> Value-C </property-C> </Resource-C> </property-B> </Resource-B> </property-A> </Resource-A> value of property-A value of property-B
Introducing some Structure to RDF Documents using the rdf:type Element • What does the following RDF describe? Not very straightforward. <rdf:Description rdf:ID="CIT1111"> <uni:courseName>Discrete Maths</uni:courseName> <uni:isTaughtBy rdf:resource="#949318"/> </rdf:Description> • Add type declaration <rdf:Description rdf:ID="CIT1111"> <rdf:type rdf:resource="http://www.mydomain.org/uni-ns#course"/> <uni:courseName>Discrete Maths</uni:courseName> <uni:isTaughtBy rdf:resource="#949318"/> </rdf:Description> • An equivalent, more concise notation <uni:course rdf:ID="CIT1111"> <uni:courseName>Discrete Maths</uni:courseName> <uni:isTaughtBy rdf:resource="#949318"/> </rdf:Description>
Equivalent Representations <River rdf:ID="Yangtze" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.geodesy.org/river#" xml:base="http://www.china.org/geography/rivers"> <length>6300 kilometers</length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation> </River> <River rdf:about="http://www.china.org/geography/rivers#Yangtze" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.geodesy.org/river#"> <length>6300 kilometers</length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation> </River> <rdf:Description rdf:about="http://www.china.org/geography/rivers#Yangtze" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.geodesy.org/river#"> <rdf:typerdf:resource="http://www.geodesy.org/river#River"/> <length>6300 kilometers</length> <startingLocation>western China's Qinghai-Tibet Plateau </startingLocation> <endingLocation>East China Sea</endingLocation> </rdf:Description> Note: In the RDF literature the examples are typically shown in this form. Example From Costello
Resource URI = concatenation(xml:base, '#', rdf:ID) = concatenation(http://www.china.org/geography/rivers, '#', "Yangtze") = http://www.china.org/geography/rivers#Yangtze
Describe a property that has more than one value <?xml version="1.0"?> <River id="Yangtze" xmlns="http://www.geodesy.org/river" xmlns:uom="http://www.measurements.org/units-of-measure#"> <length uom:units="kilometers">6300</length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation> </River> Not correct! RDF does not allow attributes on the properties (except for special RDF attributes such as rdf:resource). So we need to make the uom:units attribute a child element. Your first instinct might be to modify length to have two child elements: <?xml version="1.0"?> <River id="Yangtze" xmlns="http://www.geodesy.org/river" xmlns:uom="http://www.measurements.org/units-of-measure#"> <length> <value>6300</value> <uom:units>kilometers</uom:units> </length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation> </River> However, now the length property has as its value two values. RDF allows only binary relations i.e., a single value for a property. Example From Costello From Costello
Rdf:value • length has two values - 6300 and kilometers. • RDF provides a special property, rdf:value, to be used for specifying the "primary" value. • 6300 is the primary value • kilometers is a value which provides additional information about the primary value. 6300 length kilometers From Costello
Anonymous resource <?xml version="1.0"?> <River rdf:ID="Yangtze" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.geodesy.org/river#" xmlns:uom="http://www.measurements.org/units-of-measure#"> … <length> <rdf:Description> <rdf:value>6300</rdf:value> <uom:units>kilometers</uom:units> </rdf:Description> </length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation> </River> An anonymous resource From Costello
rdf:parseType="Resource" If the value of a property is comprised of several values then one option is to create an anonymous resource, as we saw. RDF provides a shorthand, so that you don't need to create an rdf:Description element, by using rdf:parseType="Resource", as shown here: <?xml version="1.0"?> <River rdf:ID="Yangtze" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.geodesy.org/river#" xmlns:uom="http://www.measurements.org/units-of-measure#"> <length rdf:parseType="Resource"> <rdf:value>6300</rdf:value> <uom:units>kilometers</uom:units> </length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation> </River> From Costello
Equivalent <length> <rdf:Description> <rdf:value>6300</rdf:value> <uom:units>kilometers</uom:units> </rdf:Description> </length> <length rdf:parseType="Resource"> <rdf:value>6300</rdf:value> <uom:units>kilometers</uom:units> </length>
Exercise Modify the following XML document so that it is also a valid RDF document: <?xml version="1.0"?> <River id="Yangtze" xmlns="http://www.geodesy.org/river" xmlns:uom="http://www.measurements.org/units-of-measure#"> <length uom:units="kilometers">6300</length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation> <Dam id="ThreeGorges" xmlns="http://www.geodesy.org/dam"> <name>The Three Gorges Dam</name> <width>1.5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </River>
Answer <?xml version="1.0"?> <River rdf:ID="Yangtze" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.geodesy.org/river#" xmlns:uom="http://www.measurements.org/units-of-measure#" xml:base="http://www.china.org/geography/rivers"> <length rdf:parseType="Resource"> <rdf:value>6300</rdf:value> <uom:units>kilometers</uom:units> </length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation> <obstacle> <Dam rdf:ID="ThreeGorges" xmlns="http://www.geodesy.org/dam#"> <name>The Three Gorges Dam</name> <width>1.5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </obstacle> </River>