StanfordCoreNLP配置方法
pip install stanfordcorenlp去官网下载CoreNLP解压CoreNLP,得到stanford-corenlp-4.2.0unzip stanford-corenlp-latest.zip简单实用示例:>>> from stanfordcorenlp import StanfordCoreNLP>>> nlp = StanfordCore
·
pip install stanfordcorenlp
- 去官网下载CoreNLP
- 解压CoreNLP,得到stanford-corenlp-4.2.0
unzip stanford-corenlp-latest.zip
简单实用示例:
>>> from stanfordcorenlp import StanfordCoreNLP
>>> nlp = StanfordCoreNLP('./stanford-corenlp-4.2.0')
>>> s = 'show from flights me san francisco to minneapolis'
>>> print(nlp.pos_tag(s))
[('show', 'NN'), ('from', 'IN'), ('flights', 'NNS'), ('me', 'PRP'), ('san', 'FW'), ('francisco', 'FW'), ('to', 'TO'),
('minneapolis', 'NNP')]
>>> print(nlp.ner(s))
[('show', 'O'), ('from', 'O'), ('flights', 'O'), ('me', 'O'), ('san', 'O'), ('francisco', 'O'), ('to', 'O'), ('minneapolis', 'O')]
>>> print(nlp.parse(s))
(ROOT
(NP
(NP
(NP (NN show))
(PP (IN from)
(NP
(NP (NNS flights))
(NP (PRP me)))))
(NP
(NP (FW san) (FW francisco))
(TO to)
(NP (NNP minneapolis)))))
>>> print(nlp.dependency_parse(s))
[('ROOT', 0, 1), ('case', 3, 2), ('nmod', 1, 3), ('dep', 3, 4), ('compound', 6, 5), ('dep', 4, 6), ('case', 8, 7), ('nmod', 6, 8)]
如需中文扩展,请参考以下链接
Reference
更多推荐
已为社区贡献3条内容
所有评论(0)