如何从文章DBPedia获取维基百科文章的摘要和缩略图? [英] How to get abstract and thumbnail of a Wikipedia article from article DBPedia?

查看:152
本文介绍了如何从文章DBPedia获取维基百科文章的摘要和缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SPARQL的新手。通过此查询,我可以得到欧内斯特·海明威(Ernest Hemingway)的birthName:

I am new to SPARQL. With this query, I can get the birthName of Ernest Hemingway:

select distinct ?birthName
where {
  ?person a dbpedia-owl:Person .
  ?person dbpprop:birthName ?birthName .
  FILTER (regex(?birthName, "Ernest Miller Hemingway"))
} 
LIMIT 1

有没有办法通过DBPedia获得欧内斯特·海明威的维基百科摘要/介绍和缩略图?

Is there a way I can get the wikipedia abstract/introduction and thumbnail of Ernest Hemingway with DBPedia?

推荐答案

通常,如果您已经知道要查找的内容,那么开始查询DBpedia的最佳方法是查看页面中所需的资源。在这种情况下,您需要

In general, the best way to start querying DBpedia if you already have an idea what you're looking for is to look at the page for the resource that you're interested in. In this case, you want

  • http://dbpedia.org/resource/Ernest_Hemingway, which redirects to
  • http://dbpedia.org/page/Ernest_Hemingway

在该页面上,您会看到该属性将资源与其摘要相关联是 dbpedia-owl:abstract ,缩略图或图像是 dbpedia-owl:thumbnail 。因此,您需要类似以下的查询(可以在 DBpedia SPARQL端点上运行)。我已经把结果限制为英语摘要。

On that page, you'll see that the property relating a resource to its abstract is dbpedia-owl:abstract, and the thumbnail or image is dbpedia-owl:thumbnail. Thus, you want a query like the following (which you can run on the DBpedia SPARQL endpoint). I've taken the liberty of restricting the results to just the English language abstract.

prefix dbpedia: <http://dbpedia.org/resource/>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>

select ?abstract ?thumbnail where { 
  dbpedia:Ernest_Hemingway dbpedia-owl:abstract ?abstract ;
                           dbpedia-owl:thumbnail ?thumbnail .
  filter(langMatches(lang(?abstract),"en"))
}

SPARQL结果

这篇关于如何从文章DBPedia获取维基百科文章的摘要和缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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