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

获取DBpedia无重复单曲的relYear/released字段及Billboard单曲查询

解决DBpedia单曲数据查询的两个需求

Hey there! Let's break down how to address your two requirements for querying DBpedia's single data:

需求1:获取无重复的单曲发行年份(relYear/released)

The core goal here is to pull either the relYear or released field from DBpedia's single records, with strict no-duplicate results. Key points to note:

  • DBpedia stores release year info in two separate property fields: prop:relyear and prop:released
  • Using DISTINCT is essential to eliminate duplicate entries
  • We'll use OPTIONAL clauses to capture both fields without excluding records that only have one of them

需求2:优化Billboard Hot 100冠军单曲查询

You shared a SPARQL query for fetching Billboard Hot 100 number-one singles, and we can tweak it to align with the no-duplicate requirement while properly capturing release year data. Here's the refined query:

PREFIX prop: <http://dbpedia.org/property/>
PREFIX ont: <http://dbpedia.org/ontology/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dbc: <http://dbpedia.org/resource/Category:>

SELECT DISTINCT ?page ?artist ?releaseYear ?runTime
WHERE {
  ?page dct:subject dbc:Billboard_Hot_100_number-one_singles .
  # Fetch artist info if available
  OPTIONAL { ?page prop:artist ?artist }
  # Unify release year into a single field (covers both relYear and released)
  OPTIONAL { ?page prop:released ?releaseYear }
  OPTIONAL { 
    ?page prop:relyear ?relyearVal .
    BIND(?relyearVal AS ?releaseYear)
  }
  # Get runtime if the data exists
  OPTIONAL { ?page ont:runtime ?runTime }
}

What this query does better:

  • No duplicates: The DISTINCT keyword ensures every returned row is a unique single entry
  • Unified release year: Instead of having two separate columns for relYear and released, we map both into a single releaseYear field for cleaner results
  • Robust data capture: OPTIONAL clauses mean we won't drop records that lack artist, release year, or runtime info—we'll just return whatever data is available for each single

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 07:33:43