0

I am trying to retrieve the publication date and the no.of pages for books in DBpedia. I tried the following query and it gives empty results. I see that these are properties under book(http://mappings.dbpedia.org/server/ontology/classes/Book) but could not retrieve it.

I would like to know if there is an error in the code or if dbpedia does not store these dates related to books.

SELECT  ?book  ?genre ?date ?numberOfPages
WHERE {
     ?book rdf:type dbpedia-owl:Book .
     ?book dbp:genre ?genre .
     ?book dbp:firstPublicationDate ?date .
     OPTIONAL {?book dbp:numberOfPages ?numberOfPages .}
     }
VKB
  • 65
  • 1
  • 7
  • Try with `dbp:releaseDate` – Ivo Velitchkov Mar 11 '17 at 23:12
  • Thank you that worked. It would be helpful if you could tell me why "dbp:firstPublicationDate" did not work. – VKB Mar 12 '17 at 01:44
  • DBpedia is populated from Wikipedia content, through an evolving set of extractors/converters. If an extractor doesn't exist for the data you want, or the data isn't on Wikipedia, or the mapping isn't as you expect... you won't get the result you expect. – TallTed Mar 13 '17 at 00:49

2 Answers2

0

Mapping based properties are using the namespace http://dbpedia.org/ontology/, thus, the prefix must be dbo instead of dbp, which stands for http://dbpedia.org/property/.

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>

SELECT  ?book  ?genre ?date ?numberOfPages
WHERE {
     ?book a dbo:Book ;
           dbp:genre ?genre ;
           dbo:firstPublicationDate ?date .
     OPTIONAL {?book dbp:numberOfPages ?numberOfPages .}
     }

Some additional comments:

  • put the prefixes to the SPARQL query such that others here can run it without any exceptions (also in the future) - the current SPARQL query uses dbpedia-owl but this one is not pre-defined on the official DBpedia anymore - it's called dbo instead
  • which brings me to the second point -> if you're using a public SPARQL endpoint, show its URL
  • you can start debugging your own SPARQL query by simply starting with only parts of it and adding more triple patterns then, e.g. in your case you could check if there is any triple with the property with

    PREFIX dbp: <http://dbpedia.org/property/>
    
    SELECT * WHERE {?book dbp:firstPublicationDate ?date } LIMIT 10
    

Update

As Ivo Velitchkov noticed in his answer below, the property dbo:firstPublicationDate is only used for mangas, etc., i.e. written work that was published periodically. Thus, the result will be empty.

UninformedUser
  • 8,397
  • 1
  • 14
  • 23
0

The dbp:firstPublicationDate does not work for two reasons:

First, as pointed in the first answer, you used the wrong prefix.

But even if you correct it, you'll see that you would still have no results. Then the best thing to do is to test with the minimum number of patters, in you case you should as for books with first publication date, two triple pattern only. If you still don't get results, you should test how <http://dbpedia.org/ontology/firstPublicationDate> is actually used with a query like this:

SELECT  ?class (COUNT (DISTINCT ?s) AS ?instances)
WHERE {

     ?s <http://dbpedia.org/ontology/firstPublicationDate> ?date ;
        a ?class

     }

GROUP BY ?class
ORDER BY DESC(?instances)

LIMIT 1000
Ivo Velitchkov
  • 2,361
  • 11
  • 21