查询DBpedia以获取书籍的元数据 [英] Query DBpedia to get meta-data for Books

查看:157
本文介绍了查询DBpedia以获取书籍的元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆ISBN。我想查询 DBpedia 并获取书籍的元数据。



我无法理解 SPARQL



有人可以告诉我如何从 Java中的DBpedia ?

解决方案

SPARQL既是查询语言,也是查询以下内容的协议:称为 SPARQL端点。 ,及其(或它们)关联的属性和值是这样的:

 选择不同的?book?prop?obj 
其中{
?预订dbo:Book。
?book?prop?obj。
?book dbp:isbn?isbn。
FILTER(regex(?isbn, 0-553-05250-0))
}
LIMIT 100

在浏览器中查看查询结果



请注意, regex(?isbn, 0-553-05250 -0)需要花费一些时间进行评估。它可能不适用于所有ISBN,因为




  • 维基百科可能永远不会包含完整的ISBN列表,因此DBpedia都不会拥有
  • 没有破折号的相同ISBN将与带有破折号的查询不匹配。



此外,我注意到,某些ISBN只是一串数字和破折号,而其他ISBN则包含 ISBN或



您可以将此查询发送到 DBpedia端点(通过浏览器访问该端点),通过 Jena 知名的Java工具包用于RDF和SPARQL。

这是一些Java代码中的查询,用于查询DBpedia以获取结果并将其打印到命令行(基于另一个 Jena,SPARQL和DBpedia相关问题,其中有很多):

  String sparqlQueryString1 =选择不同的?book?prop?obj + 
其中{ +
?预定dbpedia-owl:书。 +
???prop?obj。 +
?dbpprop:isbn?isbn书。 +
过滤器(regex(?isbn,\ 0-553-05250-0\)) +
} +
LIMIT 100;

查询查询= QueryFactory.create(sparqlQueryString1);
QueryExecution qexec = QueryExecutionFactory.sparqlService( http://dbpedia.org/sparql,查询);

ResultSet结果= qexec.execSelect();
ResultSetFormatter.out(System.out,结果,查询);

qexec.close();

我最喜欢的SPARQL资源是李·费根鲍姆(Lee Feigenbaum)的备忘单,这是一个非常全面的参考。也许您想看看教程耶拿(Jena)提供了其文档。


I have a bunch of ISBN's. I want to query DBpedia and get the meta-data of the books.

I am unable to understand the SPARQL.

Can someone tell me how can I get the meta-data of a book from DBpedia in Java?

解决方案

SPARQL is both a query language and a protocol to query so-called SPARQL endpoints.

A SPARQL query that asks DBpedia for a book (or books) that have the ISBN 0-553-05250-0, and its (or their) associated properties and values is this:

select distinct ?book ?prop ?obj 
where {
  ?book a dbo:Book .
  ?book ?prop ?obj .
  ?book dbp:isbn ?isbn .
  FILTER (regex(?isbn, "0-553-05250-0"))
} 
LIMIT 100

See the result of the query in your browser here.

Be aware that regex(?isbn, "0-553-05250-0") takes some time to evaluate. It may not work for all ISBNs, because

  • Wikipedia may never have a complete list of ISBNs, so neither may DBpedia
  • the same ISBN without dashes will not match a query with dashes.

Also, I noticed that some ISBNs are just a string of digits and dashes, others have "ISBN" in it or "(paperback)" appended.

You can send this query to the DBpedia endpoint via the webform (by visiting the endpoint with your browser) via Jena, a well-known Java toolkit for RDF and SPARQL.
Here is the query in some Java code that queries DBpedia for results and prints them to the command line (based on another Jena, SPARQL and DBpedia related question, of which there are many):

String sparqlQueryString1= "select distinct ?book ?prop ?obj " +
       "where { " +
       "  ?book a dbpedia-owl:Book . " +
       "  ?book ?prop ?obj . " +
       "  ?book dbpprop:isbn ?isbn . " +
       "  FILTER (regex(?isbn, \"0-553-05250-0\")) " +
       "} " +
       "LIMIT 100";

Query query = QueryFactory.create(sparqlQueryString1);
QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);

ResultSet results = qexec.execSelect();
ResultSetFormatter.out(System.out, results, query);       

qexec.close() ;

My favourite SPARQL resource is Lee Feigenbaum's cheat sheet, which is a pretty comprehensive reference. Perhaps you would like to check out the tutorials Jena provides with its documentation.

这篇关于查询DBpedia以获取书籍的元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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