1、安装sner
pip install sner
2、下载stanford-ner-2017-06-09.zip
3、解压后,在此目录下后台执行
java -Djava.ext.dirs=./lib -cp stanford-ner.jar edu.stanford.nlp.ie.NERServer -port 9199 -loadClassifier ./classifiers/english.all.3class.distsim.crf.ser.gz &
这里模型也可以换成english.conll.4class.distsim.crf.ser.gz或english.muc.7class.distsim.crf.ser.gz
4、测试并运行
from sner import Ner
test_string = "Alice went to the Museum of Natural History."
tagger = Ner(host='localhost',port=9199)
print(tagger.get_entities(test_string))