博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用stanford nlp进行依存句法分析
阅读量:7209 次
发布时间:2019-06-29

本文共 1638 字,大约阅读时间需要 5 分钟。

本文主要研究下如何使用stanford nlp进行依存句法分析

maven

edu.stanford.nlp
stanford-corenlp
3.9.1

LexicalizedParser

Lexical是词汇的意思,LexicalizedParser即词汇的语法解析
@Test    public void testLexicalizedParser() throws IOException {        LexicalizedParser lp = LexicalizedParser.loadModel(this.getClass().getClassLoader().getResource("xinhuaFactoredSegmenting.ser.gz").getPath());        List
lines = Arrays.asList("小明喜欢吃香蕉"); lines.stream().forEach(sentence -> { Tree tree = lp.parse(sentence); ChineseGrammaticalStructure gs = new ChineseGrammaticalStructure(tree); Collection
tdl = gs.typedDependenciesCollapsed(); System.out.println("sentence:"+sentence); tdl.stream().forEach(typedDependency -> { System.out.println("Governor Word: [" + typedDependency.gov() + "] Relation: [" + typedDependency.reln().getLongName() + "] Dependent Word: [" + typedDependency.dep() + "]"); }); }); }
这里加载了xinhuaFactoredSegmenting.ser.gz

输出

sentence:小明喜欢吃香蕉Governor Word: [喜欢/VV] Relation: [nominal subject] Dependent Word: [小明/NR]Governor Word: [ROOT] Relation: [root] Dependent Word: [喜欢/VV]Governor Word: [喜欢/VV] Relation: [clausal complement] Dependent Word: [吃/VV]Governor Word: [吃/VV] Relation: [direct object] Dependent Word: [香蕉/NN]

关系说明

  • root 句子的开头,一个虚拟的node
  • nsubj(nominal subject) 名词主语
  • dobj(direct object) 直接宾语
  • ccomp(clausal complement) 从句补充

词性说明

  • VV 动词
  • NR 人名
  • NN 常用名词

小结

本文利用stanford nlp的LexicalizedParser对中文句子进行了简单的依存关系分析,更深入的内容见下面的参考文档。

doc

转载地址:http://aygum.baihongyu.com/

你可能感兴趣的文章
CSS语义思维
查看>>
使用Automator批量生成图标
查看>>
Python中的下划线(译文)
查看>>
7月26日云栖精选夜读丨法国队夺了世界杯冠军,却彻底打了AI预测的脸
查看>>
SSM-SpringMVC-24:SpringMVC异常高级之自定义异常
查看>>
微软对 Chromium 新贡献:为字幕添加 Windows 系统样式支持
查看>>
关于移动端开发中遇到的坑-vue
查看>>
读书笔记 effective c++ Item 16 成对使用new和delete时要用相同的形式
查看>>
Atom 1.36.0-beta2 发布,跨平台文本编辑器
查看>>
shell学习笔记
查看>>
dubbo
查看>>
Android签名包apk安装不上:INSTALL_PARSE_FAILED_NO_CERTIFICATES
查看>>
丰田生产方式的自働化与负反馈分析
查看>>
深度学习中常用的优化方法
查看>>
安卓之上传文件,即HTTP提交表单
查看>>
Android最新Glide 4.0使用简介
查看>>
react-router browserHistory刷新页面404问题解决
查看>>
数据库服务器编码,数据库编码,数据库表编码,数据库表字段编码
查看>>
第26天:js-$id函数、焦点事件
查看>>
Android使用Thread的interrupt与sleep,重启或暂停线程任务
查看>>