2017-09-13 44 views
1

我试图检索某些人的寿命数据。在一段时间以前住过的人的情况下,这是有问题的。例如数据集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没有“捷径” -syntax的那个建议。

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. 
} 

所以我如何访问一个空节点引用的节点(在我的情况特别是最早的生日)在维基数据?

回答

2

但这个空白节点引用另一个节点...

事情略有不同。 earliest date财产不是_:t550690019的财产,而是声明wd:Q10261 wdt:P569 _:t550690019的财产。

在Wikidata data model中,这些注释使用qualifiers表示。

Wikidata data model

您的查询应该是:

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!

+0

我觉得自己很蠢,但我看不出它了:它的工作,但到底是什么您的查询做不同? 'FILTER'和'VALUES'似乎只是限制了它。 –

+0

仔细看:)。我会在几分钟内解释,现在我正在寻找良好的链接。 –

+0

啊,你对'P569'和'P1319'使用不同的前缀,我会很高兴有一些好的链接! –