query-fbe6e53af01409e255fce2e1e805847a

rq turtle/ttl

Taxonomy of specified entityI want to get the whole tree of entities up (entities for which the given entity is a subclass/instance) starting from a specific entity, for example from Q30642 (natural language processing). So, I would like to get for example Q21198 (computer science), then Q11862829 (academic discipline) and so on. And so - for all parents of the entity Q30642 (natural language processing). [1]: gas:service & BFSRecently I was prompted the following solution using SELECT ?subclass ?subclassLabel ?child ?childLabel ?depth WHERE { SERVICE gas:service { gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ; gas:in wd:Q21198 ; gas:linkType wdt:P31; gas:out ?subclass ; gas:out1 ?depth ; gas:out2 ?child . } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } order by ?depth 12:45, 16 May 2023 (UTC) 90.151.86.98. How can I take all parent entities both on the feature of P31 and on the feature of P279? gas:linkType (wdt:P31|wdt:P279)It works fine, but I need to list the features in the query. For example 13:34, 18 May 2023 (UTC)) talk (PiastuHi again. Maybe ask twice? regards,

Use at

PREFIX gas: <http://www.bigdata.com/rdf/gas#>
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 ?subclass ?subclassLabel ?child ?childLabel ?depth {
  {
  SERVICE gas:service {
    gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS";
                gas:in wd:Q21198; gas:linkType wdt:P31; gas:out ?subclass; gas:out1 ?depth; gas:out2 ?child. }
  }
  UNION
  {
  SERVICE gas:service {
    gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS";
                gas:in wd:Q21198; gas:linkType wdt:P279; gas:out ?subclass; gas:out1 ?depth; gas:out2 ?child. }
  }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} order by ?depth

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?child"):::projected v1("?depth"):::projected v2("?subclass"):::projected c2(["gas:program"]):::iri c6(["wd:Q21198"]):::iri c16(["en"]):::literal c12(["wdt:P279"]):::iri c8(["wdt:P31"]):::iri c4(["com.bigdata.rdf.graph.analytics.BFS"]):::literal c14(["bd:serviceParam"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c6 c2 --"gas:linkType"--> c12 c2 --"gas:out"--> v2 c2 --"gas:out1"--> v1 c2 --"gas:out2"--> v3 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c6 c2 --"gas:linkType"--> c8 c2 --"gas:out"--> v2 c2 --"gas:out1"--> v1 c2 --"gas:out2"--> v3 end end union0r <== or ==> union0l end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c14 --"wikibase:language"--> c16 end