检索重定向资源的属性 [英] Retrieving properties of redirected resource

查看:86
本文介绍了检索重定向资源的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取 http://dbpedia.org/resource/Milano 的所有属性?我尝试使用此查询,但结果有几个,但我不明白原因:

How can I retrieve all the properties of http://dbpedia.org/resource/Milano? I tried with this query but I have a few results and I don't understand the reason:

select ?prop ?c 
where {<http://dbpedia.org/resource/Milano> ?prop ?c.}

SPARQL结果

推荐答案

这个问题尚不完全清楚,但是希望您要问的问题是为什么您对 dbpedia:Milano ,但不是 dbpedia:Milan 。正如您在结果中看到的那样,该查询仅返回十行:

The question isn't entirely clear, but expect that the problem you're asking about is why you're getting triples about dbpedia:Milano, but not dbpedia:Milan. This query, as you can see in the results, only returns ten rows:

select ?prop ?c
where {
  <http://dbpedia.org/resource/Milano> ?prop ?c.
}

SPARQL结果

但是其中的一行是

prop                                          c
http://dbpedia.org/ontology/wikiPageRedirects http://dbpedia.org/resource/Milan

因此,简单的答案是查询米兰,查询如下:

So, the simple answer is "query for Milan" with a query like this:

select ?prop ?c
where {
  <http://dbpedia.org/resource/Milan> ?prop ?c.  # you can use dbpedia:Milan, too
}

SPARQL结果

一个更复杂的答案将返回 dbpedia:Milano 它重定向到的所有内容的三倍(而且,我想是那些重定向到的任何东西,依此类推,尽管我认为Wikipedia将重定向限制为一个深度)。您可以在SPARQL中使用属性路径查询来做到这一点:

A more sophisticated answer would return the triples for dbpedia:Milano and any triples of anything that it redirects to (and, I suppose, anything that any of those redirect to, and so on, though I think that Wikipedia limits redirects to be one level deep). You can do this with a property path query in SPARQL:

select ?prop ?c
where {
  dbpedia:Milano dbpedia-owl:wikiPageRedirects* ?subject .
  ?subject ?prop ?c.
}

SPARQL结果

在该查询中,?subject 将与以下内容相关:长度为零或更大(因此,鉴于我们已经看到的数据,?主题将至少绑定到 dbpedia:Milano dbpedia:Milan 。如果要保留有关所使用的三元组主题的信息,则可能要添加?subject select 行,以便使 select?subject?prop?c

In that query ?subject will be anything related by a path of length zero or more (so, given the data that we've seen, ?subject will be bound to at least dbpedia:Milano and dbpedia:Milan. If you want to preserve information about the subject of the various triples that you're using, you might want to add ?subject to the select line, so as to have select ?subject ?prop ?c.

如果您不在乎?subject 的特定值,那么您实际上不无需绑定?subject ,并且可以在查询中使用空白节点:

If you don't care about the particular value of ?subject, then you actually don't need to bind ?subject at all, and could use a blank node in the query:

select ?prop ?c
where {
  dbpedia:Milano dbpedia-owl:wikiPageRedirects* [ ?prop ?c ] .
}

SPARQL结果

不幸的是,尽管最后一个查询是合法的SPARQL,但Virtuoso表示这是一个错误。幸运的是,这最后的改进完全是可选的。这对解决方案并不重要。如果您要查询其他端点,则可以使用它。 Virtuoso给出的错误是:

Unfortunately, although this last query is legal SPARQL, Virtuoso says it's an error. Fortunately, this last refinement is entirely optional; it's not vital to the solution. If you were querying against a different endpoint, you'd be able to use it. The error that Virtuoso gives is:

Virtuoso 37000 Error SP031: SPARQL compiler: Object of transitive triple pattern should be variable or QName or literal, not blank node

SPARQL query:
define sql:big-data-const 0 
#output-format:text/html
define sql:signal-void-variables 1 define input:default-graph-uri <http://dbpedia.org> select ?prop ?c
where {
  dbpedia:Milano dbpedia-owl:wikiPageRedirects* [ ?prop ?c ] .
}

我联系了Virtuoso邮件列表,他们确认这是一个Virtuoso错误,并且他们会修复它。不过,我不知道该修复程序要花多长时间才能到达DBpedia端点。

I contacted the Virtuoso mailing list and they confirmed that it's a Virtuoso bug, and that they'll fix it. I don't know how long it will take for the fix to get to the DBpedia endpoint, though.

这篇关于检索重定向资源的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆