【问题标题】:Stanfordnlp.download() fails: [Errno -2] Name or service not known'))Stanfordnlp.download() 失败:[Errno -2] Name or service not known'))
【发布时间】:2020-10-18 03:27:32
【问题描述】:

我只是尝试运行 stanfordnlp 自己给出的示例:

>>> import stanfordnlp
>>> stanfordnlp.download('en')   # This downloads the English models for the neural pipeline
>>> nlp = stanfordnlp.Pipeline() # This sets up a default neural pipeline in English
>>> doc = nlp("Barack Obama was born in Hawaii.  He was elected president in 2008.")
>>> doc.sentences[0].print_dependencies()

但是,我无法这样做,收到以下错误:

ConnectionError: HTTPSConnectionPool(host='nlp.stanford.edu', port=443): Max retries exceeded with url: /software/stanfordnlp_models/latest/en_ewt_models.zip (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8f5dba7f10>: Failed to establish a new connection: [Errno -2] Name or service not known'))

为什么会这样?我看到这是一个问题on their github,但他们表示这是由于服务器问题已经解决了。我该如何解决这个错误?谢谢。

【问题讨论】:

    标签: nlp data-science stanford-nlp


    【解决方案1】:

    stanfordnlp 软件包现已弃用。我们将其重命名为 Stanza 以获得最新版本。您应该按照此处的说明进行操作:https://stanfordnlp.github.io/stanza/。按照相应的步骤,刚才对我来说效果很好:

    >>> import stanza
    >>> stanza.download('en') # download English model
    >>> nlp = stanza.Pipeline('en') # initialize English neural pipeline
    >>> doc = nlp("Barack Obama was born in Hawaii.") # run annotation over a sentence
    >>> print(doc.entities)
    

    也就是说,更多细节是:

    • 此错误来自无法从我们的实验室机器下载模型数据文件。他们有时情绪低落。第二天再试一次。立即执行此操作,模型下载成功(如果有点慢)。
    • stanfordnlp 与最新版本的 PyTorch 不兼容。如果您看到错误 RuntimeError: Integer division of tensors using div or / is no longer supported,那么您需要切换到 stanza 或将您的 PyTorch 版本降级到 1.5 或更早版本
    • Stanza 从 GitHub 而不是从我们的实验室机器下载大型模型数据文件,因此 Stanza 模型数据文件下载应该更可靠。但如果您无法访问 GitHub,请参阅 https://stanfordnlp.github.io/stanza/faq.html#getting-requestsexceptionsconnectionerror-when-downloading-models

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-10
      • 2015-09-05
      • 1970-01-01
      • 2014-03-22
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      • 1970-01-01
      相关资源
      最近更新 更多