query-ee343f4d9236fd8f89bff08ef13c8ad9
TODO
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 bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?start ?end
(GROUP_CONCAT(DISTINCT ?instancelist; SEPARATOR = ", ") AS ?instances)
(GROUP_CONCAT(DISTINCT ?propertylist; SEPARATOR = ", ") AS ?properties)
(SAMPLE (DISTINCT ?thumbs) as ?thumb)
(SAMPLE (?positions) as ?position)
WHERE
{
{ {
SELECT ?item ?instancelist ?thumbs WHERE
{
?item wdt:P17 wd:Q145 .
?item wdt:P31/wdt:P279* wd:Q1785071 .
BIND("fort" as ?instancelist)
BIND("fort.png" AS ?thumbs)
} }} UNION { {
SELECT ?item ?instancelist ?thumbs WHERE
{
?item wdt:P17 wd:Q145 .
{ ?item wdt:P31/wdt:P279* wd:Q56344492 . }
UNION { ?item wdt:P31/wdt:P279* wd:Q90754 . }
UNION { ?item wdt:P31/wdt:P279* wd:Q947103 . }
BIND("tower" as ?instancelist)
BIND("tower.png" AS ?thumbs)
} }} UNION { {
SELECT ?item ?instancelist ?thumbs WHERE
{
?item wdt:P17 wd:Q145 .
?item wdt:P31 wd:Q2772772 .
BIND("museum" as ?instancelist)
BIND("museum.png" AS ?thumbs)
} }}
OPTIONAL {?item wdt:P3134 ?tripadvisor. BIND(CONCAT("[https://www.tripadvisor.com/",?tripadvisor," tripadvisor]") AS ?propertylist)}
OPTIONAL {?item wdt:P625 ?position1}
OPTIONAL {?item wdt:P276 ?locations. ?locations wdt:P625 ?position2}
BIND(COALESCE(?position1,?position2) AS ?positions)
OPTIONAL {?item wdt:P729 ?serviceentry}
OPTIONAL {?item wdt:P571 ?inception}
OPTIONAL {?item wdt:P585 ?pointintime}
OPTIONAL {?item wdt:P580 ?starttime}
BIND(IF(?instancelist != "region",COALESCE(?awarded,?serviceentry,?inception,?pointintime,?starttime),"") as ?start)
OPTIONAL {?item wdt:P730 ?serviceretirement}
OPTIONAL {?item wdt:P576 ?abolished}
OPTIONAL {?item wdt:P582 ?endtime}
BIND(COALESCE(?serviceretirement,?abolished,?pointintime,?endtime) as ?end)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP by ?item ?start ?end
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v16("?abolished")
v18("?end"):::projected
v17("?endtime")
v11("?inception")
v4("?instancelist"):::projected
v19("?instances")
v1("?item"):::projected
v7("?locations")
v12("?pointintime")
v22("?position")
v6("?position1")
v8("?position2")
v9("?positions"):::projected
v20("?properties")
v5("?propertylist"):::projected
v10("?serviceentry")
v15("?serviceretirement")
v14("?start"):::projected
v13("?starttime")
v21("?thumb")
v4("?thumbs"):::projected
v4("?tripadvisor")
a1((" "))
a2((" "))
a3((" "))
a4((" "))
c9(["wd:Q2772772"]):::iri
c6(["wd:Q56344492"]):::iri
c8(["wd:Q947103"]):::iri
c7(["wd:Q90754"]):::iri
c5(["wd:Q1785071"]):::iri
c21(["bd:serviceParam"]):::iri
c23(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c2(["wd:Q145"]):::iri
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;
v1 --"wdt:P17"--> c2
v1 --"wdt:P31"--> c9
bind0[/"'museum'"/]
bind0 --as--o v4
bind1[/"'museum.png'"/]
bind1 --as--o v4
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P17"--> c2
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;
v1 --"wdt:P31"--> a4
a4 --"wdt:P279"--> c8
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P31"--> a3
a3 --"wdt:P279"--> c7
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c6
end
union2r <== or ==> union2l
end
bind2[/"'tower'"/]
bind2 --as--o v4
bind3[/"'tower.png'"/]
bind3 --as--o v4
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P17"--> c2
v1 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c5
bind4[/"'fort'"/]
bind4 --as--o v4
bind5[/"'fort.png'"/]
bind5 --as--o v4
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P3134".-> v4
bind6[/"concat('#91;https://www.tripadvisor.com/',?tripadvisor,' tripadvisor#93;')"/]
v4 --o bind6
bind6 --as--o v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P625".-> v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P276".-> v7
v7 --"wdt:P625"--> v8
end
bind7[/"?position1?position2"/]
v6 --o bind7
v8 --o bind7
bind7 --as--o v9
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P729".-> v10
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P571".-> v11
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P585".-> v12
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P580".-> v13
end
bind8[/"if(?instancelist != 'region',?awarded?serviceentry?inception?pointintime?starttime,'')"/]
v4 --o bind8
null --o bind8
v10 --o bind8
v11 --o bind8
v12 --o bind8
v13 --o bind8
bind8 --as--o v14
subgraph optional7["(optional)"]
style optional7 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P730".-> v15
end
subgraph optional8["(optional)"]
style optional8 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P576".-> v16
end
subgraph optional9["(optional)"]
style optional9 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P582".-> v17
end
bind9[/"?serviceretirement?abolished?pointintime?endtime"/]
v15 --o bind9
v16 --o bind9
v12 --o bind9
v17 --o bind9
bind9 --as--o v18
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c21 --"wikibase:language"--> c23
end
bind14[/"?instancelist"/]
v4 --o bind14
bind14 --as--o v19
bind15[/"?propertylist"/]
v5 --o bind15
bind15 --as--o v20
bind16[/"sample(?thumbs)"/]
v4 --o bind16
bind16 --as--o v21
bind17[/"sample(?positions)"/]
v9 --o bind17
bind17 --as--o v22