This page (revision-52) was last changed on 10-Feb-2017 10:20 by Albrecht Striffler

This page was created on 14-Nov-2013 13:29 by Joba Baumeister

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
52 10-Feb-2017 10:20 5 KB Albrecht Striffler to previous
51 09-Feb-2017 05:36 6 KB Administrator to previous | to last
50 09-Feb-2017 05:34 6 KB Administrator to previous | to last
49 09-Feb-2017 05:34 6 KB Administrator to previous | to last
48 09-Feb-2017 05:32 6 KB Administrator to previous | to last
47 09-Feb-2017 05:18 6 KB Administrator to previous | to last
46 09-Feb-2017 05:18 6 KB Administrator to previous | to last
45 09-Feb-2017 05:16 6 KB Administrator to previous | to last
44 09-Feb-2017 05:15 6 KB Administrator to previous | to last
43 09-Feb-2017 05:14 6 KB Administrator to previous | to last
42 09-Feb-2017 05:11 6 KB Administrator to previous | to last
41 09-Feb-2017 05:08 5 KB Administrator to previous | to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 1 changed one line
/// to be defined ///
[{Image src='Dean-portrait.jpg' width='150' align='right' caption='James Dean: License CreativeCommons by-sa-2.0'}]
!!! James Dean Movies
The following introduction into RDF/SPARQL was inspired by an example taken from the book:
* Dean Allemang and James Hendler: [Semantic Web for the Working Ontologist: Effective Modeling in RDFS and OWL|http://workingontologist.org/], Morgan Kaufmann, 2 edition, 2011, Chapter 5: Querying the Semantic Web - SPARQL
We slightly modified some notations to be conform with the notations of KnowWE.
The used markups for the definition of the ontology can be only seen in the EDIT mode of this wiki page.
Thus, when you want to understand how the definitions work, please move to the EDIT mode or choose "More/View Page Source".
Photo of James Dean: License [CreativeCommons by-sa-2.0|http://commons.wikimedia.org/wiki/Commons:Licensing] / find the original file [here|http://commons.wikimedia.org/wiki/File:Dean-portrait.jpg?uselang=en].
!!! Defining the knowledge base and package
We first need to define the namespace, where all elements of the James Dean knowledge base should be located, i.e., {{jamesDeanMovies}}.
%%Package jamesDeanMovies
Then, we define the knowledge base itself, giving it a name and the namespace it should use.
%%KnowledgeBase
James Dean Movies
@uses: jamesDeanMovies
@version: 1.0
@id: JamesDeanDemo
@comment: A demonstration of the ontology markups in KnowWE.
@author: joba
%
!!! Defining a schema
To connect some RDF instances properly in KnowWE, we first need to define some classes and their properties.
The classes can be also defined separately and on different wiki articles.
Classes of the James Dean demo:
%%Class
Actor
Director
Movie
Woman
Man
%
Some properties to represent who played in which movie and who directed the movies:
%%ObjectProperty
playedIn
@domain: Actor
@range: Movie
%
%%ObjectProperty
directedBy
@domain: Movie
@range: Director
%
!!! Defining some characters
We first define some ontology instances in RDF.
! People and Movies
Mr. Dean himself:
%%Individual
JamesDean
%
The directors of the Dean movies:
%%Individual
GeorgeStevens
FredGuiol
EliaKazan
NicholasRay
%
And some actresses of Dean movies:
%%Individual
AnnDoran
ElizabethTaylor
CarrollBaker
JoVanFleet
JulieHarris
MercedesMcCambridge
NatalieWood
%
And now the three movies of James Dean:
%%Individual
Giant
EastOfEden
RebelWithoutaCause
%
! Relations to connect the instances
We now connect the instances defined above by using the turtle markup.
When the subject and the predicate of two triples is equal, the you can simply separate the differing objects by commas. See, the {{playedIn}} relation for instance.
%%Turtle
JamesDean
playedIn Giant, EastOfEden, RebelWithoutaCause;
rdf:type Man.
AnnDoran
playedIn RebelWithoutaCause;
rdf:type Woman.
ElizabethTaylor
playedIn Giant.
CarrollBaker
playedIn Giant;
rdf:type Woman.
JoVanFleet
playedIn EastOfEden;
rdf:type Woman.
JulieHarris
playedIn EastOfEden;
rdf:type Woman.
MercedesMcCambridge
playedIn Giant;
rdf:type Woman.
NatalieWood
playedIn RebelWithoutaCause;
rdf:type Woman.
Giant
directedBy GeorgeStevens, FredGuiol.
EastOfEden
directedBy EliaKazan.
RebelWithoutaCause
directedBy NicholasRay.
%
!!! Some first queries
We now try to retrieve some information, that we before represented as triples.
Lets see the actresses that played together with James Dean in a movie.
We use the {{NOT IN}} filter to omitt the appearance of James Dean himself in the result set.
When the result set consists of more than one element, the result is displayed as a table.
%%Sparql
SELECT ?actress ?movie
WHERE {
lns:JamesDean lns:playedIn ?movie.
?actress lns:playedIn ?movie.
FILTER (?actress NOT IN (lns:JamesDean)).
}
@master Demo - JD Ontology
%
Lets see, what directors worked in movies where James Dean played in.
When the result set consists of one element, the result is displayed as a list of the element values.
%%Sparql
SELECT ?who
WHERE {
lns:JamesDean lns:playedIn ?what .
?what lns:directedBy ?who .
}
@master: Demo - JD Ontology
%
!!! Using labels for a user-friendly appearance
By now we only have seen the names of the actual instances.
In RDF it is also possible to define (language dependent) labels for instances by the property {{rdfs:label}}.
Please note, that we use general labels for actors and directors, but language dependent labels for the names of movies.
%%Turtle
JamesDean
rdfs:label 'James Dean'.
AnnDoran
rdfs:label 'Ann Doran'.
ElizabethTaylor
rdfs:label 'Elizabeth Taylor'.
CarrollBaker
rdfs:label 'Carroll Baker'.
JoVanFleet
rdfs:label 'JoVan Fleet'.
JulieHarris
rdfs:label 'Julie Harris'.
MercedesMcCambridge
rdfs:label 'Mercedes McCambridge'.
NatalieWood
rdfs:label 'Natalie Wood '.
Giant
rdfs:label 'Giant'@en;
rdfs:label 'Giganten'@de.
EastOfEden
rdfs:label 'East Of Eden'@en;
rdfs:label 'Jenseits von Eden'@de.
RebelWithoutaCause
rdfs:label 'Rebel Without a Cause'@en;
rdfs:label 'Denn sie wissen nicht, was sie tun'@de.
%
We are now able to query the RDF store with the labels, for instance, query all actors and the movies (in english language) they played in.
%%Sparql
SELECT ?actorLabel ?movieLabel
WHERE {
?actor lns:playedIn ?movie.
?actor rdfs:label ?actorLabel.
?movie rdfs:label ?movieLabel.
FILTER langMatches( lang(?movieLabel), "en").
}
@master: Demo - JD Ontology
%