DBpedia Sparql按页面模板 [英] DBpedia Sparql by page template

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

问题描述

我正在尝试使用SPARQL语法在dbpedia上运行查询,以查找特定模板的所有页面。似乎没有用,我正在寻找所有带有dbpprop:wikiPageUsesTemplate的页面。有人知道如何纠正此错误以正确查找模板吗?

I am trying to run a query on dbpedia using SPARQL syntax, to look for all pages of a certain template. Doesn't seem to be work, I am looking for all pages with dbpprop:wikiPageUsesTemplate. Does anyone know how to correct this to properly look for templates?

SELECT ?name ?member_Of ?country ?lat ?lng ?link
WHERE {
?x dbpprop:wikiPageUsesTemplate "dbpedia:Template:Infobox_settlement" .
?x a <http://dbpedia.org/ontology/Settlement> .
?x foaf:name ?name .
?x dbpedia-owl:isPartOf ?member_Of.
?x dbpedia-owl:country ?country.
?x geo:lat ?lat .
?x geo:long ?lng .
?x foaf:isPrimaryTopicOf ?link .
}
LIMIT 2500 OFFSET 0

我也尝试运行它

SELECT * WHERE {  ?page dbpprop:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_settlement> .  ?page dbpedia:name ?name .}

如果有人试图做类似的事情,那就是也可以通过Wiki api进行操作,您可以在其中对所有结果进行pagananate。 http://en.wikipedia.org /w/api.php?action=query&list=embeddedin&eititle=Template:Infobox_settlement

If anyone is trying to do a similar thing, it is also possible via the wiki api, where you can pagananate over all results. http://en.wikipedia.org/w/api.php?action=query&list=embeddedin&eititle=Template:Infobox_settlement

推荐答案

有至少有两个问题:(i)您需要在地方使用IRI,而不是字符串;并且(ii)您需要使用DBpedia使用的属性。

There are at least two problems: (i) you need to use IRIs in places, and not strings; and (ii) you need to use properties that DBpedia uses.

?x a <http://dbpedia.org/ontology/Settlement> .

?x foaf:isPrimaryTopicOf ?link .

您已经证明您知道URI必须用< 和> ,或带前缀的缩写。但是,

you've demonstrated that you know that URIs need to be written in full with < and >, or abbreviated with a prefix. However,

?x dbpprop:wikiPageUsesTemplate "dbpedia:Template:Infobox_settlement" .

肯定无法正常工作。这是合法的SPARQL,因为字符串可以是三元组的对象,但是您几乎可以肯定需要IRI。

certainly isn't going to work. It's legal SPARQL, because a string can be the object of a triple, but you almost certainly want an IRI.

使用 dbpprop:wikiPageUsesTemplate 的查询不会返回任何结果:

A query with dbpprop:wikiPageUsesTemplate like this returns no results:

select distinct ?template where {
 [] dbpprop:wikiPageUsesTemplate ?template
}

SPARQL结果

这很容易检查,并迅速确认没有数据可能匹配您的查询。您在哪里找到此物业?您看到它在某处使用过吗?我不确定您是否可以基于信息框模板查询DBpedia。 DBpedia与Wikipedia并不相同,即使Wikipedia API支持它,也不意味着DBpedia具有对应的版本。在 DBpedia数据集属性上有一个注释: / p>

That's easy enough to check, and quickly confirms that there's no data that can possibly match your query. Where did you find this property? Have you seen it used somewhere? I'm not confident that you can query DBpedia based on infobox templates. DBpedia is not the same as Wikipedia, and even if the Wikipedia API supports it, it doesn't mean that DBpedia has a counterpart. There is a note on DBpedia Data Set Properties that says:


http://xx.dbpedia.org/property/wikiPageUsesTemplate(将更改为http://dbpedia.org/ontology/wikiPageUsesTemplate )

http://xx.dbpedia.org/property/wikiPageUsesTemplate (will be changed to http://dbpedia.org/ontology/wikiPageUsesTemplate)

,但后者的属性似乎也未在端点上使用。请参阅语法的我的答案。 Sparql查询具有特定信息框的页面以获取更多详细信息。

but that latter property doesn't seem to be in use on the endpoints either. See my answer to Syntax for Sparql query for pages with specific infobox for more details.

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

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