在NameFinderME类中使用OpenNLP的Nullpointer异常

问题描述 投票:5回答:1

我正在使用OpenNLP从给定文本中提取命名实体。在大数据上运行代码时,它给出了以下错误。当我在小数据上运行它时它工作正常。

java.lang.NullPointerException
    at opennlp.tools.util.Cache.put(Cache.java:134)
    at opennlp.tools.util.featuregen.CachedFeatureGenerator.createFeatures(CachedFeatureGenerator.java:71)
    at opennlp.tools.namefind.DefaultNameContextGenerator.getContext(DefaultNameContextGenerator.java:116)
    at opennlp.tools.namefind.DefaultNameContextGenerator.getContext(DefaultNameContextGenerator.java:39)
    at opennlp.tools.util.BeamSearch.bestSequences(BeamSearch.java:125)
    at opennlp.tools.util.BeamSearch.bestSequence(BeamSearch.java:198)
    at opennlp.tools.namefind.NameFinderME.find(NameFinderME.java:214)
    at opennlp.tools.namefind.NameFinderME.find(NameFinderME.java:198)

这个你能帮我吗。

nlp opennlp
1个回答
3
投票

我在POSTaggerME中遇到了同样的问题,原因几乎可以肯定是因为你在线程之间共享一个NameFinderME实例。

根据opennlp文档,大多数公开的库类都不是线程安全的:http://incubator.apache.org/opennlp/documentation/manual/opennlp.html#tools.namefind.recognition.api

© www.soinside.com 2019 - 2024. All rights reserved.