【问题标题】:DBPedia SPARQL query should return results but is emptyDBPedia SPARQL 查询应返回结果但为空
【发布时间】:2012-01-21 13:37:42
【问题描述】:

我想获取所有具有指定类别和指定键的页面。我的查询:

PREFIX dbpedia: <http://dbpedia.org/>
PREFIX dbpedia2: <http://dbpedia.org/property/> 
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://dublincore.org/2010/10/11/dcterms.rdf#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX grs: <http://www.georss.org/georss/point>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?page ?cat ?key ?value (lang(?value) as ?language) WHERE {

  ?page dcterms:subject ?cat .
  ?page ?key ?value .

  FILTER(
    regex(?cat, "category:Amusement_parks_in_the_Netherlands") &&
    ?key = foaf:depiction
  )

}

但它返回零结果。见这里:SNORQL query

它至少应该返回这个页面:http://dbpedia.org/page/Duinrell(因为它符合条件)。

有什么想法吗?

【问题讨论】:

    标签: sparql dbpedia


    【解决方案1】:

    您的查询存在一些问题。首先,在比较 URI 时不要使用正则表达式。而不是:

    regex(?cat, "category:Amusement_parks_in_the_Netherlands")
    

    使用:

    ?cat = <http://dbpedia.org/resource/category:Amusement_parks_in_the_Netherlands>
    

    第二:都柏林核心的命名空间前缀似乎是错误的。您正在查询属性dcterms:subject,并且在您的查询中,前缀dcterms 映射到命名空间http://dublincore.org/2010/10/11/dcterms.rdf#。但是,DBPedia 中的实际属性是 http://purl.org/dc/terms/subject,因此您的命名空间前缀应该映射到 http://purl.org/dc/terms/

    【讨论】:

    • 谢谢。当 ?cat 有多个值时, ?cat = ... 表达式是否也有效?每个页面可以有多个类别。
    • @Alp,是的,查询模式将匹配至少有一个类别具有该特定值的任何页面。
    猜你喜欢
    • 2021-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多