Search code examples
sparqldbpediavirtuoso

retrieving sparql dates in string format


I have this code:

PREFIX dbp: <http://dbpedia.org/property/> 
    SELECT Distinct  ?bookLabel ?authorLabel ?genreLabel ?date 
FROM <http://dbpedia.org>    
 WHERE{{ {{?s rdf:type dbo:Book .
    ?s rdfs:label ?bookLabel . 
      FILTER(LANGMATCHES(LANG(?bookLabel), 'en')) 
   ?s dbo:author ?author . 
    ?author rdfs:label ?authorLabel .       
      FILTER(LANGMATCHES(LANG(?authorLabel), 'en')) 

 OPTIONAL {{ ?s dbp:country ?country .
              ?country rdfs:label ?countryLabel .
                 FILTER(LANGMATCHES(LANG(?countryLabel), 'en'))
 }}
    ?s dbo:literaryGenre ?genre .
              ?genre rdfs:label ?genreLabel .
?genreLabel bif:contains "'war'"
                 FILTER(LANGMATCHES(LANG(?genreLabel), 'en')) 
  
    OPTIONAL {{ ?s dbp:language ?language .
              ?language rdfs:label ?languageLabel .
                 FILTER(LANGMATCHES(LANG(?languageLabel), 'en'))
 }}
    
  
    OPTIONAL {{ ?s dbp:country ?country .
              ?country rdfs:label ?countryLabel .
                 FILTER(LANGMATCHES(LANG(?countryLabel), 'en'))
 }}
    
    
    OPTIONAL {{ ?s dbp:language ?language .
              ?language rdfs:label ?languageLabel .
                 FILTER(LANGMATCHES(LANG(?languageLabel), 'en'))
 }}
   ?s dbp:releaseDate ?date.
                     FILTER ( ?date >= '19990210'^^xsd:date && ?date <= "20211231"^^xsd:date  )  
}} }}

This retrieves only part of the books for the mentioned period. There are books in dbp:releaseDate with dates written in string format not xsd:date. for example "2006 February". how can i apply the same filter above for those books?


Solution

  • DBPedia data is mostly just as dirty (or clean) as the Wikipedia pages from which DBpedia is derived.

    Your best (if tedious) bet would be to fix the Wikipedia data (making all book publication dates conform to xsd:date), and wait a bit (may be minutes, hours, days, or longer, for this experimental public service) for DBpedia to pick up the changes.