User:Rdrg109/3/1
< User:Rdrg109 | 3
This page contains a SPARQL query that builds a graph of conference presentations in Wikidata Data Reuse Days 2022.
#defaultView:Graph
SELECT
?item
?itemLabel
?rgb
?linkTo
?linkToLabel
?edgeLabel
WITH {
# Get all the instances of the talks
SELECT DISTINCT ?item {
?item wdt:P31 wd:Q110886488.
}
} AS %0
WITH {
# Get talks with a given color
SELECT ("00ff00" AS ?rgb) ?item ?linkTo (?propertyLabel AS ?edgeLabel) {
INCLUDE %0.
{?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").
}
} AS %1
WITH {
SELECT ?speaker {
INCLUDE %0
?item wdt:P823 ?speaker.
}
} AS %2
WITH {
SELECT ("0000ff" AS ?rgb) (?speaker AS ?item) {
INCLUDE %2.
}
} AS %3
WITH {
SELECT ?mainSubject {
INCLUDE %0
?item wdt:P921 ?mainSubject.
}
} AS %4
WITH {
SELECT ("ff0000" AS ?rgb) (?mainSubject AS ?item) {
INCLUDE %4.
}
} AS %5
{
{INCLUDE %0}
UNION
{INCLUDE %3}
UNION
{INCLUDE %5}
# This OPTIONAL makes all talks to be shown regardless whether they
# are pointed or point another entity using P155 and P156.
OPTIONAL{INCLUDE %1}.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}