query-ada9191886f0de7081d42f166124254d

rq turtle/ttl

Feature proposal: instance classes15:37, 24 April 2023 (UTC) pagetalk / TomT0m author This section was archived on a request by: statements which show an expandable section with the superclass tree). It would be useful to have also a superclass tree for the classes that the entity is instance of. (P279)subclass of statements this extension shows " is also a(n)..." but does not show any superclass tree (unlike (P31)instance of Thank you for creating this useful tool. I have a feature proposal: currently below with the appropriate entity: (Q1001)Mahatma Gandhi This tree could be obtained with a query like this, substituting the example entity

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#>
#defaultView:Graph
SELECT ?superClass ?rgb ?parent ?superClassLabel ?parentLabel
WHERE {
  {
    bind ('FF0000' as ?rgb).
    bind (wd:Q1001 as ?superClass).
    ?superClass wdt:P31 ?parent.
  } UNION {
    bind ('FFFFFF' as ?rgb).
    wd:Q1001 wdt:P31 ?class.
    ?class wdt:P279* ?superClass.
    ?superClass wdt:P279 ?parent.
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "it,en,[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?class") v3("?parent"):::projected v4("?rgb"):::projected v2("?superClass"):::projected c5(["bd:serviceParam"]):::iri c7(["it,en,#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q1001"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; bind0[/"'FFFFFF'"/] bind0 --as--o v4 c2 --"wdt:P31"--> v4 v4 --"wdt:P279"--> v2 v2 --"wdt:P279"--> v3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; bind1[/"'FF0000'"/] bind1 --as--o v4 bind2[/"'wd:Q1001'"/] bind2 --as--o v2 v2 --"wdt:P31"--> v3 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end