从维基百科/ wikidata /链接数据中获取消除歧义的同义词列表

Moo*_*per 6 api wikipedia-api linked-data wikidata-api

如果我"George Bush"在维基百科上手动搜索,我会得到这个页面,其中列出了带有简短描述的同音异义词.

我想将我的搜索提供给api并获取以下信息:

  • 乔治HW布什
  • 乔治W.布什
  • 乔治布什(圣经学者)
  • 乔治布什(足球运动员)
  • 乔治布什(赛车手)
  • 乔治P.布什
  • 乔治华盛顿布什

只要我可以毫不含糊地解析它,我不介意获得更多.

我的目标是让一个网站的用户能够标记一个公共人物,但我想限制他们的选择并避免含糊不清,所以这个列表可能略有不同,任何其他具有api的体面数据库都可以.

我还没有弄清楚如何用维基百科或wikidata来做,我只是设法在我知道它的情况下对特定的id /页面进行查询,这不是这里的情况.

Ter*_*den 2

有几种方法可以做到这一点,具体取决于您想要什么类型的数据。

例如 - https://en.wikipedia.org/w/api.php?action=query&titles=George%20Bush&prop=links - 会告诉您该人的名字是否有“消歧义”。

这将返回:

               {
                    "ns": 0,
                    "title": "Bush family"
                },
                {
                    "ns": 0,
                    "title": "George Brush (disambiguation)"
                },
                {
                    "ns": 0,
                    "title": "George Bush (biblical scholar)"
                },
                {
                    "ns": 0,
                    "title": "George Bush (footballer)"
                },
                {
                    "ns": 0,
                    "title": "George Bush (racing driver)"
                },
                {
                    "ns": 0,
                    "title": "George H. W. Bush"
                },
                {
                    "ns": 0,
                    "title": "George P. Bush"
                },
                {
                    "ns": 0,
                    "title": "George W. Bush"
                },
                {
                    "ns": 0,
                    "title": "George Washington Bush"
Run Code Online (Sandbox Code Playgroud)

您可以使用 - https://en.wikipedia.org/w/api.php?action=query&utf8=&list=search&srsearch=George%20Bush立即获取更多数据

这会让你:

    "search": [
        {
            "ns": 0,
            "title": "George W. Bush",
            "pageid": 3414021,
            "size": 299185,
            "wordcount": 27007,
            "snippet": "<span class=\"searchmatch\">George</span> Walker <span class=\"searchmatch\">Bush</span> (born July 6, 1946) is an American politician who served as the 43rd President of the United States from 2001 to 2009. He had previously",
            "timestamp": "2018-09-26T21:48:08Z"
        },
        {
            "ns": 0,
            "title": "George H. W. Bush",
            "pageid": 11955,
            "size": 210189,
            "wordcount": 20867,
            "snippet": "<span class=\"searchmatch\">George</span> Herbert Walker <span class=\"searchmatch\">Bush</span> (born June 12, 1924) is an American politician who served as the 41st President of the United States from 1989 to 1993. Prior",
            "timestamp": "2018-10-01T06:41:50Z"
        },
Run Code Online (Sandbox Code Playgroud)