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-episode_data.sparql
Podcast-episode 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 xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX target: <http://www.wikidata.org/entity/Q124268563>
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
{
?podcast wdt:P179 ?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("../podcast/", ?q) AS ?valueUrl)
BIND(3 AS ?order)
BIND("Podcast" AS ?description)
}
UNION
{
?podcast wdt:P577 ?publication_datetime .
BIND(xsd:date(?publication_datetime) AS ?value)
BIND(4 AS ?order)
BIND("Publication date" AS ?description)
}
UNION
{
?podcast wdt:P4908 ?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("../podcast-season/", ?q) AS ?valueUrl)
BIND(5 AS ?order)
BIND("Season" AS ?description)
}
UNION
{
?podcast wdt:P155 ?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("../podcast-episode/", ?q) AS ?valueUrl)
BIND(6 AS ?order)
BIND("Previous episode" AS ?description)
}
UNION
{
?podcast wdt:P156 ?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("../podcast-episode/", ?q) AS ?valueUrl)
BIND(7 AS ?order)
BIND("Next episode" AS ?description)
}
}
ORDER BY ?order
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?_anon_d5635a4148474aba9b1ec2d6f2e48935193")
v13("?description"):::projected
v6("?dummy")
v7("?iri")
v13("?order")
v2("?podcast")
v12("?publication_datetime")
v13("?q")
v13("?value"):::projected
v13("?valueUrl"):::projected
v9("?value_")
v5("?value_string")
c3([http://www.wikidata.org/entity/Q124268563]):::iri
bind0[/"http://www.wikidata.org/entity/Q124268563"/]
bind0 --as--o v2
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;
subgraph union5[" Union "]
subgraph union5l[" "]
style union5l fill:#abf,stroke-dasharray: 3 3;
f1[["?value_string = 'en'"]]
f1 --> v5
v2 --"p:direct/P156"--> v7
bind2[/"substring(str(?iri),'32^^xsd:integer')"/]
v7 --o bind2
bind2 --as--o v13
v7 --"rdfs:label"--> v5
bind3[/"str(?value_string)"/]
v5 --o bind3
bind3 --as--o v13
bind4[/"concat('../podcast-episode/',?q)"/]
v13 --o bind4
bind4 --as--o v13
bind5[/"'7^^xsd:integer'"/]
bind5 --as--o v13
bind6[/"'Next episode'"/]
bind6 --as--o v13
end
subgraph union5r[" "]
style union5r fill:#abf,stroke-dasharray: 3 3;
f7[["?value_string = 'en'"]]
f7 --> v5
v2 --"p:direct/P155"--> v7
bind8[/"substring(str(?iri),'32^^xsd:integer')"/]
v7 --o bind8
bind8 --as--o v13
v7 --"rdfs:label"--> v5
bind9[/"str(?value_string)"/]
v5 --o bind9
bind9 --as--o v13
bind10[/"concat('../podcast-episode/',?q)"/]
v13 --o bind10
bind10 --as--o v13
bind11[/"'6^^xsd:integer'"/]
bind11 --as--o v13
bind12[/"'Previous episode'"/]
bind12 --as--o v13
end
union5r <== or ==> union5l
end
end
subgraph union4r[" "]
style union4r fill:#abf,stroke-dasharray: 3 3;
f13[["?value_string = 'en'"]]
f13 --> v5
v2 --"p:direct/P4908"--> v7
bind14[/"substring(str(?iri),'32^^xsd:integer')"/]
v7 --o bind14
bind14 --as--o v13
v7 --"rdfs:label"--> v5
bind15[/"str(?value_string)"/]
v5 --o bind15
bind15 --as--o v13
bind16[/"concat('../podcast-season/',?q)"/]
v13 --o bind16
bind16 --as--o v13
bind17[/"'5^^xsd:integer'"/]
bind17 --as--o v13
bind18[/"'Season'"/]
bind18 --as--o v13
end
union4r <== or ==> union4l
end
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P577"--> v12
bind19[/"http://www.w3.org/2001/XMLSchema#date(?publication_datetime)"/]
v12 --o bind19
bind19 --as--o v13
bind20[/"'4^^xsd:integer'"/]
bind20 --as--o v13
bind21[/"'Publication date'"/]
bind21 --as--o v13
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
f22[["?value_string = 'en'"]]
f22 --> v5
v2 --"p:direct/P179"--> v7
bind23[/"substring(str(?iri),'32^^xsd:integer')"/]
v7 --o bind23
bind23 --as--o v13
v7 --"rdfs:label"--> v5
bind24[/"str(?value_string)"/]
v5 --o bind24
bind24 --as--o v13
bind25[/"concat('../podcast/',?q)"/]
v13 --o bind25
bind25 --as--o v13
bind26[/"'3^^xsd:integer'"/]
bind26 --as--o v13
bind27[/"'Podcast'"/]
bind27 --as--o v13
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
f28[["?value_string = 'en'"]]
f28 --> v5
bind29[/"'1^^xsd:integer'"/]
bind29 --as--o v6
c3 --"p:direct/P371"--> v7
bind30[/"substring(str(?iri),'32^^xsd:integer')"/]
v7 --o bind30
bind30 --as--o v13
v7 --"rdfs:label"--> v5
bind31[/"?value_string?q"/]
v5 --o bind31
v13 --o bind31
bind31 --as--o v9
bind34[/"?q"/]
v13 --o bind34
bind34 --as--o v10
bind35[/"'2^^xsd:integer'"/]
bind35 --as--o v13
bind36[/"'Presenters'"/]
bind36 --as--o v13
bind37[/"?value_"/]
v9 --o bind37
bind37 --as--o v13
bind38[/"concat('../authors/',)"/]
null --o bind38
bind38 --as--o v13
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
bind39[/"'1^^xsd:integer'"/]
bind39 --as--o v13
bind40[/"'Title'"/]
bind40 --as--o v13
v2 --"p:direct/P1476"--> v13
end
union0r <== or ==> union0l
end