用stanfordCoreNLP进行中文分词时出现错误json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
最近准备使用stanfordCoreNLP进行中文分词,使用的是最新的coreNLP4.2版本,即使运行简单的下面代码,都会报错
from stanfordcorenlp import StanfordCoreNLP
nlp = StanfordCoreNLP(r'stanfordnlp', lang="zh")
sentence = "清华大学位于北京"
print(nlp.ner(sentence))
报错截图如下所示
经过搜索,发现可能是版本问题,因为python包stanfordcorenlp 3.9.1.1
最新的版本也是3.9,然后还是2018年发布的,所以将coreNLP的版本从最新的4.2换成2018年的3.9版本。
可以在这个地址下载coreNLP的历史版本https://stanfordnlp.github.io/CoreNLP/history.html
,注意要将中文支持包也要下载。