I am trying to get a list of all hyperonymes of a given Wikidata item. For instance I want to traverse the "subclass of" element for https://www.wikidata.org/wiki/Q4421.
How would the SPARQL command for https://query.wikidata.org look like?
You can use the property path (*) syntax.
In this case wdt:P279* to mention 0 or more time wdt:P279 which is subclass of equivalent in Wikidata model.
I added a few variation here to include the depth so you can order them
SELECT ?entity ?entityLabel (count(?mid) as ?depth) WHERE {
wd:Q4421 wdt:P279* ?mid.
?mid wdt:P279* ?entity
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} group by ?entity ?entityLabel
order by ?depth