7

我正在尝试使用斯坦福 CoreNLP。我使用网络上的一些代码来了解共指工具发生了什么。我尝试在 Eclipse 中运行该项目,但一直遇到内存不足异常。我尝试增加堆大小,但没有任何区别。关于为什么这种情况不断发生的任何想法?这是特定于代码的问题吗?使用 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<Integer, CorefChain> graph = document.get(CorefCoreAnnotations.CorefChainAnnotation.class);



        Iterator<Integer> itr = graph.keySet().iterator();

        while (itr.hasNext()) {

             String key = itr.next().toString();

             String value = graph.get(key).toString();

             System.out.println(key + " " + value);      
        }

   }
}
4

3 回答 3

4

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

PS:您最终会在 Netbeans 中使用默认设置出现内存不足异常。但它可以通过调整每个应用程序的设置-Xms来轻松解决。

于 2012-01-23T12:15:11.283 回答
3

修复 Eclipse:您可以在 Eclipse 首选项中进行如下配置

  1. Windows -> 首选项(在 Mac 上是:eclipse -> 首选项)
  2. Java -> 已安装的 JRE
  3. 选择 JRE 并单击编辑
  4. 在默认 VM 参数字段中,输入“-Xmx1024M”。(或您的内存偏好,对于 1GB 的 ram 其 1024)
  5. 单击完成或确定。
于 2013-01-09T05:39:21.853 回答
2

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

于 2013-02-22T21:26:22.810 回答