query-6de8be23725cb443069ebe1995def52c

rq turtle/ttl

Can we get the distance between wikidata entries?Hello community! ). I would love to get the paths connecting these entries in the sense of human -- subclass of -- X -- instance of --- Z ... leg. I perhaps could retrieve all parents of an entry save them and externally merge them, however ideally I can do this via Wikidata SPARQL directly. So is it possible to retrieve all paths connecting two entries via Wikidata SPARQL? (Q1072190)chicken nugget ) and something more distant like chicken nugget ((Q133105)leg ) and we later find the entry leg ((Q15978631)Homo sapiens (Homo sapiens or (Q5)human Let's say we have Thanks! 07:23, 19 August 2020 (UTC)) talk (SCIdude). --1 the number of graph edges, i.e. statements (E(...)) with log + E(OI think restricting the graph to P31 and P279 would give very unsatisfying results. Ideally you want every non-ID property for this. Also, I think SPARQL is not suited for this, but I would be delighted to be proven wrong. The complexity would be 14:30, 18 August 2020 (UTC)) talk (Hannes Röst ? --Wikidata:Request_a_queryMaybe as relation. In the following, substitute (wdt:P31/wdt:P279/etc) for every wdt:P171 to widen the relations searched (but emotionally prepare for failure). This would be the "pure" (some would say "naive") query: (P171)parent taxon As SCIdude mentions, this is unlikely to work in the general case. The following restricts it to just the

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?homo ?homoLabel ?root ?rootLabel ?chicken ?chickenLabel
WHERE 
{
  ?homo wdt:P225 "Homo sapiens sapiens" .
  ?chicken wdt:P225 "Gallus gallus domesticus" .
  ?chicken wdt:P171+ ?root .
  ?root ^wdt:P171+ ?homo .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?chicken"):::projected v1("?homo"):::projected v3("?root"):::projected c6(["bd:serviceParam"]):::iri c2(["Homo sapiens sapiens"]):::literal c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal c3(["Gallus gallus domesticus"]):::literal v1 --"wdt:P225"--> c2 v2 --"wdt:P225"--> c3 v2 --"wdt:P171"--> v3 v1 --"wdt:P171"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end