使用OpenNLP进行共指解决

时间:2011-12-25 13:11:24

标签: nlp opennlp

我想使用OpenNLP进行“共参分析”。来自Apache(Coreference Resolution)的文档未涵盖如何执行“coreference resolution”。有没有人有任何文档/教程如何做到这一点?

2 个答案:

答案 0 :(得分:12)

我最近遇到了同样的问题,并写了一些关于使用OpenNLP 1.5.x工具的博客说明。完整复制有点密集,所以here's a link with more details


在较高级别,您需要加载相应的OpenNLP coreference model libraries以及WordNet 3.0 dictionary。鉴于这些依赖关系,初始化链接器对象非常简单:

// LinkerMode should be TEST
//Note: I tried LinkerMode.EVAL before realizing that this was the problem
Linker _linker = new DefaultLinker("lib/opennlp/coref", LinkerMode.TEST);

然而,使用链接器并不那么明显。你需要:

  1. 将内容分解为句子和相应的标记
  2. 为每个句子创建一个Parse对象
  3. 包装每个句子Parse以指示句子排序:

    final DefaultParse parseWrapper = new DefaultParse(parse, idx);
  4. 迭代每个句子解析使用链接器从每个解析中获取提及对象:

    final Mention[] extents =
       _linker.getMentionFinder().getMentions(parseWrapper);
  5. 最后,使用链接器识别所有提及对象中的不同实体:

    DiscourseEntity[] entities = _linker.getEntities(arrayOfAllMentions);

答案 1 :(得分:9)

除了a very short mention of how to run it in the readme之外,OpenNLP目前几乎没有共识解析文档。

如果您没有投入使用OpenNLP,请考虑Stanford CoreNLP package,其中包括a Java example of how to run it,,包括如何使用该软件包执行共识解析。它还包括a page summarizing it's performance, and the papers published on the coreference package