Stanford CoreNLP 3.6.0 中文指代消解模块调用失败的解决方案
当前中文指代消解领域比较活跃的研究者是Chen和Vincent Ng,这两个人近两年在AAAI2014, 2015发了一些相关的文章,研究领域跨越零指代、代词指代、名词指代等,方法也不是很复杂,集中于规则+特征+模型的传统思路。国内集中在苏州大学周国栋老师带领的团队和刘挺、秦兵老师带领的团队,分别在Berkeley Parser、LTP基础上做了一些研究,但是遗憾的是,近年来国内学者好像没有顶会命中记录。
鉴于当前国内的指代消解工具基本上没有开源、同时效果还说得过去的,所以经过大量调研当前中文指代消解的现状后,最终确定了使用Stanford CoreNLP作为实验对象。
Stanford CoreNLP 是斯坦福NLP组开源的一套集分词、词性标注、命名实体识别、句法分析、情感分析、指代消解等NLP功能的软件套装,支持英文、中文等语言。
附这个妇孺皆知的tools的链接:http://nlp.stanford.edu/software/index.shtml 和 http://stanfordnlp.github.io/CoreNLP/index.html
它的官方Demo链接:http://nlp.stanford.edu:8080/corenlp/ (这个DEMO对应的后台,应该是使用的英文模型)
好了 闲话不多说,我们快快步入正题,如何调用Stanford CoreNLP 3.6.0 套装中的中文指代消解模块
=========================================================================
=========================================================================
1、下载 Stanford CoreNLP 3.6.0 源码+模型,500M+,但是里面的cws、pos、parse等模型都是英文的 (http://stanfordnlp.github.io/CoreNLP/download.html)
2、下载中文模型,分词、词性标注、NER、parser等。(我不确定有没有统一下载地址,我是一个一个点开,找到Chinese Model,下载的 http://nlp.stanford.edu/software/index.shtml)
3、跑测试代码,在 http://stanfordnlp.github.io/CoreNLP/coref.html 里面找到运行方法,jar包调用分文件方式 或者 java代码调用分句子方式。(注意另外一个页面 http://nlp.stanford.edu/software/dcoref.shtml 中的方法是错误的,实践中有bug跑不通)
4、在3中找到了对的接口,实践中jar包调用来处理文件的方法,是可以在中文语料上跑通的,但是3中贴的代码仍然面向的是英文语料。这时需要对其进行修改。
代码如下:
import edu.stanford.nlp.hcoref.CorefCoreAnnotations;
import edu.stanford.nlp.hcoref.data.CorefChain;
import edu.stanford.nlp.hcoref.data.Mention;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.StringUtils; import java.util.Properties; public class CorefExample {
public static void main(String[] args) throws Exception {
long startTime=System.currentTimeMillis(); String text = "小明吃了个冰棒,它很甜。 ";
args = new String[] {"-props", "edu/stanford/nlp/hcoref/properties/zh-coref-default.properties" }; Annotation document = new Annotation(text);
Properties props = StringUtils.argsToProperties(args);
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
pipeline.annotate(document);
System.out.println("---");
System.out.println("coref chains");
for (CorefChain cc : document.get(CorefCoreAnnotations.CorefChainAnnotation.class).values()) {
System.out.println("\t" + cc);
}
for (CoreMap sentence : document.get(CoreAnnotations.SentencesAnnotation.class)) {
System.out.println("---");
System.out.println("mentions");
for (Mention m : sentence.get(CorefCoreAnnotations.CorefMentionsAnnotation.class)) {
System.out.println("\t" + m);
}
} long endTime=System.currentTimeMillis();
long time = (endTime-startTime)/1000;
System.out.println("Running time "+time/60+"min "+time%60+"s");
}
}
那么里面的zh-coref-default.properties 为啥CoreNLP里面没有呢。。。最后在stanford-chinese-corenlp-2015-12-08-models.jar解压后对应目录下找到了这个文件,与它官方网页里面虽然只相差一行(具体哪一行,大家可以对比看看),但是没有那个属性,真的跑不通。
Stanford CoreNLP 3.6.0 中文指代消解模块调用失败的解决方案的更多相关文章
- marmalade android 5.0 JNI 调用失败的解决方案
5.0 真机日志如下:sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV call ...
- Error:(27, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2约束布局constraint-layout导入失败的解决方案
运行demo提示错误: Error:(27, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2 ...
- 用 Python 和 Stanford CoreNLP 进行中文自然语言处理
实验环境:Windows 7 / Python 3.6.1 / CoreNLP 3.7.0 一.下载 CoreNLP 在 Stanford NLP 官网 下载最新的模型文件: CoreNLP 完整包 ...
- OpenERP 7.0 中文报表PDF乱码(WindowsXP)
OpenERP默认安装输出的PDF中文报表都是一些方块: 此问题可以通过oecn_base_fonts模块解决: 更多关于oecn_base_fonts的信息请参考: 1. OpenERPv7.0 中 ...
- 开源中文分词工具探析(五):Stanford CoreNLP
CoreNLP是由斯坦福大学开源的一套Java NLP工具,提供诸如:词性标注(part-of-speech (POS) tagger).命名实体识别(named entity recognizer ...
- 开源中文分词工具探析(六):Stanford CoreNLP
CoreNLP是由斯坦福大学开源的一套Java NLP工具,提供诸如:词性标注(part-of-speech (POS) tagger).命名实体识别(named entity recognizer ...
- stanford corenlp的TokensRegex
最近做一些音乐类.读物类的自然语言理解,就调研使用了下Stanford corenlp,记录下来. 功能 Stanford Corenlp是一套自然语言分析工具集包括: POS(part of spe ...
- stanford corenlp自定义切词类
stanford corenlp的中文切词有时不尽如意,那我们就需要实现一个自定义切词类,来完全满足我们的私人定制(加各种词典干预).上篇文章<IKAnalyzer>介绍了IKAnalyz ...
- 【转】基于VSM的命名实体识别、歧义消解和指代消解
原文地址:http://blog.csdn.net/eastmount/article/details/48566671 版权声明:本文为博主原创文章,转载请注明CSDN博客源地址!共同学习,一起进步 ...
随机推荐
- FFMpeg框架代码阅读
http://blog.csdn.net/wstarx/article/details/1572393 FFMPEG源码分析(二) http://www.cnblogs.com/qingquan/ar ...
- 伪分布模式安装hadoop
准备工具: 虚拟机:VMware Linux系统:CentOS hadoop-1.1.2.tar.gz jdk-7u75-linux-x64.gz CentOS的网络配置 1.设置主机中VMware ...
- Creating, detaching, re-attaching, and fixing a SUSPECT database
今天遇到一个问题:一个数据库suspect了.然后又被用户detach了. 1,尝试将数据库attach回去,因为log file损坏失败了. 2,尝试将数据库attach回去,同一时候rebuild ...
- java异常处理Exception
我看别人的面经中有一道题目就问到了Exception,即java的异常处理的,我曾经也学了java的异常处理,可是我查了下,看了别人的博客关于写的exception异常处理.我发现,自己学的不坚固,仅 ...
- 【Linux】Ctentos下载
百度输入:Download Centos 在百度搜索Download Centos然后进入Centos下载官网 点击上述标记的Download Centos,则会出现如下界面,并且点击"Mo ...
- golang使用sqlite
安装问题 在import sqlite的时候,golang build 出现以下错误, exec: "gcc": executable file not found in %PAT ...
- 使用typescript开发js代码提升代码维护性
function test() { var gs = new Greeter('ss'); alert( gs.greet()); } window.onload = test; class Gree ...
- Python 射线法判断一个点坐标是否在一个坐标区域内
class Point: lng = '' lat = '' def __init__(self, lng, lat): self.lng = lng self.lat = lat # 求外包矩形 d ...
- Android---Handler消息处理机制
搞Android的人都知道.android是不同意你在子线程中更新UI操作的.这主要出于线程安全方面的考虑.通常的做法是在主线程中创建一个Handler对象,在子线程中创建一个Message对象.该M ...
- Java Jar maven 下载地址
Java Jar maven 下载地址 https://repo1.maven.org/maven2/ 根据maven artifactid 查找相关jar