【问题标题】:Sparql to recover the Type of a DBpedia resourceSparql 恢复 DBpedia 资源的类型
【发布时间】:2014-03-19 14:05:26
【问题描述】:

我需要一个 Sparql 查询来恢复特定 DBpedia 资源的类型。例如:

pt.DBpedia 资源:http://pt.dbpedia.org/resource/Argentina

预期类型:国家(可以在http://pt.dbpedia.org/page/Argentina 看到)

使用 pt.DBpedia Sparql Virtuoso Interface (http://pt.dbpedia.org/sparql) 我有以下查询:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select ?l ?t where {
 ?l rdfs:label "Argentina"@pt .
 ?l rdf:type ?t .
}

但它没有恢复任何东西,只是打印变量名。 The virtuoso answer.

其实我也不需要恢复标签(?l)。

谁能修复它,或者帮我定义正确的查询?

【问题讨论】:

  • 您是如何构建查询 URL 的?出于某种原因,您将default-graph-uri 设置为pt.dbpedia.org/ 而不是http://pt.dbpedia.org

标签: sparql dbpedia


【解决方案1】:

http 在图形名称中

我不确定您是如何生成查询字符串的,但是当我将您的查询复制并粘贴到端点并运行它时,我得到了结果,生成的 URL 如下所示:

http://pt.dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fpt.dbpedia.org&sho...

但是,您问题中的链接是:

http://pt.dbpedia.org/sparql?default-graph-uri=pt.dbpedia.org%2F&should-sponge...

如果你仔细看,你会发现default-graph-uri参数是不同的:

yours: pt.dbpedia.org%2F
mine:  http%3A%2F%2Fpt.dbpedia.org

我不确定您是如何获得与您一样的 URL,但它不正确; default-graph-urineeds to be http://pt.dbpedia.org,而不是pt.dbpedia.org/

查询没问题

当我在您链接到的端点上运行您提供的查询时,我得到了我期望的结果。值得注意的是,这里的标签是文字"Argentina"@pt,而您所说的?l 是个人,而不是标签。个人?l标签"Argentina"@pt

我们可以稍微简化您的查询,使用?i 而不是?l(建议individual):

select ?i ?type where {
  ?i rdfs:label "Argentina"@pt ;
     a ?type .
}

当我在 Portuguese endpoint 运行此程序时,我得到了以下结果:

如果您不希望个人出现在结果中,则不必select它:

select ?type where {
  ?i rdfs:label "Argentina"@pt ;
     a ?type .
}

甚至:

select ?type where {
  [ rdfs:label "Argentina"@pt ; a ?type ]
}

如果你知道资源的标识符,并且不需要使用它的标签来检索它,你甚至可以这样做:

select ?type where {
  dbpedia-pt:Argentina a ?type
}
type
==========================================
http://www.w3.org/2002/07/owl#Thing
http://www.opengis.net/gml/_Feature
http://dbpedia.org/ontology/Place
http://dbpedia.org/ontology/PopulatedPlace
http://dbpedia.org/ontology/Country
http://schema.org/Place
http://schema.org/Country

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多