query-a8f61885ecd83514d57a669190801d92

rq turtle/ttl

TODO

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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 ?item  (GROUP_CONCAT(DISTINCT ?discog) as ?discogs)  (GROUP_CONCAT(DISTINCT ?rymurl) as ?rym_url) (GROUP_CONCAT(DISTINCT ?mburl) as ?mb_url) (GROUP_CONCAT(DISTINCT ?amurl) as ?am_url) WHERE {
BIND( xsd:integer( STRAFTER( STR( ?item ), STR( wd:Q ) ) ) AS ?qid )
  ?item wdt:P31/wdt:P279* wd:Q188451.
  OPTIONAL {?item wdt:P17 ?p17.} .
  OPTIONAL {?item wdt:P495 ?p495.} .
  OPTIONAL {?item wdt:P9218 ?DgID. 
            BIND(CONCAT("[https://www.discogs.com/genre/",?DgID," ",?DgID,"]") as ?DgIDurl)}
  OPTIONAL {?item wdt:P9219 ?DsID. 
            BIND(CONCAT("[https://www.discogs.com/style/",?DsID," ",?DsID,"]") as ?DsIDurl)}
  BIND(IF(BOUND(?DgIDurl) && BOUND(?DsIDurl),concat(?DgIDurl," ",?DsIDurl),
          IF(BOUND(?DgIDurl),?DgIDurl,
            IF(BOUND(?DsIDurl),?DsIDurl,""))) as ?discog) 
  OPTIONAL {?item wdt:P9173 ?rymID. BIND(REPLACE(?rymID," ","%20") as ?rymID1)
            BIND(CONCAT("[https://rateyourmusic.com/genre/",?rymID1," ",?rymID1,"]") as ?rymurl_)
            BIND(if(?rymurl_="[https://rateyourmusic.com/genre/Trap%20[EDM] Trap%20[EDM]]",
                                  "[https://rateyourmusic.com/genre/Trap%20%5BEDM%5D Trap (EDM)]",?rymurl_) as ?rymurl)}
  OPTIONAL {?item wdt:P8052 ?mbID. 
            wd:P8052 rdfs:label ?propItemLabelmb . FILTER (lang(?propItemLabelmb) = "en"). 
            BIND(CONCAT("[https://musicbrainz.org/genre/",?mbID," ID]") as ?mburl)}
  OPTIONAL {?item wdt:P9185 ?amID. 
            wd:P9185 rdfs:label ?propItemLabelam . FILTER (lang(?propItemLabelam) = "en"). 
            BIND(CONCAT("[https://www.allmusic.com/style/",?amID," ID]") as ?amurl)} 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} group by ?item

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?DgID") v8("?DgIDurl") v9("?DsID") v10("?DsIDurl") v18("?amID") v23("?am_url") v19("?amurl"):::projected v11("?discog"):::projected v20("?discogs") v4("?item"):::projected v16("?mbID") v22("?mb_url") v17("?mburl"):::projected v5("?p17") v6("?p495") v1("?propItemLabelam") v2("?propItemLabelmb") v3("?qid") v12("?rymID") v13("?rymID1") v21("?rym_url") v15("?rymurl"):::projected v14("?rymurl_") a1((" ")) c16(["bd:serviceParam"]):::iri c4(["wd:Q188451"]):::iri c11(["wd:P8052"]):::iri c14(["wd:P9185"]):::iri c18(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/"http://www.w3.org/2001/XMLSchema#integer(substring-after(str(?item),str('wd:Q')))"/] v4 --o bind0 bind0 --as--o v3 v4 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P17".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P495".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P9218".-> v7 bind1[/"concat('#91;https://www.discogs.com/genre/',?DgID,' ',?DgID,'#93;')"/] v7 --o bind1 bind1 --as--o v8 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P9219".-> v9 bind2[/"concat('#91;https://www.discogs.com/style/',?DsID,' ',?DsID,'#93;')"/] v9 --o bind2 bind2 --as--o v10 end bind3[/"if(bound(?DgIDurl)bound(?DsIDurl),concat(?DgIDurl,' ',?DsIDurl),if(bound(?DgIDurl),?DgIDurl,if(bound(?DsIDurl),?DsIDurl,'')))"/] v8 --o bind3 v10 --o bind3 bind3 --as--o v11 subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P9173".-> v12 bind4[/"replace(?rymID,' ','%20')"/] v12 --o bind4 bind4 --as--o v13 bind5[/"concat('#91;https://rateyourmusic.com/genre/',?rymID1,' ',?rymID1,'#93;')"/] v13 --o bind5 bind5 --as--o v14 bind6[/"if(?rymurl_ = '#91;https://rateyourmusic.com/genre/Trap%20#91;EDM#93; Trap%20#91;EDM#93;#93;','#91;https://rateyourmusic.com/genre/Trap%20%5BEDM%5D Trap (EDM)#93;',?rymurl_)"/] v14 --o bind6 bind6 --as--o v15 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P8052".-> v16 c11 --"rdfs:label"--> v2 bind7[/"concat('#91;https://musicbrainz.org/genre/',?mbID,' ID#93;')"/] v16 --o bind7 bind7 --as--o v17 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P9185".-> v18 c14 --"rdfs:label"--> v1 bind8[/"concat('#91;https://www.allmusic.com/style/',?amID,' ID#93;')"/] v18 --o bind8 bind8 --as--o v19 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c18 end bind13[/"?discog"/] v11 --o bind13 bind13 --as--o v20 bind14[/"?rymurl"/] v15 --o bind14 bind14 --as--o v21 bind15[/"?mburl"/] v17 --o bind15 bind15 --as--o v22 bind16[/"?amurl"/] v19 --o bind16 bind16 --as--o v23