斯坦福python中文分词stanza

 

1 下载 Stanford CoreNLP相关文件

斯坦福python中文分词stanza

 
下载中文模型文件 

斯坦福python中文分词stanza

 
解压stanford-corenlp-full-2018-02-27.zip,并将下载的模型文件stanford-chinese-corenlp-2018-10-05-models.jar、 StanfordCoreNLP-chinese.properties 拷贝到上述解压的文件夹内
 
 
2 配置并检验JAVA环境
java -version
 
3 下载并安装 stanza 
 
手动下载或者通过git方式下载 stanza源文件 https://codeload.github.com/stanfordnlp/stanza/zip/master
在解压的文件内执行 python3 setup.py install
 
4 启动服务
java -Xmx6g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-chinese.properties -port 9000 -timeout 15000
 
5 通过python调用分词验证
from stanza.nlp.corenlp import CoreNLPClient
client = CoreNLPClient(server='http://localhost:9000', default_annotators=['ssplit', 'lemma', 'tokenize
', 'pos', 'ner']) # 注意在以前的版本中,中文分词为 segment,新版已经和其他语言统一为 tokenize
 
# 分词和词性标注测试
test1 = "财政部会计司发布通知称,上海财经大学会计学院原副教授钱逢胜同志不再符合担任企业会计准则咨询委员
会委员条件,现决定辞聘钱逢胜担任的企业会计准则咨询委员会委员。"
annotated = client.annotate(test1)
for sentence in annotated.sentences:
    for token in sentence:
        print(token)

 

斯坦福python中文分词stanza

相关文章:

  • 2021-11-08
  • 2022-01-23
  • 2021-10-31
  • 2021-09-03
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2021-08-25
  • 2022-12-23
  • 2021-06-23
  • 2021-04-25
  • 2021-06-17
相关资源
相似解决方案