在 Wikidata 中以这种方式获取有关语句和单位的信息:
SELECT ?item ?itemLabel
?height ?unitHeightLabel
?width ?unitWidthLabel
?inception ?precisionLabel WHERE {
?item wdt:P31 wd:Q184296 .
OPTIONAL {
?item p:P2048 ?stmnodeHeight . # height
?stmnodeHeight psv:P2048 ?valuenodeHeight.
?valuenodeHeight wikibase:quantityAmount ?height.
?valuenodeHeight wikibase:quantityUnit ?unitHeight.
?item p:P2049 ?stmnodeWidth . # width
?stmnodeWidth psv:P2049 ?valuenodeWidth.
?valuenodeWidth wikibase:quantityAmount ?width.
?valuenodeWidth wikibase:quantityUnit ?unitWidth.
?item p:P571/psv:P571 ?timenode .
?timenode wikibase:timeValue ?inception.
?timenode wikibase:timePrecision ?timeprecision.
# get the label of time precision (by @StanislavKralin)
{
SELECT ?precision (xsd:integer(?precisionDecimal) AS ?timeprecision) {
?precision wdt:P2803 ?precisionDecimal .
}
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} LIMIT 1
使用 SPARQL 1.1 属性路径 + Turtle 快捷方式的稍微更紧凑的版本:
SELECT ?item ?itemLabel
?height ?unitHeightLabel
?width ?unitWidthLabel
?inception ?precisionLabel WHERE {
?item wdt:P31 wd:Q184296 .
OPTIONAL {
# height
?item p:P2048/psv:P2048 [ wikibase:quantityAmount ?height ;
wikibase:quantityUnit ?unitHeight ].
# width
?item p:P2049/psv:P2049 [ wikibase:quantityAmount ?width ;
wikibase:quantityUnit ?unitWidth ].
# inception
?item p:P571/psv:P571 [ wikibase:timeValue ?inception;
wikibase:timePrecision ?timeprecision ]
# get the label of time precision (by @StanislavKralin)
{
SELECT ?precision (xsd:integer(?precisionDecimal) AS ?timeprecision) {
?precision wdt:P2803 ?precisionDecimal .
}
}
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} LIMIT 1
结果:
+-------------+-----------------+--------+-----------------+-------+----------------+-------------+---------------+
| item | itemLabel | height | unitHeightLabel | width | unitWidthLabel | inception | precisionLabel |
+-------------+-----------------+--------+-----------------+-------+----------------+-------------+---------------+
| wd:Q187483 | Bayeux Tapestry | 0.5 | metre | 68.38 | metre | Jan 1, 1070 | 8 |
+-------------+-----------------+--------+-----------------+-------+----------------+-------------+---------------+
精度代码分别为0:十亿年,1:亿年,3:百万年,4:十万年,5:万年,6:千年,7:世纪,8:十年,9:年,10 :月,11:日,12:小时,13:分钟,14:秒。