query-07df9cae9a7fb256740db46ad4ae2e4d

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?person ?personLabel ?personDescription ?genderLabel  ?birthplaceLabel ?deathplaceLabel
(IF(YEAR(?birthdate)>1400,?birthdate,YEAR(?birthdate)) AS ?birthdate)
(IF(YEAR(?deathdate)>1400,?deathdate,YEAR(?deathdate)) AS ?deathdate)
(GROUP_CONCAT(DISTINCT ?nationality_label ;separator=', ') AS ?nationalities) 
(SAMPLE(?image) AS ?image) 
(GROUP_CONCAT(DISTINCT ?book_label ;separator=', ') AS ?books)
(GROUP_CONCAT(DISTINCT ?honour_label ;separator=', ') AS ?honours)

WHERE{
  {
    SELECT DISTINCT ?person ?image ?gender ?birthdate ?birthplace ?deathdate ?deathplace ?cnt ?nationality_label ?book_label ?honour_label WHERE{
      ?person wdt:P31 wd:Q5 . #eliminates fictional people
      ?person wdt:P106 wd:Q170790; #selects occupation
            wikibase:sitelinks ?cnt .  
      ?person wdt:P18 ?image .
      ?person wdt:P21 ?gender .
      OPTIONAL {?person wdt:P569 ?birthdate .}
      OPTIONAL {?person wdt:P570 ?deathdate .}
      OPTIONAL {?person wdt:P19 ?birthplace .}
      OPTIONAL {?person wdt:P20 ?deathplace .}
      OPTIONAL {
            ?person wdt:P27 ?nationality .
            ?nationality rdfs:label ?nationality_label FILTER (lang(?nationality_label) = "en") . 
      }
      OPTIONAL {
            ?book wdt:P50 ?person .
            FILTER EXISTS {
              ?book wdt:P31 wd:Q571 . #eliminates quotations and the like
            }
            ?book rdfs:label ?book_label FILTER (lang(?book_label) = "en") . 
      }
      OPTIONAL {
            ?person wdt:P166 ?honour .
            ?honour rdfs:label ?honour_label FILTER (lang(?honour_label) = "en") .
        }              
    } ORDER BY DESC(?cnt) 
  }
  SERVICE wikibase:label {
       bd:serviceParam wikibase:language "en" .
    }
} 
GROUP BY ?person ?personLabel ?personDescription ?genderLabel ?birthdate ?birthplaceLabel ?deathdate ?deathplaceLabel
ORDER BY DESC(?cnt)
LIMIT 300

Query found at