问题描述
使用SPARQL,我正在尝试获取所有英语小说及其属性的列表.
我还想查找是否根据该小说拍摄了一部电影,并获得了电影名称及其导演(如果存在电影关系).
代码:
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
如果您像这样修改查询,则可以得到很多正确的结果.
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
...但是请记住,有许多电影未归类为dbpedia-owl:Film
.然后,您当然可以用其他一些流行的类别制作union
,但这仍不能保证不会有基于书籍的电影,也不会被遗漏.
那么,您所说的英语小说"是那些最初用英语写的还是由英语作者写的?
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
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?
这篇关于如何在DBPEDIA中使用SPARQL获得基于英语小说的电影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!