如何使用DBpedia查找属于两个给定类别的成员的所有Wikipedia页面? [英] How to find all Wikipedia pages which are members two given categories using DBpedia?

查看:92
本文介绍了如何使用DBpedia查找属于两个给定类别的成员的所有Wikipedia页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几年前,我迷上了 DBpedia 并发现它很有趣,但是现在我想在不使用它多年之后执行查询,所以我完全找到了它

I dabbled with DBpedia a couple of years ago and find it fascinating, but now that I want to perform a query after not using it for ages, I find it totally impenetrable.

我应该发出什么 SPARQL 查询来检索属于这两个

What SPARQL query should I issue to retrieve the set of all Wikipedia pages that are members of both "Category ABC" and "Category XYZ"?

我可以找到的所有示例似乎都比我看似基本的问题要复杂得多,这使得我很难发现

All of the examples I can find seem to be quite a bit more involved than my seemingly basic question, making it difficult to distil something minimal.

(例如,我想找到所有为意大利队踢过职业足球的澳大利亚球员。)

(As an example I'd like to find all Australian players that have played professional football for Italian teams.)

推荐答案

资源和类别之间的链接使用 dcterms:subject 关系表示(如您所见,例如,转到 Elvis Presley )的DBPedia表示。

The link between resources and categories is represented using the dcterms:subject relation (as you can see if you go, for example, to the DBPedia representation for Elvis Presley).

因此要查询所有属于两个类别的来源(例如美国男歌手和同卵双胞胎),只需执行以下操作:

So to query for all resources that belong to two categories (e.g. "American male singers" and "identical twins"), simply do this:

SELECT ?res    
WHERE { 
 ?res dcterms:subject category:American_male_singers, category:Identical_twins .
} 

通常,当尝试通过DBPedia制定SPARQL查询时,它有助于浏览首先大约要花一点时间(就像我通过查看Elvis页面所做的那样),尝试找出可用的属性和关系。

In general, when trying to formulate SPARQL queries over DBPedia, it helps to browse around a bit first (like I did by looking at the Elvis page), to try and figure out which properties and relations are available.

顺便说一下,上述查询本身是检索DBPedia资源的。如果要获取实际的Wikipedia页面,则应像这样修改查询:

Edit The above query, by the way, retrieves the DBPedia resources themselves. If you want to get the actual Wikipedia pages, you should adapt your query like so:

SELECT ?wikiPage   
WHERE { 
 ?res dcterms:subject category:American_male_singers, category:Identical_twins ;
      foaf:page ?wikiPage .
} 

这篇关于如何使用DBpedia查找属于两个给定类别的成员的所有Wikipedia页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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