简体   繁体   中英

SPARQL: Find out which property is used for link

So I have the following query I would like to extend:

SELECT ?item ?itemLabel ?p ?superItem ?superItemLabel
WHERE { 
  wd:Q146 (wdt:P279 | wdt:P31 | wdt:P361 )+ ?item.
  ?item   ( wdt:P279 | wdt:P31 | wdt:P361) ?superItem.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

If you run it in the Wikidata Query Service you can see an empty column. There I would like to have the Property responsible for that specific link. So either wdt:P279 or wdt:P31 or wdt:P361 .

Is this somehow possible? And if yes how?

Best regards Max

It is possible to print property is used in a triple with the keyword VALUES .

PREFIX bd: <http://www.bigdata.com/rdf#> 
PREFIX wd: <http://www.wikidata.org/entity/> 
PREFIX wdt: <http://www.wikidata.org/prop/direct/> 
PREFIX wikibase: <http://wikiba.se/ontology#> 

SELECT ?item ?itemLabel ?p ?superItem ?superItemLabel
WHERE { 
  wd:Q146 (wdt:P279 | wdt:P31 | wdt:P361 )+ ?item.

  VALUES ?p { wdt:P279  wdt:P31  wdt:P361 }
  ?item  ?p ?superItem.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
LIMIT 50

Demo: http://linkedwiki.com/query/Find_out_which_property_is_used_for_link

Doc: https://www.w3.org/TR/sparql11-query/#inline-data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM