【问题标题】:How to establish connection to use dbpediaSpotlight in python?如何建立连接以在 python 中使用 dbpediaSpotlight?
【发布时间】:2020-08-16 14:49:24
【问题描述】:

我正在 Jupyter Notebook 中编写 python,但是当我运行这段代码时:

import requests
import re
import spotlight

document = 'First documented in the 13th century, Berlin was the capital of the Kingdom of Prussia 
(1701–1918), the German Empire (1871–1918), the Weimar Republic (1919–33) and the Third Reich (1933– 
45). Berlin in the 1920s was the third largest municipality in the world. After World War II, the 
city became divided into East Berlin -- the capital of East Germany -- and West Berlin, a West German 
exclave surrounded by the Berlin Wall from 1961–89. Following German reunification in 1990, the city 
regained its status as the capital of Germany, hosting 147 foreign embassies.'
annotations = spotlight.annotate('http://spotlight.dbpedia.org/rest', document,confidence=0.5, 
support=20)

它显示这个错误,我该如何运行它?

ConnectionError: HTTPSConnectionPool(host='www.dbpedia-spotlight.orgrest', port=443): Max retries 
exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection 
object at 0x000000070169B1C8>: Failed to establish a new connection: [Errno 11001] getaddrinfo 
failed')

谢谢。

【问题讨论】:

    标签: python jupyter-notebook spotlight spotlight-dbpedia


    【解决方案1】:

    尝试使用annotate REST API 的不同地址运行注释器:

    annotations = spotlight.annotate('http://api.dbpedia-spotlight.org/en/annotate', document, confidence=0.5, support=20)

    【讨论】:

      【解决方案2】:

      图书馆有更新,不能再以这种方式查阅。我建议您检查以下post

      这与使用响应的另一种方式实现相同。

      您提到的 SPARQL 查询可以跳过,它可以工作

      我用翻译器,突然出错

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-07-18
        • 1970-01-01
        • 1970-01-01
        • 2021-08-02
        • 2018-01-27
        • 2021-11-18
        • 2012-03-12
        相关资源
        最近更新 更多