Question

I am currently trying to get movies (I want their URI) that an actor acted in. When I explore linkedmdb I see "is" actor "of", but I can not use it in my SPARQL query. Is it some special namespace or something? Or is it in an OWL ontology? The query that I am using right now is:

PREFIX movie: <http://data.linkedmdb.org/resource/movie/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
SELECT ?actorName ?filmName WHERE{ 
  <http://data.linkedmdb.org/resource/actor/30947> movie:actor_name ?actorName . 
  <http://data.linkedmdb.org/resource/actor/30947> movie:performance ?film . 
  ?film movie:performance_film ?filmName .
}

This code only return the title, I would like the whole URI of the movie.

Was it helpful?

Solution

Saying that

o is p of x

is a common way of saying that the data contains the triple

s p o

So seeing that

actor32 is actor of movie89

means that the data contains

movie89 actor actor32

I'd say the property actor is poorly named. It's more like features or hasActor, but the RDF is generated by a mapping from a database, so I suppose that some of the names are automatically generated, and that they can't all be great. At any rate, this means that a query like the following will find all the movies and their titles that <http://data.linkedmdb.org/resource/actor/30947> acted in.

SELECT ?movie ?movieTitle WHERE{ 
  ?movie movie:actor <http://data.linkedmdb.org/resource/actor/30947> .
  ?movie dc:title ?movieTitle .
}

Results

Just as an aside, you can abbreviate this query a little bit by using the ; to continue a predicate object list, so you don't have to repeat the subject ?movie:

SELECT ?movie ?movieTitle WHERE{ 
  ?movie movie:actor <http://data.linkedmdb.org/resource/actor/30947> ;
         dc:title ?movieTitle .
}

Appendix: About “is — of”

Notation3 (N3): A readable RDF syntax, which is very much like Turtle, the Terse RDF Triple Language (in fact, Turtle is a subset of N3), but which includes a few more syntactic constructs, actually allows a “is — of” way of writing triples. The grammar production for predicate is:

predicate
    expression
    "<="
    "="
    "=>"
    "@a"
    "@has" expression
    "@is" expression "@of"

This means that in N3, you could, e.g,. enumerate some instances of a class with

ex:Planet @is rdf:type @of 
  :Mercury, :Venus, :Earth, :Mars, :Jupiter, :Saturn, :Uranus, :Neptune .

instead of having to do

:Mercury rdf:type ex:Planet .
:Venus rdf:type ex:Planet .
:Earth rdf:type ex:Planet .
:Mars rdf:type ex:Planet .
:Jupiter rdf:type ex:Planet .
:Saturn rdf:type ex:Planet .
:Uranus rdf:type ex:Planet .
:Neptune rdf:type ex:Planet .

Unfortunately, many tools that claim to support N3 actually only support Turtle, and wouldn't accept the first form. However, it you're working with something that does actually support N3, you could write

<http://data.linkedmdb.org/resource/actor/30947> @is movie:actor @of ?movie .
?movie dc:title ?movieTitle .

Sadly, the SPARQL Syntax for Triple Patterns doesn't support @is — @of, so you won't be able to do this in your query.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top