Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 斯坦福NLP-处理文件列表时OpenIE内存不足_Java_Stanford Nlp - Fatal编程技术网

Java 斯坦福NLP-处理文件列表时OpenIE内存不足

Java 斯坦福NLP-处理文件列表时OpenIE内存不足,java,stanford-nlp,Java,Stanford Nlp,我正试图使用斯坦福CoreNLP的OpenIE工具从几个文件中提取信息,当几个文件传递到输入时,而不是一个文件时,会出现内存不足错误 All files have been queued; awaiting termination... java.lang.OutOfMemoryError: GC overhead limit exceeded at edu.stanford.nlp.graph.DirectedMultiGraph.outgoingEdgeIterator(DirectedMu

我正试图使用斯坦福CoreNLP的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.
我尝试使用
-mx3g
和其他变体来增加内存,虽然处理的文件数量增加了,但并没有增加多少(例如,从5个增加到7个)。每个文件都被正确处理,所以我排除了一个包含大句子或多行的文件

是否有一个我没有考虑的选项,一些OpenIE或Java标志,我可以用来强制输出转储、清理或处理的每个文件之间的垃圾收集


从上面的评论中提前感谢您:我怀疑这是一个并行性太强、内存太少的问题。OpenIE有点内存不足,特别是对于长句,因此并行运行许多文件可能会占用相当多的内存


一个简单的修复方法是通过设置
-threads 1
标志,强制程序运行单线程。如果可能的话,增加内存也会有帮助。

运行此命令以获得每个文件的单独注释(sample-file-list.txt应该是每行一个文件)


请调用的代码您正在处理的文件有多大(例如,文字)?你的计算机有多少线程?您可以尝试的一件事是设置
-threads 1
,并在处理文档时禁用并行性。如果一次加载许多大型文档,这可以解决问题。@Woot4Moo我直接从shell调用openIE,使用我在shell中的java调用,而不更改提供的源代码,但无论如何还是要感谢您。@smothP太棒了!很有可能,将内存增加几GB也可以使其在多线程中工作。CoreNLP注释对象相当大,OpenIE产生的中间垃圾可能比它应该产生的要多——特别是对于长句。我们有不同的输出:这是一个新功能的好主意。现在,您可以将输出格式设置为
-format reverb
,然后第一列将有输入文件名,您可以使用该文件名路由输出。(请参阅混响输出格式)注意:我刚刚修复了此命令,因为在最初的命令中,我在本地计算机上使用了属性文件!还有各种输出格式(json、xml),我只是喜欢使用文本来提高可读性,但在管道中传递到下一步时可能很糟糕;i、 所有其他的CoreNLP注释。谢谢你们。这很管用,但我将使用@GaborAngeli的建议输出到混响格式,因为我已经在使用混响到其他东西了。再次感谢!我的机器只有4Gb,所以我只尝试了3Gb的内存。我会尝试访问一台内存更多的机器来测试它,但这个解决方案是完美的。
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.
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