您的位置:首页 > 其它

Stanford NLP工具--句法分析

2017-03-22 14:02 816 查看
1,先上几个网址。

主页:http://nlp.stanford.edu

github地址:https://github.com/stanfordnlp/CoreNLP

在线效果展示1:http://nlp.stanford.edu:8080/parser/index.jsp

在线效果展示2:http://corenlp.run

2,下载并使用

(1)访问http://stanfordnlp.github.io/CoreNLP/下载对应的zip包,zip包名称类似于stanford-corenlp-full-2016-10-31.zip。

(2)访问http://nlp.stanford.edu/software/lex-parser.html#Download下载对应的jar包(模型文件,选择需要分析的语言模型),jar包名称类似于stanford-chinese-corenlp-2016-10-31-models.jar。

(3)新建java项工程,并将解压后的zip包中所有jar包和model的jar包加入到java build path中。

 PS:Stanford NLP句法分析工具占用内存较大,建议设置ide的内存为“-Xms512M -Xmx4096M”。切记使用1.8版本的jdk。

(4)编写测试类。

 github地址中有很多测试类,可以自行查找。以下提供几个简单的中文句法分析测试类。

 1)main方法如下
public static void main(String[] args) {
String[] arg2 = {"-encoding", "utf-8",
"-outputFormat", "penn,typedDependenciesCollapsed",
"edu/stanford/nlp/models/lexparser/xinhuaFactored.ser.gz",
"D:\\t1.txt"};
LexicalizedParser.main(arg2);
}
 从该方法可以看出,edu.stanford.nlp.parser.lexparser.LexicalizedParser是一个很重要的类,该方法的main函数告诉我们怎样使用这个方法。

 具体参考http://www.cnblogs.com/stGeekpower/p/3457746.html和http://www.cnblogs.com/stGeekpower/p/3477520.html。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: