2017-05-16 11 views
0

私はOpenIE annotatorを使用して情報抽出にStanford CoreNLP(JAVA)を使用しています。私のコードを実行している間:(Javaヒープ領域のjava.lang.OutOfMemoryError) - PFB私のコードStandford CoreNLP throwing OutofMemoryException

public void getInformation(String fileName){ 
    Properties prop = new Properties(); 
    prop.setProperty("annotators", "tokenize, ssplit, pos, lemma, depparse, natlog, openie"); 
    StanfordCoreNLP pipeline = new StanfordCoreNLP(prop); 
    Annotation annotation = new Annotation(IOUtils.slurpFileNoExceptions(fileName)); 
    pipeline.annotate(annotation); 
    pipeline.prettyPrint(annotation, out_data); 
    System.out.println("============================="); 
    System.out.println("The top level annotation"); 
    System.out.println(annotation.toString()); 

    List<CoreMap> sentences = (List<CoreMap>) annotation.get(CoreAnnotations.SentencesAnnotation.class); 
    if(sentences!=null && !sentences.isEmpty()) 
    { 
     CoreMap sentence = sentences.get(0); 

     Collection<RelationTriple> triples = sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class); 

     // Print the triples 
     for(RelationTriple triple : triples) 
     { 
      System.out.println(triple.confidence + "\t" + 
      triple.subjectLemmaGloss() + "\t" + 
      triple.relationLemmaGloss() + "\t" + 
      triple.objectLemmaGloss()); 
     } 

    } 
} 

しかし、次のエラーを取得しています。

INFO edu.stanford.nlp.parser.nndep.DependencyParser - Loading depparse model file: edu/stanford/nlp/models/parser/nndep/english_UD.gz ... 
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space 
at edu.stanford.nlp.parser.nndep.Classifier.preCompute(Classifier.java:661) 
at edu.stanford.nlp.parser.nndep.Classifier.preCompute(Classifier.java:643) 
at edu.stanford.nlp.parser.nndep.DependencyParser.initialize(DependencyParser.java:1168) 
at edu.stanford.nlp.parser.nndep.DependencyParser.loadModelFile(DependencyParser.java:605) 
at edu.stanford.nlp.parser.nndep.DependencyParser.loadFromModelFile(DependencyParser.java:498) 
at edu.stanford.nlp.pipeline.DependencyParseAnnotator.<init>(DependencyParseAnnotator.java:57) 
at edu.stanford.nlp.pipeline.AnnotatorImplementations.dependencies(AnnotatorImplementations.java:273) 
at edu.stanford.nlp.pipeline.AnnotatorFactories$18.create(AnnotatorFactories.java:480) 
at edu.stanford.nlp.simple.Document$5.get(Document.java:154) 
at edu.stanford.nlp.simple.Document$5.get(Document.java:148) 
at edu.stanford.nlp.simple.Document.runDepparse(Document.java:946) 
at edu.stanford.nlp.simple.Document.runNatlog(Document.java:966) 
at edu.stanford.nlp.simple.Document.runOpenie(Document.java:986) 
at edu.stanford.nlp.simple.Sentence.openieTriples(Sentence.java:890) 
at edu.stanford.nlp.simple.Sentence.openieTriples(Sentence.java:900) 
at com.automatics.nlp.OpenIEDemo.main(OpenIEDemo.java:18) 

この例外をどのように克服する必要がありますか?

ありがとうございます!

答えて

0

プログラムを実行する際には、少なくとも2 GBのRAMを用意する必要があります。使用している他のStanford CoreNLP注釈子によります。クラッシュがなくなるまでRAMを追加し続ける必要があります。

+0

ありがとうございます! RAMを増やしても例外なく実行されます。 –