stanford-nlp - 添加属性时超出 GC 开销限制
问题描述
我刚刚开始使用用于 java 的 StanfordCoreNlp 库,并且在添加 coref 或 dcoref 注释属性时不断收到 GC 开销限制错误。知道如何解决这个问题吗?
出于测试目的,我逐渐将 JVM maxHeap 内存更改为 8GB 内存,这绝对不是问题。我尝试从属性中删除几个标签,这是唯一一个似乎解决开销错误的标签,它也只给出了StanfordCoreNlp 上的错误,simpleCore api 可以正常工作,但没有那么有效。代码片段与斯坦福官方文档中提供的示例相同。
public static void main(String[] args) {
// run all Annotators on this text
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma,ner, parse, coref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// read some text in the text variable
String text = "who is here?"; // Add your text here!
Annotation document = new Annotation(text);
// run all Annotators on this text
pipeline.annotate(document);
这是确切的错误消息:
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Arrays.copyOfRange(Arrays.java:3664)
at java.lang.String.<init>(String.java:207)
at edu.stanford.nlp.util.StringUtils.splitOnChar(StringUtils.java:537)
at edu.stanford.nlp.coref.data.Dictionaries.loadGenderNumber(Dictionaries.java:406)
at edu.stanford.nlp.coref.data.Dictionaries.<init>(Dictionaries.java:676)
at edu.stanford.nlp.coref.data.Dictionaries.<init>(Dictionaries.java:576)
at edu.stanford.nlp.coref.CorefSystem.<init>(CorefSystem.java:32)
at edu.stanford.nlp.pipeline.CorefAnnotator.<init>(CorefAnnotator.java:67)
at edu.stanford.nlp.pipeline.AnnotatorImplementations.coref(AnnotatorImplementations.java:196)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.lambda$getNamedAnnotators$14(StanfordCoreNLP.java:532)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$$Lambda$25/2137589296.apply(Unknown Source)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.lambda$null$30(StanfordCoreNLP.java:602)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$$Lambda$38/1798286609.get(Unknown Source)
at edu.stanford.nlp.util.Lazy$3.compute(Lazy.java:126)
at edu.stanford.nlp.util.Lazy.get(Lazy.java:31)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:149)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:251)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:192)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:188)
at StanfordCoreNLPtest.main(StanfordCoreNLPtest.java:31)
进程以退出代码 1 结束
解决方案
据我所知,这只能是由 Java 内存不足引起的——这里只是加载字典,而不是无限循环。您确定要指定如何正确设置可用内存吗?例如,如果在 Eclipse 下运行,您需要设置应用程序的内存而不是给 Eclipse 的内存。8GB 应该足以使用任何选项运行 CoreNLP(除非文档很大,但文档加载发生在加载 coref 之后)。但是您可以尝试使用 12GB 以防万一看看会发生什么......
推荐阅读
- python - 给定向量 X 和 Y,计算数组 C 使得 C[i, j] = 1 / (x[i] - y[j])
- r - 从 commandlne ubuntu 运行 R 时出错:加载共享库时出错:libpcre.so.1:无法打开共享对象文件
- c# - 为什么我们不需要在 HttpGet Create 中返回 View(new Person())?
- php - 如何使用一个查询删除数据库条目<实际日期与单独字段中的年月日值?
- laravel - 一般是否可以导入用户的linkedin职位或个人资料?
- .net - 在控制台应用程序中使用实体框架运行一系列脚本 (.sql) 文件
- visual-studio-code - 我们如何利用在我们的扩展程序中隐藏单个状态栏项目?
- webview - 工作的 WebView 程序停止显示整页
- powershell - Powershell - 如何在 Bitlocker 脚本的文件名中添加计算机名称?
- javascript - 使用 HTML 中的本地脚本构建外部 JavaScript 引用