query-bee85da4414cec681506b3185a45e71b
Taxonomy from a specific entity 11:36, 12 May 2023 (UTC) 31.163.119.81I 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). Is it possible to do this in one request and how? Thank you! :gas:service & BFSProbably You're looking gor
Use at
- https://query.wikidata.org/sparql
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 WHERE
{
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ; gas:in wd:Q30642 ; 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
c15(["en"]):::literal
c8(["wdt:P279"]):::iri
c4(["com.bigdata.rdf.graph.analytics.BFS"]):::literal
c13(["bd:serviceParam"]):::iri
c6(["wd:Q30642"]):::iri
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
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c13 --"wikibase:language"--> c15
end