query-5fd91fe746c46a5df5b02e93a3a08185
Shorten URL Example: Is there any way to shorten the URLs to Wikipedia articles?
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Timeline
SELECT DISTINCT ?president ?presidentLabel ?start ?end ?article
(SAMPLE(?image) as ?image)
WHERE {
?president wdt:P31 wd:Q5 .
?president p:P39 ?presidentStatement .
?presidentStatement ps:P39 wd:Q11696 .
OPTIONAL { ?presidentStatement pq:P580 ?start }
OPTIONAL { ?presidentStatement pq:P582 ?end }
OPTIONAL { ?president wdt:P18 ?image }
OPTIONAL {
?article schema:about ?president .
?article schema:isPartOf <https://en.wikipedia.org/> .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} GROUP BY ?president ?presidentLabel ?start ?end ?article
ORDER BY ?start
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?article"):::projected
v4("?end"):::projected
v7("?image"):::projected
v2("?president"):::projected
v3("?presidentStatement")
v1("?start"):::projected
c15(["en"]):::literal
c11([https://en.wikipedia.org/]):::iri
c13(["bd:serviceParam"]):::iri
c2(["wd:Q5"]):::iri
c5(["wd:Q11696"]):::iri
v2 --"p:direct/P31"--> c2
v2 --"p:P39"--> v3
v3 --"p:statement/P39"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P580".-> v1
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P582".-> v4
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P18".-> v7
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v6 -."schema:about".-> v2
v6 --"schema:isPartOf"--> c11
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c15
end
bind1[/"sample(?image)"/]
v7 --o bind1
bind1 --as--o v7