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

DBPedia SPARQL查询仅返回表头无结果问题求助

Troubleshooting Your DBPedia SPARQL Query

Got it, let's figure out why your SPARQL query is returning only headers with no results on DBpedia. Here are the key issues and fixes to get it working:

1. Duplicate Triple & Exact String Matching Problem

You’ve repeated the ?disease rdfs:label ?diseasename triple twice—this is redundant, but the real blocker is your exact string filter. DBpedia’s disease labels typically use title case (like "Brain Tumor"@en) instead of the lowercase "t" in your "Brain tumor" filter. This strict exact match won’t align with the actual data stored in the dataset, hence no results.

2. Fixes to Try

Option 1: Match the Exact Title-Cased Label

Update your filter to match DBpedia’s standard label formatting:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?diseasename ?personname 
WHERE { 
  ?disease a dbo:Disease . 
  ?person dbo:deathCause ?disease . 
  ?person rdfs:label ?personname FILTER (lang(?personname) = "en"). 
  ?disease rdfs:label ?diseasename FILTER (lang(?diseasename) = "en" && ?diseasename = "Brain Tumor") 
}

Option 2: Case-Insensitive Matching (More Flexible)

If you want to avoid worrying about capitalization, use a regex filter with the case-insensitive flag:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?diseasename ?personname 
WHERE { 
  ?disease a dbo:Disease . 
  ?person dbo:deathCause ?disease . 
  ?person rdfs:label ?personname FILTER (lang(?personname) = "en"). 
  ?disease rdfs:label ?diseasename FILTER (lang(?diseasename) = "en" && regex(?diseasename, "^brain tumor$", "i")) 
}

3. Quick Sanity Check

Before running the full query, confirm the disease exists in DBpedia with a simpler test:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?disease ?diseasename
WHERE {
  ?disease a dbo:Disease .
  ?disease rdfs:label ?diseasename FILTER (lang(?diseasename) = "en" && regex(?diseasename, "brain tumor", "i"))
}

This will verify that DBpedia has entries for the disease you’re targeting, which is a good pre-check before adding the person/death cause logic.

内容的提问来源于stack exchange,提问作者Rita Isabel Torres De Sousa

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:30:14