本文介绍了使用斯坦福大学的CoreNLP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Stanford CoreNLP.我使用了一些Web上的代码来了解共指工具的功能.我尝试在Eclipse中运行该项目,但始终遇到内存不足异常.我尝试增加堆大小,但没有任何区别.关于为什么这种情况持续发生的任何想法?这是特定于代码的问题吗?使用CoreNLP的任何指导都很棒.

I am trying to get around using the Stanford CoreNLP. I used some code from the web to understand what is going on with the coreference tool. I tried running the project in Eclipse but keep encountering an out of memory exception. I tried increasing the heap size but there isnt any difference. Any ideas on why this keeps happening? Is this a code specific problem? Any directions of using CoreNLP would be awesome.

编辑-已添加代码

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);      
        }

   }
}

推荐答案

在Eclipse中使用Stanford CoreNLP构建小型应用程序时,我发现了类似的问题.
增大Eclipse的堆大小将无法解决您的问题.
搜索后,应该增加 ant构建工具堆大小,但是我不知道该怎么做.
所以我放弃了Eclipse,转而使用Netbeans.

I found similar problem when building small application using Stanford CoreNLP in Eclipse.
Increasing Eclipse's heap size will not solve your problem.
After doing search, it is ant build tool heap size that should be increased, but I have no idea how to do that.
So I give up Eclipse and use Netbeans instead.

PS:您最终将获得Netbeans中默认设置的内存不足异常.但是可以通过根据应用程序调整设置 -Xms 来轻松解决.

PS: You will eventually get out of memory exception with default setting in Netbeans. But it can easily solved by adjust setting -Xms per application basis.

这篇关于使用斯坦福大学的CoreNLP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 23:29