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, 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 / 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. Then, we define the knowledge base itself, giving it a name and the namespace it should use.James Dean Movies (JamesDeanDemo)
1.0
joba
A demonstration of the ontology markups in KnowWE.
jamesDeanMovies
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:
Some properties to represent who played in which movie and who directed the movies:Defining some characters#
We first define some ontology instances in RDF.
People and Movies#
Mr. Dean himself:
The directors of the Dean movies: And some actresses of Dean movies:
And now the three movies of James Dean:
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.null
JamesDeanplayedIn.:
playedIn::null
Giant,
null
EastOfEden,
null
RebelWithoutaCause;
rdf.type::
rdf:type::null
Man.
null
AnnDorannull
playedInnull
RebelWithoutaCause;
rdf.type
rdf:typenull
Woman.
null
ElizabethTaylornull
playedInnull
Giant.
null
CarrollBakernull
playedInnull
Giant;
rdf.type
rdf:typenull
Woman.
null
JoVanFleetnull
playedInnull
EastOfEden;
rdf.type
rdf:typenull
Woman.
null
JulieHarrisnull
playedInnull
EastOfEden;
rdf.type
rdf:typenull
Woman.
null
MercedesMcCambridgenull
playedInnull
Giant;
rdf.type
rdf:typenull
Woman.
null
NatalieWoodnull
playedInnull
RebelWithoutaCause;
rdf.type
rdf:typenull
Woman.
null
Giantnull
directedBynull
GeorgeStevens,
null
FredGuiol.
null
EastOfEdennull
directedBynull
EliaKazan.
null
RebelWithoutaCausenull
directedBynull
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.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.
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.null
JamesDeanrdfs.label
rdfs:label.
null
AnnDoranrdfs.label
rdfs:label.
null
ElizabethTaylorrdfs.label
rdfs:label.
null
CarrollBakerrdfs.label
rdfs:label.
null
JoVanFleetrdfs.label
rdfs:label.
null
JulieHarrisrdfs.label
rdfs:label.
null
MercedesMcCambridgerdfs.label
rdfs:label.
null
NatalieWoodrdfs.label
rdfs:label.
null
Giantrdfs.label
rdfs:label;
rdfs.label
rdfs:label.
null
EastOfEdenrdfs.label
rdfs:label;
rdfs.label
rdfs:label.
null
RebelWithoutaCauserdfs.label
rdfs:label;
rdfs.label
rdfs:label.