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/podcast_data.sparql
Podcast aspect: data
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 target: <http://www.wikidata.org/entity/Q124262264>
SELECT DISTINCT ?description ?value ?valueUrl
WHERE {
BIND(target: AS ?podcast)
{
BIND(1 AS ?order)
BIND("Title" AS ?description)
?podcast wdt:P1476 ?value .
}
UNION
{
SELECT
(2 AS ?order)
("Presenters" AS ?description)
(GROUP_CONCAT(?value_; separator=", ") AS ?value)
(CONCAT("../authors/", GROUP_CONCAT(?q; separator=",")) AS ?valueUrl)
{
BIND(1 AS ?dummy)
target: wdt:P371 ?iri .
BIND(SUBSTR(STR(?iri), 32) AS ?q)
?iri rdfs:label ?value_string .
FILTER (LANG(?value_string) = 'en')
BIND(COALESCE(?value_string, ?q) AS ?value_)
}
GROUP BY ?dummy
}
UNION
{
BIND(3 AS ?order)
BIND("Language" AS ?description)
?podcast wdt:P407 ?iri .
BIND(SUBSTR(STR(?iri), 32) AS ?q)
?iri rdfs:label ?value_string .
FILTER (LANG(?value_string) = 'en')
BIND(STR(?value_string) AS ?value)
BIND(CONCAT("../language/", ?q, "/podcast") AS ?valueUrl)
}
UNION
{
SELECT ?description ?order (MAX(?value_) AS ?value) WHERE {
BIND(target: AS ?podcast)
?podcast wdt:P1113 ?value_ .
BIND(4 AS ?order)
BIND("Number of episodes" AS ?description)
} GROUP BY ?description ?order
}
UNION
{
BIND(5 AS ?order)
BIND("Web feed" AS ?description)
?podcast wdt:P1019 ?valueUrl .
BIND("feed" AS ?value)
}
}
ORDER BY ?order
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?_anon_d5635a4148474aba9b1ec2d6f2e48935390")
v12("?description"):::projected
v6("?dummy")
v7("?iri")
v12("?order")
v12("?podcast")
v12("?q")
v12("?value"):::projected
v12("?valueUrl"):::projected
v9("?value_")
v5("?value_string")
c3([http://www.wikidata.org/entity/Q124262264]):::iri
bind0[/"http://www.wikidata.org/entity/Q124262264"/]
bind0 --as--o v12
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;
bind1[/"'5^^xsd:integer'"/]
bind1 --as--o v12
bind2[/"'Web feed'"/]
bind2 --as--o v12
v12 --"p:direct/P1019"--> v12
bind3[/"'feed'"/]
bind3 --as--o v12
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
bind4[/"http://www.wikidata.org/entity/Q124262264"/]
bind4 --as--o v12
v12 --"p:direct/P1113"--> v9
bind5[/"'4^^xsd:integer'"/]
bind5 --as--o v12
bind6[/"'Number of episodes'"/]
bind6 --as--o v12
bind8[/"max(?value_)"/]
v9 --o bind8
bind8 --as--o v12
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
f9[["?value_string = 'en'"]]
f9 --> v5
bind10[/"'3^^xsd:integer'"/]
bind10 --as--o v12
bind11[/"'Language'"/]
bind11 --as--o v12
v12 --"p:direct/P407"--> v7
bind12[/"substring(str(?iri),'32^^xsd:integer')"/]
v7 --o bind12
bind12 --as--o v12
v7 --"rdfs:label"--> v5
bind13[/"str(?value_string)"/]
v5 --o bind13
bind13 --as--o v12
bind14[/"concat('../language/',?q,'/podcast')"/]
v12 --o bind14
bind14 --as--o v12
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
f15[["?value_string = 'en'"]]
f15 --> v5
bind16[/"'1^^xsd:integer'"/]
bind16 --as--o v6
c3 --"p:direct/P371"--> v7
bind17[/"substring(str(?iri),'32^^xsd:integer')"/]
v7 --o bind17
bind17 --as--o v12
v7 --"rdfs:label"--> v5
bind18[/"?value_string?q"/]
v5 --o bind18
v12 --o bind18
bind18 --as--o v9
bind21[/"?q"/]
v12 --o bind21
bind21 --as--o v10
bind22[/"'2^^xsd:integer'"/]
bind22 --as--o v12
bind23[/"'Presenters'"/]
bind23 --as--o v12
bind24[/"?value_"/]
v9 --o bind24
bind24 --as--o v12
bind25[/"concat('../authors/',)"/]
null --o bind25
bind25 --as--o v12
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
bind26[/"'1^^xsd:integer'"/]
bind26 --as--o v12
bind27[/"'Title'"/]
bind27 --as--o v12
v12 --"p:direct/P1476"--> v12
end
union0r <== or ==> union0l
end