query-33b5d034d4907bba7b3a769d978a8ec7
Mastodon accounts in Scotland
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map
SELECT DISTINCT #(?orgTypeLabel AS ?layer)
?loc ?org ?orgLabel
?tmp17Label ?tmp131Label ?tmp159Label
WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
VALUES ?scotmarks {wd:Q22 wd:Q15060255 }
?org wdt:P4033 ?MastName.
?org wdt:P31 ?orgType.
FILTER (?orgType != wd:Q5). #ignore individuals
{?org wdt:P131 ?scotmarks.}
UNION {?org wdt:P131 ?orgloc1. ?orgloc1 wdt:P31/wdt:P131 ?scotmarks.}
UNION {?org wdt:P159 ?orgpl. { ?orgpl wdt:P31/wdt:P131 ?scotmarks.} UNION {?orgpl wdt:P131 ?orgl2. ?orgl2 wdt:P31/wdt:P131 ?scotmarks.}.}.
OPTIONAL {?org wdt:P17 ?tmp17}. OPTIONAL {?org wdt:P131 ?tmp131}. OPTIONAL {?org wdt:P159 ?tmp159}.
BIND (strafter(?MastName,"@") AS ?hostAt).
OPTIONAL {?org wdt:P625 ?loc1}.
OPTIONAL {?org wdt:P159 ?orghq. ?orghq wdt:P625 ?hloc.}.
OPTIONAL {?org wdt:P131 ?orgwhere. ?orgwhere wdt:P625 ?aloc.}.
BIND (IF(BOUND(?loc1),?loc1,IF(BOUND(?hloc),?hloc,IF (BOUND(?aloc),?aloc,?NULL))) AS ?loc).
?orgType rdfs:label ?orgTypeLabel filter (lang(?orgTypeLabel) = "en"). #P279 to level up?
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?MastName")
v17("?aloc")
v15("?hloc")
v12("?hostAt")
v18("?loc"):::projected
v13("?loc1")
v4("?org"):::projected
v2("?orgType")
v1("?orgTypeLabel")
v14("?orghq")
v8("?orgl2")
v6("?orgloc1")
v7("?orgpl")
v16("?orgwhere")
v3("?scotmarks")
v10("?tmp131")
v11("?tmp159")
v9("?tmp17")
a1((" "))
a2((" "))
a3((" "))
c4(["bd:serviceParam"]):::iri
c6(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?orgTypeLabel = 'en'"]]
f0 --> v1
f1[["?orgType != 'wd:Q5'"]]
f1 --> v2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c4 --"wikibase:language"--> c6
end
bind2[/VALUES ?scotmarks/]
bind2-->v3
bind20(["wd:Q22"])
bind20 --> bind2
bind21(["wd:Q15060255"])
bind21 --> bind2
v4 --"wdt:P4033"--> v5
v4 --"wdt:P31"--> 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;
v4 --"wdt:P159"--> v7
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
v7 --"wdt:P131"--> v8
v8 --"wdt:P31"--> a3
a3 --"wdt:P131"--> v3
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v7 --"wdt:P31"--> a2
a2 --"wdt:P131"--> v3
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v4 --"wdt:P131"--> v6
v6 --"wdt:P31"--> a1
a1 --"wdt:P131"--> v3
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 --"wdt:P131"--> v3
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P17".-> v9
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P131".-> v10
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P159".-> v11
end
bind3[/"substring-after(?MastName,'@')"/]
v5 --o bind3
bind3 --as--o v12
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P625".-> v13
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P159".-> v14
v14 --"wdt:P625"--> v15
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P131".-> v16
v16 --"wdt:P625"--> v17
end
bind4[/"if(bound(?loc1),?loc1,if(bound(?hloc),?hloc,if(bound(?aloc),?aloc,?NULL)))"/]
v13 --o bind4
v15 --o bind4
v17 --o bind4
null --o bind4
bind4 --as--o v18
v2 --"rdfs:label"--> v1