Reputation: 58
I would like to query all wikipedia articles that have a property P585 (point in time). Unfortunately, some of these are very obscure and are under sub-sub properties, like on the picture. I would like to be able to filter for these dates, no matter under what property they are.
The query: "?item p:P585/ps:P585 ?date. " only gives back results where point in time is the root category, and no matter what I try, I can't get all articles that have "point in time" somewhere. Or if not possible, the very least I would like to be able to specify "significant event/*/point in time"...
Thank you!
Upvotes: 2
Views: 428
Reputation: 1966
The issue is that you want 'point in time' to be a qualifying property as opposed to the property of a statement as you currently wrote. Let me clarify what I mean by considering the following query about Q76
(Barack Obama) and P26
(spouse):
SELECT *
WHERE {
wd:Q76 p:P26 ?statement .
?statement ?p ?o
}
ps:P26
tells us who the object of the statement is, i.e. Michelle Obama.
Note: Often you will find that for every ?a p:Px/ps:Px ?b
there is ?a wdt:Px ?b
(this depends on what the rank of the statement is, e.g. there are two statements about Obama's place ob birth, on listing it as Hawaii, the other as Kenya, but only the statement that lists Hawaii is ranked high enough to warrant a direct link with wdt
).
However if we want to find the qualifying properties about the statement (e.g. when the Obamas were married, where etc), then we need a different namespace, in this case pq
, where 'q' stands for qualifier.
How does this relate to your example then?
In your example, the 'main' property you are looking for is 'significant event', so P793
, and the qualifier is P585
.
Thus your query should be like this:
SELECT *
WHERE {
?subject p:P793 ?statement .
?statement pq:P585 ?date .
}
Or for short:
SELECT *
WHERE {
?subject p:P793/pq:P585 ?date .
}
If you are further interested in the object of the significant event (in your example this is 'rocket launch' Q797476
), then you may specify this like so:
SELECT *
WHERE {
?subject p:P793 ?statement .
?statement pq:P585 ?date ;
ps:P793 wd:Q797476 .
}
Notice the role that the namespaces and the property numbers play.
Upvotes: 5