如何获取给定Wikidata ID的语句列表? [英] How to get list of statements for a given Wikidata ID?

查看:155
本文介绍了如何获取给定Wikidata ID的语句列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我唯一要做的就是这个链接:

The only thing I managed to do is this link:

https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q568&format=jsonfm

但这会产生大量无用的数据.我需要获取给定项目的所有语句,但在上面的查询中看不到任何语句.

But this produces lots of useless data. What I need is to get all the statements for the given item, but I can't see any of the statements in the query above.

会在这里:

{ "instance of" : "chemical element",
  "element symbol" : "Li",
  "atomic number" : 3,
  "oxidation state" : 1,
  "subclass of" : ["chemical element", "alkali metal"]
 // etc...
}

是否有用于此的API或我必须抓取网页?

Is there an API for this or must I scrape the web page?

推荐答案

所需信息在查询中,但难以解码.例如,这:

The information you want is in your query, except it's hard to decode. For example, this:

"P246": [
          {
            "id": "q568$E47B8CE7-C91D-484A-9DA4-6153F132997D",
            "mainsnak": {
              "snaktype": "value",
              "property": "P246",
              "datatype": "string",
              "datavalue": {
                "value": "Li",
                "type": "string"
              }
            },
            "type": "statement",
            "rank": "normal",
            "references": …
          }
        ]

表示元素符号"(属性P246 )为李".因此,您需要从查询中读取所有属性,然后为找到的每个属性找出名称.

means that the "element symbol" (property P246) is "Li". So, you will need to read all the properties from your query and then find out the name for each of the properties you found.

仅获取语句,也可以使用action=wbgetclaims,但格式与上面相同.

To get just the statements, you could also use action=wbgetclaims, but it's in the same format as above.

这篇关于如何获取给定Wikidata ID的语句列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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