停止StanfordCoreNLP从连接到StanfordCoreNLP服务器

问题描述 投票:0回答:1

[每当我为解析任务创建StanfordCoreNLP时,

StanfordCoreNLP('stanford-corenlp-full-2020-04-20', lang='en')

我得到此日志记录

Initializing native server...
java -Xmx4g -cp "/stanford-corenlp-full-2020-04-20/*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9032
Server shell PID: 11991
The server is available.
  1. StanfordCoreNLP可以在不连接服务器的情况下离线运行python吗?
  2. 在stanfordCoreNLP中是否有命令停止登录到屏幕?申请中

[在使用解析器self.nlp_src.parse(sentence)时,我得到了下面形式的另一个日志:

{'properties': "{'annotators': 'pos,parse', 'outputFormat': 'json'}", 'pipelineLanguage': 'en'}

  1. 也有办法停止上述记录吗?

最后,如上所述,我在stanford coreNLP中使用解析器的过程中遇到了此错误。

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=9032): Max retries exceeded with url: /?properties=%7B%27annotators%27%3A+%27pos%2Cparse%27%2C+%27outputFormat%27%3A+%27json%27%7D&pipelineLanguage=en (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe04121d6d0>: Failed to establish a new connection: [Errno 111] Connection refused'))

  1. 此错误的原因是什么?我该怎么做才能防止这种情况?
python nltk stanford-nlp
1个回答
0
投票

[嗨,如果您想在Python中使用Stanford CoreNLP,我建议您使用我们的官方Python软件包Stanza,可在此处找到:https://stanfordnlp.github.io/stanza/

如果要使用Python访问Stanford CoreNLP,Stanza将需要在本地计算机上启动Java服务器进程。这不需要连接到Internet或任何外部网络。 Java服务器进程正在您的本地计算机上运行,​​而Python进程正在与其通信。

这里有关于如何使用Python启动Java服务器的详细文章:https://stanfordnlp.github.io/stanza/corenlp_client.html#overview

Stanza本身具有词性,依赖关系解析和命名实体识别,这完全是原生Python,并且不涉及任何类型的服务器。此处有更多详细信息:https://stanfordnlp.github.io/stanza/installation_usage.html

© www.soinside.com 2019 - 2024. All rights reserved.