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

SPARQL新手求教:如何查询Wikibase中语句的限定符信息?

解决SPARQL查询Wikibase限定符的问题

要获取公共资金(P92)附带的限定符(资金子部分P62),你需要调整查询结构——直接属性(epfowdt:*)会跳过statement层级,而限定符是绑定在statement节点上的元数据,必须通过statement节点才能访问。

修改后的完整查询

PREFIX epfowd: <https://wikibase.epfo.eu/entity/>
PREFIX epfowdt: <https://wikibase.epfo.eu/prop/direct/>
PREFIX epfop: <https://wikibase.epfo.eu/prop/>
PREFIX epfops: <https://wikibase.epfo.eu/prop/statement/>
PREFIX epfopq: <https://wikibase.epfo.eu/prop/qualifier/>

SELECT ?itemLabel ?publicfunding ?mepfunding ?mepfundingLabel
WHERE {  
  # 筛选政党实体
  ?item epfowdt:P9 epfowd:Q2 ;
        # 关联到P92对应的statement节点
        epfop:P92 ?statement .
  
  # 从statement节点提取公共资金金额
  ?statement epfops:P92 ?publicfunding ;
             # 从同一个statement节点提取P62限定符的值
             epfopq:P62 ?mepfunding .

  # 获取多语言可读标签
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". } 
}
ORDER BY ?itemLabel

关键修改说明

  • 引入statement节点:用epfop:P92 ?statement替代原查询的epfowdt:P92 ?publicfunding,先获取属性对应的statement节点,这是访问限定符的前提
  • 拆分主值与限定符:通过epfops:P92获取公共资金的实际数值,通过epfopq:P62获取绑定在该statement上的限定符内容
  • 可选优化:如果需要?mepfunding的可读标签,只需在SELECT子句和标签服务中添加?mepfundingLabel即可

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 20:27:04