当前位置: 首页 > 知识库问答 >
问题:

Stanford CoreNLP——线程“main”java中的异常。lang.OutOfMemoryError:Java堆空间

邓越泽
2023-03-14

我正在尝试运行这个网站上提供的简单程序https://stanfordnlp.github.io/CoreNLP/api.html
我的节目

import java.io.BufferedReader;  
import java.io.BufferedWriter;  
import java.io.FileNotFoundException;  
import java.io.FileReader;  
import java.io.FileWriter;  
import java.io.IOException;  
import java.io.PrintWriter;  
import java.util.List;  
import java.util.Properties;  

import edu.stanford.nlp.ling.CoreAnnotations.NamedEntityTagAnnotation;  
import edu.stanford.nlp.ling.CoreAnnotations.PartOfSpeechAnnotation;  
import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation;  
import edu.stanford.nlp.ling.CoreAnnotations.TextAnnotation;  
import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation;  
import edu.stanford.nlp.ling.CoreLabel;  
import edu.stanford.nlp.pipeline.Annotation;  
import edu.stanford.nlp.pipeline.StanfordCoreNLP;  
import edu.stanford.nlp.util.CoreMap;  

public class StanfordClass {

    public static void main(String[] args) throws Exception {
     Properties props = new Properties();
      props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse");

        StanfordCoreNLP pipeline = new StanfordCoreNLP(props);

        String text = "What is the Weather in Mumbai right now?";
         Annotation document = new Annotation(text);
          pipeline.annotate(document);

        List<CoreMap> sentences = document.get(SentencesAnnotation.class);

       for(CoreMap sentence: sentences) {
          // traversing the words in the current sentence
          // a CoreLabel is a CoreMap with additional token-specific methods
          for (CoreLabel token: sentence.get(TokensAnnotation.class)) {
            // this is the text of the token
            String word = token.get(TextAnnotation.class);
            // this is the POS tag of the token
            String pos = token.get(PartOfSpeechAnnotation.class);
            // this is the NER label of the token
            String ne = token.get(NamedEntityTagAnnotation.class);

            System.out.println(String.format("Print: word: [%s] pos: [%s] ne: [%s]",word, pos, ne));
          }
        }
    }
}  

但是在线程"main"中获取Exceptionjava.lang.OutOfMemoryError:Java堆空间

我所尝试的
1。如果我从上述代码中删除ner(命名实体识别器)属性,即道具。setProperty(“注释器”、“标记化、ssplit、pos、引理、解析”)
那么代码运行正常
2。但我需要ner(命名实体识别器),因此我在eclipse中增加了堆大小。ini文件高达1g,并且确保这个大小对于这个程序来说足够大,并且确保堆大小在这种情况下不是问题。我觉得有些东西不见了,但没有得到。

共有1个答案

贡威
2023-03-14

经过大量搜索后,使用Stanford CoreNLP获得了答案

使用以下答案:-
1。窗户-

 类似资料:
  • 我从https://stanfordnlp.github.io/CoreNLP/然后将其解压并放入cd。现在我试着运行下面的java文件<代码>javac-cp“*”分析。java工作正常,但是java情感分析在线程“main”java中抛出异常错误。lang.NoClassDefFoundError:edu/stanford/nlp/pipeline/StanfordCoreNLP。 导入jav

  • 问题内容: 每当我运行此命令时,该函数就可以正常使用。当我选择洞穴时,消息会每隔2秒弹出一次,然后当它越过该部分时,就会出现错误: 我已经尝试过和,并且在该方法中使用时,出现了很多错误。当我在方法中使用时,它不接受我的输入。 当我在该方法中使用时,它不接受我的字符串输入,而直接进入另一个游戏,但是布尔值返回并且它无限地发送垃圾邮件“ Which Cave …”。 我已经阅读了错误报告,以及类似问题

  • 问题内容: 我正在开发一个访问数据库的项目,但是我遇到了一些问题。我尝试使用hibernate3.2和4.52,但是它不起作用。 例外是在这行代码中 问题答案: 您需要在类路径中检查类org.apache.log4j.Level的冲突版本并进行解决。版本1.2.12或更高版本的log4j jar中提供了TRACE级别。

  • 我最近安装了intellij IDEA 14.0,为了确保一切正常,我创建了一个简单的Hello World程序。我不明白为什么输出不正确,为什么会出现这个错误。如果有人能帮忙,那就太好了。 以下是程序: 这是错误:

  • 问题内容: 当我运行程序进行智能卡读取时,会出现此异常。我的设备未连接。请帮我。 问题答案: 这意味着它无法加载您需要的共享库。这可能是因为。 该库不在您的库路径中。 该库名称不正确,例如,Unix上LIBRARY必须为libLIBRARY.so。 您无法执行该库。 该库不适用于操作系统或JVM的位大小。例如64位JVM将不会加载32位库。 您的JRE未正确安装,并且无法加载其自己的库之一。 您正

  • 我不断收到错误消息: 线程“main”java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)在java.lang.Integer.ParseInt(Integer.java:580)在java.lang.Integer.ParseInt(Integer.java:615)在TestClass.Mai