我下载了fresh version of Stanford Core NLP,并下载了latest parser model for Spanish stanford-spanish-corenlp-2018-10-05-models.jar
。
然后我运行以下代码:
from nltk.parse.corenlp import CoreNLPParser
Parser = CoreNLPParser(url='http://localhost:9000')
sentence = 'si idioma no es elegido entonces elegir español por defecto.'
result = Parser.raw_parse(sentence)
for item in result:
print(item)
使用新的西班牙模式会产生以下 :
(ROOT
(sentence
(sn
(grup.nom
(SCONJ si)
(NOUN idioma)
(NOUN no)
(AUX es)
(VERB elegido)
(ADV entonces)
(VERB elegir)
(ADJ español)
(ADP por)
(NOUN defecto)))
(PUNCT .)))
但是,当我将新的解析器模型替换为较旧的解析器模型(stanford-spanish-corenlp-2017-06-09-models.jar
)时,输出结果会使用旧的西班牙模型不同:
ROOT
(sentence
(S
(S
(conj (cs si))
(sn (grup.nom (nc0s000 idioma)))
(neg (rn no))
(grup.verb (vsip000 es)))
(S (participi (aq0000 elegido))))
(S
(sadv (grup.adv (rg entonces)))
(S
(infinitiu (vmn0000 elegir))
(s.a (grup.a (aq0000 español)))
(sp (prep (sp000 por)) (sn (grup.nom (nc0s000 defecto))))))
(fp .)))
注意:在这两种情况下,我都通过执行以下操作来启动Stanford服务器:
java -mx3g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-spanish.properties -port 9000 -timeout 15000