使用Stanford CoreNLP

vik*_*ga9 7 java eclipse nlp stanford-nlp

我正在尝试使用Stanford CoreNLP.我使用Web上的一些代码来了解coreference工具的用途.我尝试在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);      
        }

   }
}
Run Code Online (Sandbox Code Playgroud)

Kha*_*rul 4

我在 Eclipse 中使用斯坦福 CoreNLP 构建小型应用程序时发现了类似的问题。
增加 Eclipse 的堆大小并不能解决您的问题。
搜索后,应该增加ant build tool堆大小,但我不知道如何做到这一点。
所以我放弃了Eclipse,改用Netbeans。

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