如何查询特定DBpedia资源/页面的多个实体? [英] How to query a particular DBpedia Resource/Page for multiple entities?

查看:224
本文介绍了如何查询特定DBpedia资源/页面的多个实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多DBpedia页面的链接,例如:

http:// dbpedia .org / resource / Harry_Potter

http:// dbpedia。 org / resource / Twilight_(series)

http://dbpedia.org / resource / Bible

http://dbpedia.org/resource/Manga

I have links to a number of DBpedia pages like:
http://dbpedia.org/resource/Harry_Potter
http://dbpedia.org/resource/Twilight_(series)
http://dbpedia.org/resource/Bible
http://dbpedia.org/resource/Manga

我想为它们中的每一个获取Abstract和Thumbnail实体。

I would like to get the Abstract and Thumbnail entities for each one of them.

我可以使用以下方法分别获取它们:

I can get them individually using:


  • 对于摘要:

  • For Abstract:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX res: <http://dbpedia.org/resource/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label
WHERE { <http://dbpedia.org/resource/Harry_Potter>
          dbo:abstract ?label . FILTER (lang(?label) = \'en\')}


  • 对于缩略图:

  • For Thumbnail:

    PREFIX dbo: <http://dbpedia.org/ontology/>
    PREFIX res: <http://dbpedia.org/resource/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    SELECT ?thumbnail
    WHERE { <http://dbpedia.org/resource/Harry_Potter>
              dbo:thumbnail ?thumbnail}
    


  • 是否可以将以上两个查询合并为一个查询。我对SPARQL非常陌生,无法通过

    Is it possible to combine the above two queries into a single one. I am very new to SPARQL and couldn't get it to work.

    另外,有没有比我目前的方法更好的查询方法?

    Additionally, is there a better way to query than my current approach?

    推荐答案

    当然可以将它们组合在一起,简单的方法就是将两个 WHERE的主体连接起来 s并相应地调整 SELECT

    Of course it's possible to combine them, the trivial way to do it would be just to concatenate the bodies of the two WHEREs and adjust the SELECT accordingly:

    SELECT ?label ?thumbnail
    WHERE {
        <http://dbpedia.org/resource/Harry_Potter> dbo:abstract ?label . 
        FILTER (lang(?label) = 'en')
        <http://dbpedia.org/resource/Harry_Potter> dbo:thumbnail ?thumbnail .
    }
    

    如果您想更简洁,可以将两个三元组与同一个主题使用;

    If you want to be more succinct, you can combine two triples with the same subject using ;:

    SELECT ?label ?thumbnail
    WHERE {
        <http://dbpedia.org/resource/Harry_Potter>
            dbo:abstract ?label ; 
            dbo:thumbnail ?thumbnail .
        FILTER (lang(?label) = 'en')
    }
    

    并且由于定义了 res:前缀,因此可以使用它来缩短URI:

    And since you defined the res: prefix, you can use that to shorten the URI:

    SELECT ?label ?thumbnail
    WHERE {
        res:Harry_Potter
            dbo:abstract ?label ; 
            dbo:thumbnail ?thumbnail .
        FILTER (lang(?label) = 'en')
    }
    

    这篇关于如何查询特定DBpedia资源/页面的多个实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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