Linux安装Stanford-CoreNLP

一、首先需要安装java8

brew cask install java

安装成功后用命令”java -version”可查看版本信息

二、下载Stanford coreNLP 包

1、下载https://stanfordnlp.github.io/CoreNLP/的CoreNLP 3.9.2以及模型jar包,包括英文和中文模型jar包。

Linux安装Stanford-CoreNLP

或如下地址:

Stanford coreNLP 包:http://nlp.stanford.edu/software/stanford-corenlp-full-2018-10-05.zip

中文的模型jar文件(放到stanford-corenlp-full-2018-02-27根目录下):http://nlp.stanford.edu/software/stanford-chinese-corenlp-2018-02-27-models.jar

2、进入解压缩的目录,并设置类路径

for file in `find . -name "*.jar"`; do export

CLASSPATH="$CLASSPATH:`realpath $file`"; done

若经常使用,则需在~/.bash_profile等环境变量文件中设置(需要将目录替换为相应路径)

for file in `find /path/to/corenlp/ -name "*.jar"`; do export

CLASSPATH="$CLASSPATH:`realpath $file`"; done

三、生成文本文件并运行CoreNLP

echo "the quick brown fox jumped over the lazy dog" > input.txt

java -mx3g edu.stanford.nlp.pipeline.StanfordCoreNLP -outputFormat json -file input.txt

参考:https://stanfordnlp.github.io/CoreNLP/download.html