How to get the movies which are based on english novels using SPARQL in DBPEDIA

a 夏天 提交于 2019-12-13 08:14:56

问题


Using SPARQL, I am trying the get the list of all english novels and their properties.

I would also like to find if a movie was taken based on that novel and get the movie name and its director, If a movie relationship exists.

Code:

SELECT ?movie ?director ?book ?author ?publisher ?illustrator
WHERE {
?movie  dcterms:subject  <http://dbpedia.org/resource/Category:films> ;
        dbpedia-owl:basedOn     ?book .
?movie dbp:director ?director .

?book a dbpedia-owl:Book .
?book dbp:author ?author .
?book dbp:publisher ?publisher .
?book dbp:illustrator ?illustrator .

}
limit 200

回答1:


You can get a lot of correct results, if you modify your query like this...

PREFIX     dcterms: <http://purl.org/dc/terms/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX         dbp: <http://dbpedia.org/property/>

SELECT ?book ?author ?movie ?director  ?publisher ?illustrator
WHERE {
?book a dbpedia-owl:Book .
  OPTIONAL {?book dbp:author ?author .}
  OPTIONAL {?book dbp:publisher ?publisher .}
  OPTIONAL {?book dbp:illustrator ?illustrator .}
  OPTIONAL {?book ^dbpedia-owl:basedOn ?movie . ?movie a dbpedia-owl:Film }
  OPTIONAL {?movie dbp:director ?director .}
}
LIMIT 200

...but keep in mind that there are many movies that are not classified as dbpedia-owl:Film. Then of course you make a union with a few other popular classifications but that would still not guarantee there there won't be a movie based on a book, which will not be omitted.

And by the way what do you call "English novels" -- those written originally in English or those by English authors?



来源:https://stackoverflow.com/questions/42721789/how-to-get-the-movies-which-are-based-on-english-novels-using-sparql-in-dbpedia

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!