从Wikidata中的空白节点检索数据 [英] Retrieving data from blank nodes in Wikidata

查看:14
本文介绍了从Wikidata中的空白节点检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检索有关某些人寿命的数据。这在不久前生活过的人的情况下是有问题的。例如Pythagoras的数据集似乎有一个所谓的date of birth (P569)的"空白节点"。但此空白节点引用了另一个节点earliest date (P1319),该节点具有我可以正常使用的数据。

但是由于某些原因,我无法检索该节点。My first try looked like this,但不知何故这会导致一个完全空的结果集:

SELECT DISTINCT ?person ?name ?dateofbirth ?earliestdateofbirth WHERE {
  ?person wdt:P31 wd:Q5.         # This thing is Human
  ?person rdfs:label ?name.      # Name for better conformation
  ?person wdt:P569 ?dateofbirth. # Birthday may result in a blank node
  ?dateofbirth wdt:P1319 ?earliestdateofbirth # Problem: Plausbible Birth
}

然后我发现另一个语法建议使用?person wdt:P569/wdt:P1319 ?earliestdateofbirth作为我在but this also ends with a empty result set上面执行的显式导航的某种"快捷"语法。

SELECT DISTINCT ?person ?name ?dateofbirth ?earliestdateofbirth WHERE {
  ?person wdt:P31 wd:Q5.         # Is Human
  ?person rdfs:label ?name.      # Name for better conformation
  ?person wdt:P569/wdt:P1319 ?earliestdateofbirth. 
}

那么,如何访问Wikidata中的空白节点(在我的情况下,特别是最早的生日)引用的节点?

推荐答案

但是此空白节点引用了另一个节点…

情况略有不同。earliest date属性不是_:t550690019的属性,而是语句wd:Q10261 wdt:P569 _:t550690019的一个属性。

在Wikidatadata model中,这些批注使用qualifiers表示。

您的查询应该是:

SELECT DISTINCT ?person ?name ?dateofbirth ?earliestdateofbirth WHERE {
  VALUES (?person) {(wd:Q10261)}
  ?person wdt:P31 wd:Q5.         # --Is human
  ?person rdfs:label ?name.      # --Name for better conformation
  ?person p:P569/pq:P1319 ?earliestdateofbirth. 
  FILTER (lang(?name) = "en")
}

Try it!


顺便说一下,时间精度(在知道出生日期时使用)是另一个限定符:

SELECT ?person ?personLabel ?value ?precisionLabel {
  VALUES (?person) {(wd:Q859) (wd:Q9235)}
  ?person  wdt:P31  wd:Q5 ;
           p:P569/psv:P569  [ wikibase:timeValue  ?value ;
                              wikibase:timePrecision  ?precisionInteger ]
  {
  SELECT ?precision (xsd:integer(?precisionDecimal) AS ?precisionInteger) {
    ?precision  wdt:P2803  ?precisionDecimal .
  }
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!

这篇关于从Wikidata中的空白节点检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆