stanford NLP 介绍与安装,使用

  • 介绍

stanford NLP 拿过全球分词第一名,用Java写的,有python接口
jieba只支持中文分词

  • 安装:
    下载
    https://stanfordnlp.github.io/CoreNLP/download.html
    在这里插入图片描述
    解压后在这里插入图片描述
    然后再下个中文模型的jar包:
    stanford-chinesecorenlp-2018-02-27-models.jar
    放到解压后的目录下
    在这里插入图片描述
  • 简单使用:

from stanfordcorenlp import StanfordCoreNLP
path=r'D:\MyNLPLearningProject\stanford_NLP\stanford-corenlp-full-2018-10-05'
nlp = StanfordCoreNLP(path, lang='zh')
fin=open(r'D:\MyNLPLearningProject\stanford_NLP\news.txt','r',encoding='utf8')
for line in fin:
    line=line.strip()
    if len(line)<1:
        continue
    list01=[each[0]+"/"+each[1] for  each in nlp.ner(line) if len(each)==2 ]
    list02=[each[0]+"/"+each[1] for each in nlp.pos_tag(line) if len(each)==2 ]
    print(list01)
    print(list02)

发布了542 篇原创文章 · 获赞 133 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/qq_41228218/article/details/104013737