query-2b89d368a64e71b26c6b943d1a717a36

rq turtle/ttl

This page contains a SPARQL query that builds a graph of conference presentations in Wikidata Data Reuse Days 2022.

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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Graph
SELECT
  ?item
  ?itemLabel
  ?rgb
  ?linkTo
  ?linkToLabel
  ?edgeLabel
{
  { {
  # Get all the instances of the talks
  SELECT DISTINCT ?item {
    ?item wdt:P31 wd:Q110886488.
  }
}}
  UNION
  { {
  SELECT ("0000ff" AS ?rgb) (?speaker AS ?item) {
     {
  SELECT ?speaker {
     {
  # Get all the instances of the talks
  SELECT DISTINCT ?item {
    ?item wdt:P31 wd:Q110886488.
  }
}    ?item wdt:P823 ?speaker.
  }
}
  }
}}
  UNION
  { {
  SELECT ("ff0000" AS ?rgb) (?mainSubject AS ?item) {
     {
  SELECT ?mainSubject {
    INCLUDE %0
    ?item wdt:P921 ?mainSubject.
  }
}
  }
}}

  # This OPTIONAL makes all talks to be shown regardless whether they
  # are pointed or point another entity using P155 and P156.
  OPTIONAL{ {
  # Get talks with a given color
  SELECT ("00ff00" AS ?rgb) ?item ?linkTo (?propertyLabel AS ?edgeLabel) {
     {
  # Get all the instances of the talks
  SELECT DISTINCT ?item {
    ?item wdt:P31 wd:Q110886488.
  }
}
    {?item p:P155 [ps:P155 ?linkTo; ?ps []].}
    UNION
    {?item p:P156 [ps:P156 ?linkTo; ?ps []].}
    UNION
    {?item p:P921 [ps:P921 ?linkTo; ?ps []].}
    UNION
    {?item p:P823 [ps:P823 ?linkTo; ?ps []].}

    ?property wikibase:statementProperty ?ps;
              rdfs:label ?propertyLabel.

    FILTER(LANG(?propertyLabel) = "en").
  }
}}.

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Query found at