使用Stanford CoreNLP

我正在尝试使用Stanford CoreNLP。 我使用Web上的一些代码来了解coreference工具的用途。 我尝试在Eclipse中运行该项目但仍然遇到内存不足exception。 我尝试增加堆大小,但没有任何区别。 关于为什么会这种情况发生的任何想法? 这是特定于代码的问题吗? 任何使用CoreNLP的方向都会很棒。

编辑 – 已添加代码

import edu.stanford.nlp.dcoref.CorefChain; import edu.stanford.nlp.dcoref.CorefCoreAnnotations; import edu.stanford.nlp.pipeline.Annotation; import edu.stanford.nlp.pipeline.StanfordCoreNLP; import java.util.Iterator; import java.util.Map; import java.util.Properties; public class testmain { public static void main(String[] args) { String text = "Viki is a smart boy. He knows a lot of things."; Annotation document = new Annotation(text); Properties props = new Properties(); props.put("annotators", "tokenize, ssplit, pos, parse, dcoref"); StanfordCoreNLP pipeline = new StanfordCoreNLP(props); pipeline.annotate(document); Map graph = document.get(CorefCoreAnnotations.CorefChainAnnotation.class); Iterator itr = graph.keySet().iterator(); while (itr.hasNext()) { String key = itr.next().toString(); String value = graph.get(key).toString(); System.out.println(key + " " + value); } } } 

在Eclipse中使用Stanford CoreNLP构建小型应用程序时,我发现了类似的问题。
增加Eclipse的堆大小不会解决您的问题。
在进行搜索之后,应该增加ant构建工具堆大小,但我不知道该怎么做。
所以我放弃Eclipse并使用Netbeans代替。

PS: Netbeans中的默认设置最终会导致内存不足。 但它可以通过调整设置-Xms每个应用程序轻松解决。

修复eclipse:你可以在eclipse偏好中配置如下

  1. Windows – >首选项(在Mac上:eclipse – >首选项)
  2. Java – >已安装的JRE
  3. 选择JRE并单击Edit
  4. 在默认的VM参数字段中,键入“-Xmx1024M”。 (或者你的记忆偏好,1GB的ram是1024)
  5. 点击完成或确定。

我认为您可以在VM参数下的右键单击 – >运行 – >运行配置中定义堆大小。 我已经在Mac上测试了它,它的工作原理。