Fetching a list of books adapted into films from d

2020-04-01 06:11发布

问题:

I am trying to fetch a list of American movies adapted from books from dbpedia. This is what I have so far:

PREFIX onto: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT * WHERE {

?movie dcterms:subject <http://dbpedia.org/resource/Category:American_films> .
?movie dcterms:subject <http://dbpedia.org/resource/Category:Films_based_on_novels> .
?movie onto:basedOn ?book .
?book a onto:Book .
}

I get only 4 results back. Is there another property I can use to get more results?

回答1:

First thing, try removing the second line of your pattern --

?movie dcterms:subject <http://dbpedia.org/resource/Category:Films_based_on_novels> .

You'll get a great many more results from --

PREFIX onto: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT * WHERE 
  {
    ?movie  dcterms:subject  <http://dbpedia.org/resource/Category:American_films> ;
            onto:basedOn     ?book .
    ?book   a                 onto:Book .
  }

Have you looked at the descriptions of the results you did get? That will show you the properties you might use...

Remember that you're limited by the data in DBpedia, which may not have what you think it should (for instance, not every film based on a novel is explicitly categorized as such, as you can see by the different results I got), and may also be 6 or more months out of sync with Wikipedia. You might look at DBpedia-live, for constantly updated ingestion.