query-952a2e10ed3f78c2fb817a279f19f45e

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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?person ?personLabel  ?propertyLabel ?dob ?dod WHERE { 

  { {?item wdt:P179 wd:Q23733.
  ?item ?predicate ?person .} # item = things which are part of the series Seinfeld
                              # ?person is the object of a tripe within the item
  UNION
  {wd:Q23733 ?predicate ?person .} # some people are mentioned in the main Seinfeld item, so get them too
  ?person wdt:P31 wd:Q5 .          # person must be a human 
  ?property wikibase:directClaim ?predicate . # deal with direct claims only, get the property
  }  # do this bit first

  OPTIONAL {?person p:P569 ?statement         # get the date of birth
            OPTIONAL {?statement psv:P569 [   # deal with date precision issues
                wikibase:timePrecision ?precision ;
                wikibase:timeValue ?date_ ].
                BIND(IF(strlen(str(month(?date_)))=2,str(month(?date_)),concat("0",str(month(?date_)))) as ?month) 
                BIND(IF(strlen(str(day(?date_)))=2,str(day(?date_)),concat("0",str(day(?date_)))) as ?day) 
                BIND(IF(?precision=9,year(?date_),
                       IF(?precision=10,concat(str(year(?date_)),":",?month),
                         IF(?precision=11,concat(str(year(?date_)),":",?month,":",?day),""))) as ?dob)
               }   
           }

  OPTIONAL {?person wdt:P570 ?dod . } # get the date of death; don't need to deal with date precision issues here b/c they're all precision=11
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?date_") v9("?day") v10("?dob"):::projected v11("?dod"):::projected v1("?item") v8("?month") v3("?person"):::projected v6("?precision") v2("?predicate") v4("?property") v5("?statement") a1((" ")) c2(["wd:Q23733"]):::iri c12(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; c2 -->v2--> v3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P179"--> c2 v1 -->v2--> v3 end union0r <== or ==> union0l end v3 --"p:direct/P31"--> c4 v4 --"wikibase:directClaim"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:P569".-> v5 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; a1 -."wikibase:timePrecision".-> v6 a1 --"wikibase:timeValue"--> v7 v5 --"p:statement/value/P569"--> a1 bind0[/"if(string-length(str(month-from-dateTime(?date_))) = '2^^xsd:integer',str(month-from-dateTime(?date_)),concat('0',str(month-from-dateTime(?date_))))"/] v7 --o bind0 bind0 --as--o v8 bind1[/"if(string-length(str(day-from-dateTime(?date_))) = '2^^xsd:integer',str(day-from-dateTime(?date_)),concat('0',str(day-from-dateTime(?date_))))"/] v7 --o bind1 bind1 --as--o v9 bind2[/"if(?precision = '9^^xsd:integer',year-from-dateTime(?date_),if(?precision = '10^^xsd:integer',concat(str(year-from-dateTime(?date_)),':',?month),if(?precision = '11^^xsd:integer',concat(str(year-from-dateTime(?date_)),':',?month,':',?day),'')))"/] v6 --o bind2 v7 --o bind2 v8 --o bind2 v9 --o bind2 bind2 --as--o v10 end end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P570".-> v11 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end