We are creating an application that use data from Wikidata services with Sparql queries. The basic task is to get all properties of an item with corresponding units and precision.
There is a great sample of a query here, but it lacks data on units and precision. We added some details to this sample, but units are available only for specific property P2102.
So the question is - how to use not specific property (i.e. generic properties, unlike specific p:P2102, ps:P2102 or psv:P2102 in sample below) in Sparql generic queries like this ?
Here is a sample of our query :
SELECT ?wd ?wdLabel ?wdDescription ?ps_ ?ps_Label ?ps_Description ?wdpq ?wdpqLabel ?wdpqDescription ?pq_ ?pq_Label ?pq_Description ?bpUnit ?bpUnitLabel {
VALUES (?itm) {(wd:Q407225)}
?itm ?p ?statement .
?statement ?ps ?ps_ .
?wd wikibase:claim ?p.
?wd wikibase:statementProperty ?ps.
OPTIONAL {
?statement ?pq ?pq_ .
?wdpq wikibase:qualifier ?pq .
?itm p:P2102 [ # -- custom property unit
ps:P2102 ?bp ;
psv:P2102/wikibase:quantityUnit ?bpUnit
].
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?wd ?statement ?ps_