Вы находитесь на странице: 1из 6

Core Semantic Web technologies

◮ RDF – Resource Description Framework


◮ RDFS – RDF Schema (vocabulary)
◮ OWL – Web Ontology Language
◮ SPARQL – Query Language for RDF

RDF – Resource Description Framework


◮ based on XML and URIs
◮ directed, labeled graph format for representing
information in the web
◮ formal semantics allows well founded deductions in RDF
data
◮ extensible vocabulary

RDF – graph data model


◮ any expression in RDF is a collection of triples
◮ every triple consists of a subject, a predicate and an object
◮ the arc direction is significant – it always points toward the
object
◮ assertion of an RDF triple says that some relationship,
indicated by the predicate, holds between the things
denoted by subject and object of the triple
◮ meaning of an RDF graph is the conjunction (logical AND)
of the statements corresponding to all the triples it contains
Aleksander Pohl KI

RDF – subject, predicate & object


◮ nodes of an RDF graph are its subjects and objects
◮ a node may be:
◮ URI with optional fragment identifier, eg.
http://www.example.org/staffid/1234#xyz
◮ literal, eg. "George"

◮ blank

◮ the subject of a triple might be only URI reference or


a blank node
◮ the predicate of the triple must be URI reference

RDF – example
<rdf:Description rdf:about="http://www.ivan-herman.net">
<foaf:name>Ivan</foaf:name>
<abc:myCalendar rdf:resource="http://.../myCalendar"/>
<foaf:surname>Herman</foaf:surname>
</rdf:Description>

A RDFS – RDF Vocabulary Description Language


◮ RDF itself provides no means for defining
application-specific classes and properties
◮ They are described in RDFS – RDF Vocabulary
Description Language (aka RDF Schema)
◮ RDF Schema provides a type system for RDF, similar to
type systems in programming languages:
◮ allows resources to be defined as instances of one or more
classes
◮ allows classes to be organized in a hierarchical fashion

◮URIref prefix
http://www.w3.org/2000/01/rdf-schema#,
conventionally associated with the QName prefix rdfs:

RDFS – basic notions (1)


◮ Classes are described using the RDFS resources:
◮ rdfs:Class
◮ rdfs:Resource

◮ and the properties:


◮ rdf:type
◮ rdfs:subClassOf

◮ Example:
◮ ex:MotorVehicle rdf:type rdfs:Class.
Java: class MotorVehicle {· · · }
◮ exthings:myCar rdf:type ex:MotorVehicle.

Java: myCar = new MotorVehicle();


◮ ex:Van rdfs:subClassOf ex:MotorVehicle.

Java: class Van extends MotorVehicle {· · · }


Aleksander

OWL – Web Ontology Language


◮ Intended to be used when the information needs to be
processed by applications (not merely presented to
humans)
◮ Provides additional vocabulary along with a formal
semantics
◮ Sublanguages:
◮ Lite – classification hierarchy and simple constraints
(extension of restricted RDF)
◮ DL (Description Logic) – maximum expressiveness while

retaining computational completeness (extension of


restricted RDF)
◮ Full – maximum expressiveness and the syntactic freedom

of RDF with no computational guarantees (real extension of


RDF)
OWL Lite additions
◮ (In)Equality: equivalentClass,
equivalentProperty, sameAs, differentFrom, ...
◮ Property characteristics: inverseOf,
TransitiveProperty, SymmetricProperty, ...
◮ Restricted Cardinality: minCardinality,
maxCardinality, cardinality
◮ Annotation Properties: rdfs:label, rdfs:comment,
rdfs:seeAlso, rdfs:isDefinedBy,
AnnotationProperty, OntologyProperty
Aleksander
SPARQL – overview
◮ SPARQL is a query language for RDF
◮ It is similar to SQL in terms of purpose and syntax, but
different in terms of application (relational data vs. graph
based data)
◮ Human-friendly syntax
◮ Data integration and aggregation – multiple sources
supported by default
◮ Allows to make yes/no questions
Aleksander

SPARQL Example
◮ Data:
<http://example.org/book/book1>
<http://purl.org/dc/elements/1.1/title>
”SPARQL Tutorial” .
◮ Query:
SELECT ?title WHERE {
<http://example.org/book/book1>
<http://purl.org/dc/elements/1.1/title>
?title . }
◮ Result:
Title
”SPARQL Tutorial”

Jena2 – overview
◮ Developed by HP Laboratories
◮ Open-source Java implementation of core Semantic Web
technologies:
◮ RDF graph manipulation API
◮ RDFS and OWL reasoning API
◮ Includes the de facto reference RDF/XML parser

◮ RDF/XML, N3 and N-triple Input/Output

◮ SPQRQL query engine

◮ rule-based inference engine

◮ In-memory or persistent storage


Aleksander

RDF API example


1 //some definitions
2 static String personURI = "http://somewhere/JohnSmith";
3 static String fullName = "John Smith";
4
5 // create an empty Model
6 Model model = ModelFactory.createDefaultModel();
7
8 // create the resource
9 Resource johnSmith = model.createResource(personURI);
10
11 // add the property
12 johnSmith.addProperty(VCARD.FN, fullName);
Aleksander

SPARQL API example


1 Model model = ... ;
2 String queryString = " .... " ;
3 Query query = QueryFactory.create(queryString) ;
4 QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
5 try {
6 ResultSet results = qexec.execSelect() ;
7 for ( ; results.hasNext() ; )
8 {
9 QuerySolution soln = results.nextSolution() ;
10 // Get a result variable by name.
11 RDFNode x = soln.get("varName") ;
12 // Get a result variable - must be a resource
13 Resource r = soln.getResource("VarR") ;
14 // Get a result variable - must be a literal
15 Literal l = soln.getLiteral("VarL") ;
16 }
17 } finally { qexec.close() ; }
A
Jena comparison
Aleksander

Вам также может понравиться