semantic web - sharif university of...

51
ﻌﺎSemantic Web Morteza Amini RDF and RDF Schema Sharif University of Technology Fall 94-95

Upload: others

Post on 24-Apr-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

���ه �عا�ی

Semantic Web

Morteza Amini

RDF and RDF Schema

Sharif University of Technology Fall 94-95

Outline

Metadata

RDF

RDF Schema (RDFS)

RDF(S) – Applications and Tools

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 2

Web Problems

Too much Web information around 1,000,000,000 (1×109) resources Many different types of resources

text, images, graphics, audio, video, multimedia, databases, Web applications, …

Information not indexable No common “scheme” for doing so Short-lived, dynamic resources Differing relationships between authors, publishers, info

intermediaries, users Each community uses their own approach

Information not shareable no common cataloging scheme

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 3

Main Issue

Metadata Information about information Structured data about data

Many types/forms of metadata, dependent on role.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 4

Second Issue

Language for expressing metadata must be: universal (so all can understand) flexible (to incorporate different types) extensible (flexible to custom types) simple (to encourage adoption) modular (so that schemes can be mixed, extended)

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 5

Outline

Metadata

RDF

RDF Schema (RDFS)

RDF(S) – Applications and Tools

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 6

RDF (1)

RDF stands for Resource Description Framework

It is a machine understandable metadata

RDF is graphical formalism ( + XML syntax + semantics) for representing metadata for describing the semantics of information in a machine-

accessible way

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 7

RDF (2)

The XML tags can often add meaning to data, however, actually understanding the tags is meaningful only to humans.

For example: <book> <title>Thinking on The Web<title> </book>

A human might infer that: “The book has the title Thinking on the Web.”

A machine, however, could not make this inference based upon the XML alone.

For machines to do more automatically, it is necessary to go beyond the notion of the HTML display model, or XML data model, toward a “meaning”.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 8

RDF (3)

RDF is an assertional language intended to be used to express propositions using precise formal vocabularies.

The overall design goals emphasize generality and precision in expressing propositions about any topic, rather than conformity to any particular processing model.

An RDF document can delineate precise relationships between vocabulary items by constructing a grammatical representation.

Assertions in different RDF documents can be combined to provide far more information together than they could separately.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 9

RDF in SW Architecture

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 10

RDF Model

A model is a collection of statements

Statement := (subject, predicate, object)

Subject is a resource.

Predicate is a resource.

Object is either a resource or a literal.

Literal in the RDF sense is a constant string value such as string or number.

Subject Object Predicate

Statement Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 11

RDF Resource, Property, and Property Value

RDF identifies things using Web identifiers (URIs), and describes resources with properties and property values.

A Resource is anything that can have a URI, such as http://www.w3schools.com/rdf

A Property is a Resource that has a name, such as "author" or "homepage“

A Property value is the value of a Property, such as "Jan Egil Refsnes" or "http://www.w3schools.com" (note that a property value can be another resource)

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 12

Example

“The book [subject] has the title [predicate] Thinking on the Web [object].”

This can be represented as the triple: (The book, has the title, Thinking on the Web).

The Book Thinking on the Web

has the title

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 13

RDF Model and Natural Language

Subject: In grammar, this is the noun or noun phrase that is the doer of the action. In the sentence “The company sells batteries,” the subject is “the company.”

Predicate: In grammar, this is the part of a sentence that modifies the subject and includes the verb phrase. In our sentence, the predicate is the phrase “sells”.

Object: In grammar this is a noun that is acted upon by the verb. In our sentence, the object is the noun “batteries”.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 14

XML vs. RDF

RDF is not just an XML dialect.

XML: Has a tree structure data model. Only nodes are labeled.

RDF: Has a graph structure data model. Both edges (properties) and nodes (subjects/objects) are

labeled.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 15

Linking Statements

The object of one statement can be the subject of another.

Such collections of statements form a directed, labeled graph.

Ahmadi CE studentOF

Sharif http://ce.sharif.edu

departmentOF hasHomePage

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 16

RDF Graph: Anonymous Nodes

Person12345

Ali

Ahmadi

person.name

first

last

value

value

PersonName Literal Person

Sharif Univ. of Tech. 17

How Can RDF be Implemented

Usually RDF/XML syntax

However other notations are possible

e.g. Notation3: Ali Ahmadi teaches Semantic Web course. The course has a Web site accessible at http://ce.sharif.edu/~sw. Ahmadi is the father of Maryam.

<#Ahmadi> <#teaches> <#SemanticWeb>. <#SemanticWeb> <#has-website> <http://ce.sharif.edu/~sw>. <#Ahmadi> <#father-of> <#Maryam>.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 18

Converting N3 to RDF/XML

Jena toolkit can do such conversion.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 19

RDF has an XML syntax that has a specific meaning: Every Description element describes a resource Every attribute or nested element inside a Description is a

property of that Resource We can refer to resources by using URIs. <rdf:Description rdf:about="some.uri/person/Ahmadi"> <studentOf rdf:resource="some.uri/Sharif/CE"/> </rdf:Description> <rdf:Description rdf:about="some.uri/Sharif/CE"> <hasHomePage>http://ce.sharif.edu</hasHomePage> <departmentOf rdf:resource="some.uri/~Sharif"/> </rdf:Description>

XML Syntax for RDF

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 20

RDF Document Parts

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 21

Document Parts RDF Document

Header– XML Syntax declaration

<?xml version=“1.0”>

Root element tag <rdf:RDF

XML namespaces for rdf and our ontology (here ‘ex’)

xmlns:rdf =“http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:ex=“http://example.org”>

Inserting the triples (subject, predicate, object)

<rdf:Description rdf:about=“SUBJECT”> <ex:PREDICATE>OBJECT</ex:PREDICATE> </rdf:Description>

End of root element indicates end of RDF document

</rdf:RDF>

RDF Example

<?xml version="1.0"?> <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/Neyestan"> <cd:artist>Shahram Nazeri</cd:artist> <cd:country>I.R. IRAN</cd:country> <cd:company>Soroush</cd:company> <cd:price>50000IRR</cd:price> <cd:year>1989</cd:year> </rdf:Description> </rdf:RDF>

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 22

RDF Main Elements (1)

Properties as Attributes The property elements can also be defined as attributes

(instead of elements): Example:

<?xml version="1.0"?> <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/Neyestan" cd:artist=“Shahram Nazeri" cd:country=“I.R. IRAN" cd:company=“Soroush" cd:price=“50000IRR" cd:year=“1989" /> </rdf:RDF>

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 23

RDF Main Elements (2)

Properties as Resources The property elements can also be defined as resources: Example:

<?xml version="1.0"?> <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/Neyestan"> <cd:artist rdf:resource="http://www.recshop.fake/cd/nazeri" /> … </rdf:Description> </rdf:RDF>

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 24

RDF Type

RDF predefined property (rdf:type).

Its value – a resource that represent a category or class

Its subject – Instance of that category or class

In RDF, we can use XML data types for typed literals by rdf:datatype=“xsd:datatype”.

prefix ex: URI: http://www.example.org/terms

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 25

ex:Person

Ali Ahmadi mailto:[email protected]

ex:mailbox

rdf:type http://example.org/staffid/23346

Containers

Containers are collections they allow grouping of resources (or literal values)

It is possible to make statements about the container (as a whole) or about its members individually.

It is also possible to create collections based on URI patterns. for example, all files in a particular web site

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 26

RDF Containers

Bag: (A resource having type rdf:Bag) Describes an unordered list of resources or literals. Duplicated values are permitted.

Sequence: (A resource having type rdf:Seq) Describes an ordered list of resources or literals. Duplicated values are permitted.

Alternatives: (A resource having type rdf:Alt) Describes a group of resources or literals that are alternatives. The user can select only one of the alternative values.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 27

Sequence Example (1)

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

“Ora Lassila”

rdf:_1

rdf:Seq

dc:Creator

rdf:Type

“Ralph Swick”

rdf:_2

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 28

Sequence Example (2)

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 29

Bag Example

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 30

Alternative Example

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 31

RDF Reification

Reification means finding more concrete representation.

Association of a statement and a specific resource representing the statement.

Used to make statements about statements.

Vocabulary: type rdf:asserts properties

rdf:subject rdf:predicate rdf:object

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 32

Reification Example

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 33

Reification Example

RDF Graph (by IsaViz):

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 34

Outline

Metadata

RDF

RDF Schema (RDFS)

RDF(S) – Applications and Tools

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 35

RDF Schema (RDFS)

RDF gives a formalism for meta data annotation, and a way to write it down in XML, but it does not give any special meaning to vocabulary such as subClassOf . Interpretation is an arbitrary binary relation

In other words, RDF needs a way to define application-specific classes and properties. Application-specific classes and properties must be defined using extensions to RDF.

One such extension is RDF Schema.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 36

RDF Schema (RDFS)

RDF Schema allows you to define vocabulary terms and the relations between those terms. It gives “extra meaning” to particular RDF predicates and

resources. This “extra meaning”, or semantics, specifies how a term

should be interpreted.

Classes in RDF Schema are much like classes in object oriented programming languages. This allows resources to be defined as instances of classes, and subclasses of classes.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 37

Core Classes & Properties

Core Classes

Core Properties

rdfs:Resource

rdfs:Literal

rdfs:XMLLiteral

rdfs:Class

rdfs:Property

rdfs:DataType

rdfs:SubClassOf

rdfs:SubPropertyOf

rdfs:Domain

rdfs:Range

rdfs:Label

rdfs:Comment

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 38

RDFS Examples

<Student,type,Class>

<Professor,type,Class>

<Advise,type,Property>

<Professor,subClassOf,Person>

<Maryam Jafari,type,Student>

<Advise,range,Student>

<Advise,domain,Professor>

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 39

RDFS Examples

<rdfs:class rdf:ID="Person"/> <rdfs:class rdf:ID="Student"/> <rdfs:class rdf:ID="Professor"> <rdfs:subClassOf rdf:resource="#Person"/> </rdfs:class> <rdfs:Property rdf:ID="Advise"> <rdfs:domain rdf:resource="#Professor"/> <rdfs:range rdf:resource="#Student"/> </rdfs:Property> <rdf:Description rdf:about="http://ce.sharof.edu/students/~MJafari">

<rdf:type rdf:resource="#Student"/> </rdf:Description>

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 40

RDF/RDFS “Liberality”

No distinction between classes and instances (individuals). <Species,type,Class> <Lion,type,Species> <Leo,type,Lion>

Properties can themselves have properties. <hasDaughter,subPropertyOf,hasChild> <hasDaughter,type,familyProperty>

No distinction between language constructors and ontology vocabulary, so constructors can be applied to themselves/each other. <type,range,Class> <Property,type,Class> <type,subPropertyOf,subClassOf>

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 41

RDF and RDFS Layers

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 42

Outline

Metadata

RDF

RDF Schema (RDFS)

RDF(S) – Applications and Tools

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 43

Friend of a Friend (FOAF) Application

Many communities, such as companies, professional organizations, and social groupings, have proliferated on the Internet.

The Friend of a Friend (FOAF) RDF vocabulary, originated by Dan Brickley and Libby Miller, gives a basic expression for community membership.

The FOAF project describes people and their basic properties, such as name, email address, and so on.

Friend of a Friend allows the expression of personal information and relationships.

As a result, search engines can find people with similar interests through FOAF.

Friend of a Friend is simply an RDF vocabulary. You can create FOAF files on your Web server and share the URLs so that software can use the information.

The creation of FOAF data is decentralized since it allows many to contribute independently.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 44

FOAF Example

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 45

Rich Site Summary (RSS)

A form of publishing content such that machines can process them.

One dialect is based on RDF.

Very popular for news sites.

Tools like RSS reader can syndicate news and bring them to the desktop.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 46

Problems with RDFS

RDFS is too weak to describe resources in sufficient detail No localised range and domain constraints

Can’t say that the range of hasChild is person when applied to persons and elephant when applied to elephants.

No existence/cardinality constraints Can’t say that all instances of person have a mother that is also a person,

or that persons have exactly 2 parents. No transitive, inverse or symmetrical properties

Can’t say that isPartOf is a transitive property, that hasPart is the inverse of isPartOf or that touches is symmetrical.

Difficult to provide reasoning support. No “native” reasoners for non-standard semantics. May be possible to reason via FO axiomatisation.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 47

RDF(S) tools

Read RDF data Parsers: Jena, Redland, SWI-Prolog Validators: W3C RDF validation service Editors: IsaViz, RDF Author, RDFEd, InferEd

Store RDF data (XML format, tripples or relational/oo DB) Sesame, RSSDB, RDFLib

Use RDF data (applications, RSS news, etc.)

Manipulate RDF data (inference, query, etc.) Jena RDQL, etc. Example:

SELECT ?person, ?knows WHERE (?x <http://xmlns.com/foap/knows> ?z), (?x <http://xmlns.com/foap/name> ?person), (?z <http://xmlns.com/foap/name> ?knows)

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 48

RDF Validators

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

In general all the RDF parsers do some kind of validation.

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 49

References

RDF Resource Guide: http://www.ilrt.bris.ac.uk/discovery/rdf/resources/

http://www.w3.org/RDF

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

Chapter 5 of the book

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 50

Any Question... [email protected]

Sharif Univ. of Tech. RDF and RDF Schema - Morteza Amini 51