尝试运行stanfordnlp的corenlp演示脚本时发生TypeError

2024-06-06 08:56:50 发布

您现在位置:Python中文网/ 问答频道 /正文

ds公司

from stanfordnlp.server import CoreNLPClient
import os
os.environ["CORENLP_HOME"] = r'C:\Users\Shreyans\Downloads\stanford-ner-2018-10-16\stanford-ner-2018-10-16'

text = "Chris Manning is a nice person. Chris wrote a simple sentence. He also gives oranges to people."

client = CoreNLPClient(annotators=['tokenize','ssplit','pos','lemma','ner','depparse','coref'], timeout=30000, memory='8G')

最后一行给出以下错误:

  File "<ipython-input-16-f102b031b1bd>", line 18, in <module>
    client = CoreNLPClient(annotators=['tokenize','ssplit','pos','lemma','ner','depparse','coref'], timeout=30000, memory='8G')

  File "C:\Users\Shreyans\Anaconda3\lib\site-packages\stanfordnlp\server\client.py", line 164, in __init__
    super(CoreNLPClient, self).__init__(start_cmd, stop_cmd, endpoint,

TypeError: super(type, obj): obj must be an instance or subtype of type

有人知道是什么导致这个问题吗


Tags: posimportclientserverosuserschristokenize
1条回答
网友
1楼 · 发布于 2024-06-06 08:56:50

您应该使用完整分发版重试。在示例代码中,您只是使用了NER分布

这里提供完整的分发:

https://stanfordnlp.github.io/CoreNLP/

您还可能需要使用不同版本的Python。如果升级Python版本,可能会解决这个问题

相关问题 更多 >