关于dbpedia的Sparql:World_Wide_Web [英] Sparql about dbpedia:World_Wide_Web

查看:96
本文介绍了关于dbpedia的Sparql:World_Wide_Web的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是语义网的新手,我试图弄清楚如何编写SPARQL查询以从dbpedia中提取有关特定主题的所有信息。不仅是礼节,还有与之相关的一切。

I'm new to the semantic web and I'm trying to figure out how to write a SPARQL query to extract from dbpedia everything about a particular subject. Not just it's proprieties, but also everything related to it.

我什至不知道如何开始这样的查询。

I'm not even sure how to start such a query.

我想获得所有三元组

PREFIX dbpedia: <http://dbpedia.org/resource/>

SELECT DISTINCT ?s ?p ?o 
WHERE  {
  ?s ?p ?o .
  ?s ?p dbpedia:World_Wide_Web  

  #  FILTER( lang(?s) = "en" )   -- doesn't work with filter

}Limit 100

这只会返回带有猫头鹰的三元组:sameAs谓词

This only returns some triples with a owl:sameAs predicate

您能帮我吗?

推荐答案

您可以获得具有的所有三元组dbpedia:World_Wide_Web 作为其主题或对象,并带有这样的查询(当然,这只会提供1000)。对于文字的任何对象,我们可以限制其语言值:

You can get all the triples that have dbpedia:World_Wide_Web as their subject or object with a query like this (this only gives 1000, of course). For any objects that are literals, we can restrict their language value:

select ?s ?p ?o where {
  values ?web { dbpedia:World_Wide_Web }
  { ?web ?p ?o bind( ?web as ?s ) } union
  { ?s ?p ?web bind( ?web as ?o ) }

  # for literal objects, take only English ones
  filter( !isLiteral(?o) || langMatches(lang(?o),'en') )
}
limit 1000

SPARQL结果

这包括如下所示的结果,似乎是一致的加上您在评论中提到的内容:

This includes results like the following, which seems to align with what you mentioned in the comments:

http://dbpedia.org/resource/World_Wide_Web  http://dbpedia.org/property/company  http://dbpedia.org/resource/CERN
http://dbpedia.org/resource/World_Wide_Web  http://dbpedia.org/property/inventor  http://dbpedia.org/resource/Tim_Berners-Lee

这会产生很多结果,所以您可能想限制您可以使用的属性。您应该能够执行以下操作,但是在当前的DBpedia端点上,它将导致错误。

That will produce a lot of results, so you might want to restrict the properties that you can use. You should be able to do the following, but on the current DBpedia endpoint, it causes an error.

select ?s ?p ?o where {
  values ?web { dbpedia:World_Wide_Web }
  values ?p   { rdf:type dbpedia-owl:abstract }

  { ?web ?p ?o bind( ?web as ?s ) } union
  { ?s ?p ?web bind( ?web as ?o ) }
}
limit 1000





Virtuoso 37000 Error SP031: SPARQL compiler: Internal error: sparp_gp_attach_filter_cbk(): attempt to attach a filter with used variable

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 ?s ?p ?o where {
  values ?web { dbpedia:World_Wide_Web }
  values ?p   { rdf:type dbpedia-owl:abstract }

  { ?web ?p ?o bind( ?web as ?s ) } union
  { ?s ?p ?web bind( ?web as ?o ) }
}
limit 1000

作为替代方法,您可以执行以下操作:

Instead, as a workaround, you can do this:

select ?s ?p ?o where {
  values ?web { dbpedia:World_Wide_Web }

  { ?web ?p ?o bind( ?web as ?s ) }
  union
  { ?s ?p ?web bind( ?web as ?o ) }

  filter( ?p in (rdf:type, dbpedia-owl:abstract ))  ###
}
limit 1000

SPARQL结果

这篇关于关于dbpedia的Sparql:World_Wide_Web的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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