You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wikidata LabelService表现不符预期,SPARQL查询标签异常求助

Troubleshooting Your Wikidata SPARQL Query for Queen Victoria's Father

Hey there! Let's break down why your query isn't returning the label you expect for the fatherProperty field—it's not a bug, just a small adjustment needed in how you reference the property in your query.

The Root Issue

Your current query binds wdt:P22 to ?fatherProperty. The wdt: namespace points to direct property IRIs (like the raw URL you saw in results), but the wikibase:label service is built to fetch human-readable labels for property entities, which use the wd: namespace (i.e., wd:P22). When you pass the direct property IRI to the label service, it can't resolve the friendly label and returns the raw URL instead.

The Corrected Query

Adjust your query to bind the property entity (wd:P22) to ?fatherProperty, while still using the direct property (wdt:P22) in the triple pattern to fetch the father relationship. Here's the fixed version:

# WikiData SPARQL Query #
# Wolfgang Fahl 2018-01-06 #
# get father of queen victoria
SELECT ?queenVictoria ?queenVictoriaLabel ?fatherProperty ?fatherPropertyLabel ?father ?fatherLabel
WHERE {
# father
# Queen Victoria
BIND (wd:P22 AS ?fatherProperty).
BIND (wd:Q9439 AS ?queenVictoria).
?queenVictoria wdt:P22 ?father.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

What This Fixes

  • wd:P22 is the official property entity for "father", so the label service will correctly return "father" for ?fatherPropertyLabel.
  • wdt:P22 stays in the triple pattern to ensure we still fetch the correct father-child relationship between Queen Victoria and her father.

Expected Results

After running the corrected query, your output will match your expectations:

queenVictoria | queenVictoriaLabel | fatherProperty | fatherPropertyLabel | father    | fatherLabel
wd:Q9439      | Queen Victoria     | wd:P22         | father              | wd:Q157009| Prince Edward Augustus, Duke of Kent and Strathearn

内容的提问来源于stack exchange,提问作者Wolfgang Fahl

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:51:44