Demo - JD Ontology

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:

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 / find the original file here.

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.

jamesDeanMovies

Then, we define the knowledge base itself, giving it the namespace/package it should use.

Knowledge base / Ontology#

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:

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:

JamesDean

The directors of the Dean movies:

GeorgeStevens FredGuiol EliaKazan NicholasRay

And some actresses of Dean movies:

AnnDoran ElizabethTaylor CarrollBaker JoVanFleet JulieHarris MercedesMcCambridge NatalieWood

And now the three movies of James Dean:

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.

lns.JamesDean
JamesDean
lns.playedIn
playedIn
lns.Giant
Giant
,
lns.EastOfEden
EastOfEden
,
lns.RebelWithoutaCause
RebelWithoutaCause
;
rdf.type
rdf:type
lns.Man
Man
;

lns.AnnDoran
AnnDoran
lns.playedIn
playedIn
lns.RebelWithoutaCause
RebelWithoutaCause
;
rdf.type
rdf:type
lns.Woman
Woman
;

lns.ElizabethTaylor
ElizabethTaylor
lns.playedIn
playedIn
lns.Giant
Giant
;
rdf.type
rdf:type
lns.Woman
Woman
;

lns.CarrollBaker
CarrollBaker
lns.playedIn
playedIn
lns.Giant
Giant
;
rdf.type
rdf:type
lns.Woman
Woman
;

lns.JoVanFleet
JoVanFleet
lns.playedIn
playedIn
lns.EastOfEden
EastOfEden
;
rdf.type
rdf:type
lns.Woman
Woman
;

lns.JulieHarris
JulieHarris
lns.playedIn
playedIn
lns.EastOfEden
EastOfEden
;
rdf.type
rdf:type
lns.Woman
Woman
;

lns.MercedesMcCambridge
MercedesMcCambridge
lns.playedIn
playedIn
lns.Giant
Giant
;
rdf.type
rdf:type
lns.Woman
Woman
;

lns.NatalieWood
NatalieWood
lns.playedIn
playedIn
lns.RebelWithoutaCause
RebelWithoutaCause
;
rdf.type
rdf:type
lns.Woman
Woman
;

lns.Giant
Giant
lns.directedBy
directedBy
lns.GeorgeStevens
GeorgeStevens
,
lns.FredGuiol
FredGuiol
;

lns.EastOfEden
EastOfEden
lns.directedBy
directedBy
lns.EliaKazan
EliaKazan
;

lns.RebelWithoutaCause
RebelWithoutaCause
lns.directedBy
directedBy
lns.NicholasRay
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.

Show of 7 rows
Rows to 7 
Show of 7 rows
Rows to 7 

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.

Show of 4 rows
Rows to 4 
Show of 4 rows
Rows to 4 

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.

lns.JamesDean
JamesDean
rdfs.label
rdfs:label
'James Dean'
;

lns.AnnDoran
AnnDoran
rdfs.label
rdfs:label
'Ann Doran'
;

lns.ElizabethTaylor
ElizabethTaylor
rdfs.label
rdfs:label
'Elizabeth Taylor'
;

lns.CarrollBaker
CarrollBaker
rdfs.label
rdfs:label
'Carroll Baker'
;

lns.JoVanFleet
JoVanFleet
rdfs.label
rdfs:label
'JoVan Fleet'
;

lns.JulieHarris
JulieHarris
rdfs.label
rdfs:label
'Julie Harris'
;

lns.MercedesMcCambridge
MercedesMcCambridge
rdfs.label
rdfs:label
'Mercedes McCambridge'
;

lns.NatalieWood
NatalieWood
rdfs.label
rdfs:label
'Natalie Wood '
;

lns.Giant
Giant
rdfs.label
rdfs:label
'Giant'@en
;
rdfs.label
rdfs:label
'Giganten'@de
;

lns.EastOfEden
EastOfEden
rdfs.label
rdfs:label
'East Of Eden'@en
;
rdfs.label
rdfs:label
'Jenseits von Eden'@de
;

lns.RebelWithoutaCause
RebelWithoutaCause
rdfs.label
rdfs:label
'Rebel Without a Cause'@en
;
rdfs.label
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.

Show of 10 rows
Rows to 10 
Show of 10 rows
Rows to 10