首先安装stanza
conda install -c stanfordnlp stanza
遇到这个问题,肯定安的是stanza=1.2.3,这个版本没有nlp,所以代码改为:
from stanza.server import CoreNLPClient
后面可能遇到
这个问题:AssertionError: Please install CoreNLP by running stanza.install_corenlp()
. If you have installed it, please define $CORENLP_HOME to be location of your CoreNLP distribution or pass in a classpath parameter.
解决方法:先https://stanfordnlp.github.io/CoreNLP/下载CoreNLP,然后解压之后,在控制台中输入:
export CORENLP_HOME=$path:/你存放刚刚文件的path/stanford-corenlp-4.2.2