0

我在 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')

谢谢你。

4

2 回答 2

0

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

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

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

我用翻译器,突然有些错误

于 2021-03-20T15:24:56.520 回答
0

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

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

于 2020-05-08T15:16:56.397 回答