我尝试通过NLTK使用Stanford解析器,遵循示例here。在
我遵循示例的前两行(带有必要的导入)
from nltk.parse.corenlp import CoreNLPDependencyParser
dep_parser = CoreNLPDependencyParser(url='http://localhost:9000')
parse, = dep_parser.raw_parse('The quick brown fox jumps over the lazy dog.')
但我有个错误说:
^{pr2}$我意识到,试图连接到作为构造函数输入的url肯定是个问题。在
dep_parser = CoreNLPDependencyParser(url='http://localhost:9000')
如果不是这个,我应该连接到哪个url?如果这是正确的,问题是什么?在
您需要首先在
localhost:9000
上下载并运行CoreNLP服务器。在1)下载CoreNLP,网址:https://stanfordnlp.github.io/CoreNLP/download.html
2) 将文件解压缩到某个目录,然后在该目录下运行以下命令以启动服务器
参考号:https://stanfordnlp.github.io/CoreNLP/corenlp-server.html
上面代码的结果是
^{pr2}$也可以通过nltkapi启动服务器(需要先配置
CORENLP_HOME
环境变量)相关问题 更多 >
编程相关推荐