A set of SPARQL examples that are used in different TGX resources
License: https://www.gnu.org/licenses/gpl-3.0
Uses method in: https://github.com/WDscholia/scholia/tree/master/scholia/app/templates/author_events.sparql
Author aspect: events
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX target: <http://www.wikidata.org/entity/Q97270>
SELECT
(xsd:date(MIN(?start)) AS ?date)
?event ?eventLabel
(CONCAT("/event/", SUBSTR(STR(?event), 32)) AS ?eventUrl)
(GROUP_CONCAT(DISTINCT ?role; separator=", ") AS ?roles)
(GROUP_CONCAT(DISTINCT ?location_label; separator=", ") AS ?locations)
WHERE {
BIND(target: AS ?person)
{ # speaker
?event wdt:P823 ?person .
BIND("speaker" AS ?role)
} UNION { # organizer
?event wdt:P664 ?person .
BIND("organizer" AS ?role)
} UNION { # participant
?person wdt:P1344 | ^wdt:P710 ?event .
BIND("participant" AS ?role)
} UNION { # editor
?person ^wdt:P98 / wdt:P4745 ?event .
BIND("editor of proceedings" AS ?role)
} UNION { # author
?person ^wdt:P50 / wdt:P1433 / wdt:P4745 ?event .
BIND("author" AS ?role)
} UNION { # program committee member
?event wdt:P5804 ?person .
BIND("program committee member" AS ?role)
}
OPTIONAL { ?event wdt:P276 ?location . ?location rdfs:label ?location_label . FILTER (LANG(?location_label) = 'en')}
OPTIONAL { ?event wdt:P580 | wdt:P585 ?start }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en,da,de,es,fr,jp,no,ru,sv,zh". }
}
GROUP BY ?event ?eventLabel
ORDER BY DESC(?date)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?date")
v4("?event"):::projected
v8("?eventUrl")
v6("?location")
v2("?location_label"):::projected
v10("?locations")
v3("?person")
v6("?role"):::projected
v9("?roles")
v7("?start")
a1((" "))
a2((" "))
a3((" "))
c18(["#91;AUTO_LANGUAGE#93;,mul,en,da,de,es,fr,jp,no,ru,sv,zh"]):::literal
c16([http://www.bigdata.com/rdf#serviceParam]):::iri
bind0[/"http://www.wikidata.org/entity/Q97270"/]
bind0 --as--o v3
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
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;
v4 --"p:direct/P5804"--> v3
bind1[/"'program committee member'"/]
bind1 --as--o v6
end
subgraph union4r[" "]
style union4r fill:#abf,stroke-dasharray: 3 3;
a2 --"p:direct/P50"--> v3
a2 --"p:direct/P1433"--> a3
a3 --"p:direct/P4745"--> v4
bind2[/"'author'"/]
bind2 --as--o v6
end
union4r <== or ==> union4l
end
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
a1 --"p:direct/P98"--> v3
a1 --"p:direct/P4745"--> v4
bind3[/"'editor of proceedings'"/]
bind3 --as--o v6
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
subgraph union5[" Union "]
subgraph union5l[" "]
style union5l fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P710"--> v3
end
subgraph union5r[" "]
style union5r fill:#abf,stroke-dasharray: 3 3;
v3 --"p:direct/P1344"--> v4
end
union5r <== or ==> union5l
end
bind4[/"'participant'"/]
bind4 --as--o v6
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P664"--> v3
bind5[/"'organizer'"/]
bind5 --as--o v6
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P823"--> v3
bind6[/"'speaker'"/]
bind6 --as--o v6
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P276".-> v6
v6 --"rdfs:label"--> v2
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
subgraph union6[" Union "]
subgraph union6l[" "]
style union6l fill:#abf,stroke-dasharray: 3 3;
v4 -."p:direct/P585".-> v7
end
subgraph union6r[" "]
style union6r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P580"--> v7
end
union6r <== or ==> union6l
end
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c16 --"wikibase:language"--> c18
end
bind10[/"http://www.w3.org/2001/XMLSchema#date()"/]
null --o bind10
bind10 --as--o v8
bind11[/"concat('/event/',substring(str(?event),'32^^xsd:integer'))"/]
v4 --o bind11
bind11 --as--o v8
bind12[/"?role"/]
v6 --o bind12
bind12 --as--o v9
bind13[/"?location_label"/]
v2 --o bind13
bind13 --as--o v10