2016-04-05 2 views
2

Stanford CoreNLPのOpenIEツールを使用して複数のファイルから情報を抽出しようとしていますが、入力に複数のファイルが渡されたときにメモリ不足エラーが発生しますただ1つのスタンフォードNLP - ファイルのリストを処理するときにOpenIEがメモリ不足

All files have been queued; awaiting termination... 
java.lang.OutOfMemoryError: GC overhead limit exceeded 
at edu.stanford.nlp.graph.DirectedMultiGraph.outgoingEdgeIterator(DirectedMultiGraph.java:508) 
at edu.stanford.nlp.semgraph.SemanticGraph.outgoingEdgeIterator(SemanticGraph.java:165) 
at edu.stanford.nlp.semgraph.semgrex.GraphRelation$GOVERNER$1.advance(GraphRelation.java:267) 
at edu.stanford.nlp.semgraph.semgrex.GraphRelation$SearchNodeIterator.initialize(GraphRelation.java:1102) 
at edu.stanford.nlp.semgraph.semgrex.GraphRelation$SearchNodeIterator.<init>(GraphRelation.java:1083) 
at edu.stanford.nlp.semgraph.semgrex.GraphRelation$GOVERNER$1.<init>(GraphRelation.java:257) 
at edu.stanford.nlp.semgraph.semgrex.GraphRelation$GOVERNER.searchNodeIterator(GraphRelation.java:257) 
at edu.stanford.nlp.semgraph.semgrex.NodePattern$NodeMatcher.resetChildIter(NodePattern.java:320) 
at edu.stanford.nlp.semgraph.semgrex.CoordinationPattern$CoordinationMatcher.matches(CoordinationPattern.java:211) 
at edu.stanford.nlp.semgraph.semgrex.NodePattern$NodeMatcher.matchChild(NodePattern.java:514) 
at edu.stanford.nlp.semgraph.semgrex.NodePattern$NodeMatcher.matches(NodePattern.java:542) 
at edu.stanford.nlp.naturalli.RelationTripleSegmenter.segmentVerb(RelationTripleSegmenter.java:541) 
at edu.stanford.nlp.naturalli.RelationTripleSegmenter.segment(RelationTripleSegmenter.java:850) 
at edu.stanford.nlp.naturalli.OpenIE.relationInFragment(OpenIE.java:354) 
at edu.stanford.nlp.naturalli.OpenIE.lambda$relationsInFragments$2(OpenIE.java:366) 
at edu.stanford.nlp.naturalli.OpenIE$$Lambda$76/1438896944.apply(Unknown Source) 
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) 
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1540) 
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) 
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) 
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) 
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) 
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) 
at edu.stanford.nlp.naturalli.OpenIE.relationsInFragments(OpenIE.java:366) 
at edu.stanford.nlp.naturalli.OpenIE.annotateSentence(OpenIE.java:486) 
at edu.stanford.nlp.naturalli.OpenIE.lambda$annotate$3(OpenIE.java:554) 
at edu.stanford.nlp.naturalli.OpenIE$$Lambda$25/606198361.accept(Unknown Source) 
at java.util.ArrayList.forEach(ArrayList.java:1249) 
at edu.stanford.nlp.naturalli.OpenIE.annotate(OpenIE.java:554) 
at edu.stanford.nlp.pipeline.AnnotationPipeline.annotate(AnnotationPipeline.java:71) 
at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:499) 
at edu.stanford.nlp.naturalli.OpenIE.processDocument(OpenIE.java:630) 
DONE processing files. 1 exceptions encountered. 

私はこの呼び出しを使用して入力して、ファイルを渡す:

java -mx3g -cp stanford-corenlp-3.6.0.jar:stanford-corenlp-3.6.0-models.jar:CoreNLP-to-HTML.xsl:slf4j-api.jar:slf4j-simple.jar edu.stanford.nlp.naturalli.OpenIE file1 file2 file3 etc. 

私は-mx3gおよび他の変異体とメモリを増やす試みたが、処理されたファイルの量が増加するものの、それは非常に(5からではありません〜7など)。それぞれのファイルは個別に正しく処理されるため、大きな文章や複数行のファイルは除外します。

いくつかのOpenIEまたはJavaフラグを処理する各ファイル間で出力、クリーニング、またはガーベジコレクションにダンプするために使用できるオプションはありますか?

は、上記のコメントから、事前

+0

呼び出すためのコードください – Woot4Moo

+1

あなたが処理しているファイルが(どのように大きく、例えば、言葉で)?お使いのコンピュータにはいくつのスレッドがありますか?あなたが試みることの1つは、 '-threads 1'を設定し、文書の処理において並列性を無効にすることです。一度に多数の大きな文書をロードしている場合、これにより問題が解決する可能性があります。 –

+0

@ Woot4Moo提供されたソースコードを変更せずに、私がそこに置いたJava呼び出しを使用してシェルからopenIEを直接呼び出しますが、とにかく感謝します。 – smothP

答えて

1

にありがとう:私は、これはあまりにも多くの並列性とあまりにも少ないメモリの問題であると思います。 OpenIEは、特に長い文章では少しメモリが空いているので、多くのファイルを並行して実行するとかなりのメモリが必要になります。

簡単な修正は、-threads 1フラグを設定することによって、プログラムが強制的にシングルスレッドで実行されるようにすることです。可能であれば、メモリを増やすことも有効です。

+0

もう一度ありがとうございます!私のマシンは4Gbしか持っていないので、私は3Gbのメモリまで試しました。私はそれをテストするだけのメモリを持つマシンにアクセスしようとしますが、このソリューションは完璧です。 – smothP

3

実行ファイルごとに別々の注釈を取得するには、このコマンド(サンプル・ファイルlist.txtには、1行に1つのファイルである必要があります)

java -Xmx4g -cp "stanford-corenlp-full-2015-12-09/*" edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,depparse,natlog,openie -filelist sample-file-list.txt -outputDirectory output_dir -outputFormat text 
+1

注:私はローカルコンピュータ上のプロパティファイルを使用していたので、私はこのコマンドを修正しました! – StanfordNLPHelp

+1

また、さまざまなoutputFormats(json、xml)が用意されていますが、読みやすくするためにテキストを使用するのと同じですが、パイプラインの次のステップに渡すためにはおそらく貧弱です。 – StanfordNLPHelp

+1

これは、OpenIEに加えてたくさんの余分なものをダンプすることに注意してください。すなわち、他の全てのCoreNLP注釈を含む。 –

関連する問題