query-40f8bcd4a5e176b05b414363af3376fd

rq turtle/ttl

TODO

Use at

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 ?related ?relatedLabel ?property ?direction WHERE 
{
VALUES ?object { wd:Q42 }
{ ?related ?propa ?object .
  ?related wdt:P31 [] .
}
UNION
{ ?object ?propb ?related .
  ?related wdt:P31 [] .
}
BIND(IF(BOUND(?propa),?propa,?propb) AS ?property)
BIND(IF(BOUND(?propa),CONCAT(substr(str(?object),32,99),' is ',substr(str(?property),37,99),' of related'),CONCAT('related is ',substr(str(?property),37,99),' of ',substr(str(?object),32,99))) AS ?direction)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY UCASE(?relatedLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?direction"):::projected v2("?object") v4("?propa") v5("?propb") v6("?property"):::projected v3("?related"):::projected v1("?relatedLabel"):::projected a1((" ")) a2((" ")) c3(["bd:serviceParam"]):::iri c5(["en"]):::literal bind0[/VALUES ?object/] bind0-->v2 bind00(["wd:Q42"]) bind00 --> bind0 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 -->v5--> v3 v3 --"wdt:P31"--> a2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 -->v4--> v2 v3 --"wdt:P31"--> a1 end union0r <== or ==> union0l end bind1[/"if(bound(?propa),?propa,?propb)"/] v4 --o bind1 v5 --o bind1 bind1 --as--o v6 bind2[/"if(bound(?propa),concat(substring(str(?object),'32^^xsd:integer','99^^xsd:integer'),' is ',substring(str(?property),'37^^xsd:integer','99^^xsd:integer'),' of related'),concat('related is ',substring(str(?property),'37^^xsd:integer','99^^xsd:integer'),' of ',substring(str(?object),'32^^xsd:integer','99^^xsd:integer')))"/] v4 --o bind2 v2 --o bind2 v6 --o bind2 bind2 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c3 --"wikibase:language"--> c5 end