Reputation: 35
I am creating a web application that allows users to search for movies by using a SPARQL query.
At the moment I am using DBpedia to get the data.
The problem is I need to 3 pieces of data (title, genre, and release date). but the problem is I'm not receiving the genre of the movie but I am receiving music genre for some reason :/
Here is the query I have created
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX db: <http://dbpedia.org/ontology/>
PREFIX prop: <http://dbpedia.org/property/>
SELECT ?movieLink ?title ?genreLink ?genre ?releaseDate
WHERE {
?movieLink rdf:type db:Film;
foaf:name ?title.
OPTIONAL { ?movieLink prop:genre ?genreLink.
?genreLink rdfs:label ?genre.
FILTER(lang(?genre) = 'en') }.
OPTIONAL{ ?movieLink <http://dbpedia.org/ontology/releaseDate> ?releaseDate }.
FILTER(lang(?title) = 'en')
FILTER((?releaseDate >= '2010-01-01'^^xsd:date) && (?releaseDate < '2010-12-31'^^xsd:date))
}
ORDER BY DESC(?releaseDate)
LIMIT(100)
I have been stuck on this issues for a while so any help would be appreciated.
NOTE: I have looked into using Linkedmdb but had a similar issue.
Upvotes: 0
Views: 2133
Reputation: 2601
@svick gives a good query. If dbpedia.org won't answer it, use our endpoint that includes transitive reasoning: http://factforge.net/sparql. Eg this works:
SELECT * {
?movieLink a dbo:Film; dct:subject ?genreLink.
?genreLink skos:broaderTransitive dbc:Films_by_genre
}
Upvotes: 1
Reputation: 244757
DBpedia data primarily comes from Infoboxes on Wikipedia pages. For example, if you look at the page for the film Ayyanar, you'll notice that it contains two infoboxes:
This is the reason why your query returns the genre of soundtrack for that film.
It seems infoboxes about films do not contain any field for genre, so you won't be able to get that information that way.
On the other hand, the article is in the category Action drama films which is represented on DBpedia using dct:subject
. I think you should be able to get the genre information from that using something like:
OPTIONAL { ?movieLink dct:subject ?genreLink.
?genreLink skos:broader+ dbc:Films_by_genre }
Though it wouldn't be very clean data (because Wikipedia's category structure is a mess). And it doesn't actually work for me, because such query exceeds memory limits on the public DBpadia SPARQL endpoint.
Upvotes: 1