query-d979b1646a75150776e980aea5b3e148

rq turtle/ttl

New Zealand writers SELECT DISTINCT ?academic ?academicLabel ?academicDescription ?academicAltLabel (GROUP_CONCAT(DISTINCT ?lccnurl; SEPARATOR = ";") AS ?LCCN_urls) (GROUP_CONCAT(DISTINCT ?viafurl; SEPARATOR = ";") AS ?VIAF_urls) (GROUP_CONCAT(DISTINCT ?dob; SEPARATOR = ";") AS ?DOBs) (GROUP_CONCAT(DISTINCT ?dod; SEPARATOR = ";") AS ?DODs) (GROUP_CONCAT(DISTINCT ?komurl; SEPARATOR = ";") AS ?Kōmako_ID_urls) WHERE {

?academic wdt:P31 wd:Q5 . # academic is a person { ?academic wdt:P27 wd:Q664 . # citizen of New Zealand } UNION { ?academic wdt:P551 wd:Q664 . # residence of New Zealand }

{ ?academic wdt:P106 wd:Q15949613 . #occupation short story writer } UNION { ?academic wdt:P106 wd:Q6625963 . #occupation novelist } UNION { ?academic wdt:P106 wd:Q49757 . #occupation poet } UNION { ?academic wdt:P106 wd:Q36180 . #occupation writer } UNION { VALUES ?type {wd:Q571 wd:Q7725634 wd:Q8261} . # book literary work or novel ?item wdt:P31 ?type . ?item wdt:P50 ?academic . } UNION { ?academic wdt:P12702 ?komid . }

OPTIONAL { ?academic wdt:P569 ?dob . } .
OPTIONAL { ?academic wdt:P570 ?dod . } .

OPTIONAL { ?academic wdt:P244 ?lccn . BIND( IRI(CONCAT('https://lccn.loc.gov/', STR(?lccn))) AS ?lccnurl ) . } . OPTIONAL { ?academic wdt:P214 ?viaf . BIND( IRI(CONCAT('https://viaf.org/viaf/', STR(?viaf))) AS ?viafurl ) . } . OPTIONAL { ?academic wdt:P12702 ?komid . BIND( IRI(CONCAT('https://www.komako.org.nz/person/', STR(?komid))) AS ?komurl ) . } . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" } } GROUP BY ?academic ?academicLabel ?academicDescription ?academicAltLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#New Zealand writers
SELECT DISTINCT 
   ?academic 
   ?academicLabel 
   ?academicDescription 
   ?academicAltLabel 
   (GROUP_CONCAT(DISTINCT ?lccnurl; SEPARATOR = ";") AS ?LCCN_urls)
   (GROUP_CONCAT(DISTINCT ?viafurl; SEPARATOR = ";") AS ?VIAF_urls)
   (GROUP_CONCAT(DISTINCT ?dob; SEPARATOR = ";") AS ?DOBs)
   (GROUP_CONCAT(DISTINCT ?dod; SEPARATOR = ";") AS ?DODs)
   (GROUP_CONCAT(DISTINCT ?komurl; SEPARATOR = ";") AS ?Kōmako_ID_urls)
   WHERE {

   ?academic wdt:P31 wd:Q5 . # academic is a person
   {
      ?academic wdt:P27 wd:Q664 .  # citizen of New Zealand
    } UNION {
      ?academic wdt:P551 wd:Q664 .  # residence of New Zealand
   } 

   {
      ?academic wdt:P106 wd:Q15949613 . #occupation short story writer
   } UNION {
      ?academic wdt:P106 wd:Q6625963 . #occupation novelist
   } UNION {
      ?academic wdt:P106 wd:Q49757 . #occupation poet
   } UNION {
      ?academic wdt:P106 wd:Q36180 . #occupation writer
   } UNION {
      VALUES ?type {wd:Q571 wd:Q7725634 wd:Q8261} . # book literary work or novel
      ?item wdt:P31 ?type .
      ?item wdt:P50 ?academic .
   } UNION {
      ?academic wdt:P12702 ?komid .
   }

   OPTIONAL { ?academic wdt:P569 ?dob . } .   
   OPTIONAL { ?academic wdt:P570 ?dod . } .   

   OPTIONAL { ?academic wdt:P244 ?lccn .  BIND( IRI(CONCAT('https://lccn.loc.gov/', STR(?lccn)))  AS ?lccnurl ) .   } . 
   OPTIONAL { ?academic wdt:P214 ?viaf .  BIND( IRI(CONCAT('https://viaf.org/viaf/', STR(?viaf)))  AS ?viafurl ) . } . 
   OPTIONAL { ?academic wdt:P12702 ?komid .  BIND( IRI(CONCAT('https://www.komako.org.nz/person/', STR(?komid)))  AS ?komurl ) . } . 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" }
}
GROUP BY ?academic  ?academicLabel   ?academicDescription   ?academicAltLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v14("?DOBs") v15("?DODs") v16("?Kōmako_ID_urls") v12("?LCCN_urls") v13("?VIAF_urls") v1("?academic"):::projected v5("?dob"):::projected v6("?dod"):::projected v3("?item") v4("?komid") v11("?komurl"):::projected v7("?lccn") v8("?lccnurl"):::projected v2("?type") v9("?viaf") v10("?viafurl"):::projected c8(["wd:Q6625963"]):::iri c9(["wd:Q49757"]):::iri c20(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal c10(["wd:Q36180"]):::iri c4(["wd:Q664"]):::iri c18(["bd:serviceParam"]):::iri c7(["wd:Q15949613"]):::iri c2(["wd:Q5"]):::iri v1 --"wdt:P31"--> c2 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P551"--> c4 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P27"--> c4 end union0r <== or ==> union0l end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; subgraph union4[" Union "] subgraph union4l[" "] style union4l fill:#abf,stroke-dasharray: 3 3; subgraph union5[" Union "] subgraph union5l[" "] style union5l fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P12702"--> v4 end subgraph union5r[" "] style union5r fill:#abf,stroke-dasharray: 3 3; bind0[/VALUES ?type/] bind0-->v2 bind00(["wd:Q571"]) bind00 --> bind0 bind01(["wd:Q7725634"]) bind01 --> bind0 bind02(["wd:Q8261"]) bind02 --> bind0 v3 --"wdt:P31"--> v2 v3 --"wdt:P50"--> v1 end union5r <== or ==> union5l end end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P106"--> c10 end union4r <== or ==> union4l end end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P106"--> c9 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P106"--> c8 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P106"--> c7 end union1r <== or ==> union1l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P569".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P570".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P244".-> v7 bind1[/"concat('https://lccn.loc.gov/',str(?lccn))"/] v7 --o bind1 bind1 --as--o v8 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P214".-> v9 bind2[/"concat('https://viaf.org/viaf/',str(?viaf))"/] v9 --o bind2 bind2 --as--o v10 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P12702".-> v4 bind3[/"concat('https://www.komako.org.nz/person/',str(?komid))"/] v4 --o bind3 bind3 --as--o v11 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c18 --"wikibase:language"--> c20 end bind9[/"?lccnurl"/] v8 --o bind9 bind9 --as--o v12 bind10[/"?viafurl"/] v10 --o bind10 bind10 --as--o v13 bind11[/"?dob"/] v5 --o bind11 bind11 --as--o v14 bind12[/"?dod"/] v6 --o bind12 bind12 --as--o v15 bind13[/"?komurl"/] v11 --o bind13 bind13 --as--o v16