query-fbe6e53af01409e255fce2e1e805847a
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
- 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 {
{
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