我想托管CoreNLP服务器,但用的是无码模型,但我觉得我没有成功,而且官网也没有这种模型的托管实例。
我目前使用的是主机。
java -mx4g \
-cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-port 9000 \
-timeout 15000
但这是默认的托管方式,不使用无码模型。我查看了应用日志,它加载的是标准模型而不是无码模型。
[pool-1-thread-1] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [0.9 sec].
[pool-1-thread-1] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [0.5 sec].
[pool-1-thread-1] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [0.5 sec].
根据... https:/stanfordnlp.github.ioCoreNLPcaseless.html。我已经下载了英文的models jar文件,并把它放在corenlp模块文件夹下,但我不知道到底如何指定和使用这些服务器托管。
在客户端,我做了以下工作。
import requests
r = requests.post('http://[::]:9000/?properties={"annotators":"tokenize,ssplit,truecase,pos,ner","outputFormat":"json"}',
data="show me hotels in toronto for next weekend")
print(r.text)
truecase在工作,但我没有看到无壳模型被使用。
如果有任何帮助,我将不胜感激。
你需要通过属性 "ner.model": "edu/stanford/nlp/models/ner/english.all.3class.caseless.distsim.crf.ser.gz,edu/stanford/nlp/models/ner/english.muc.7class.caseless.distsim.crf.ser.gz,edu/stanford/nlp/models/ner/english.conll.4class.caseless.distsim.crf.ser.gz"
另外,你可能想使用Stanza来访问Stanford CoreNLP服务器。
详情请看这里。https:/stanfordnlp.github.iostanzacorenlp_client.html#overview。