stanford python中文分词

来源:互联网 发布:保定云计算培训 编辑:程序博客网 时间:2024/05/16 17:55

总结,只有三步:

下载coreNLP

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

下载

http://nlp.stanford.edu/software/stanford-chinese-corenlp-2016-10-31-models.jar

 然后把这个jar文件复制到第一步解压后的文件夹中


python输入以下代码,路径改成上面的stanford-chinese-corenlp-2016-10-31-models.jar所在文件夹路径

from stanfordcorenlp import StanfordCoreNLPnlp = StanfordCoreNLP(r'/home/appleyuchi/PycharmProjects/csdn_blog/72993873StanfordCoreNLP进行中文分词/stanford-corenlp-full-2017-06-09', lang='zh')sentence = '清华大学位于北京。'print (nlp.word_tokenize(sentence))print (nlp.pos_tag(sentence))print (nlp.ner(sentence))print (nlp.parse(sentence))print (nlp.dependency_parse(sentence))


原创粉丝点击