5

I am using OpenNLP to extract named entities from a given text. It gives me the following error while running the code on large data. When I run it on small data it works fine.

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)

Please help me out with this.

Nicomedes E.
  • 1,326
  • 5
  • 18
  • 27

1 Answers1

3

I had this same issue with POSTaggerME, and the cause is almost certainly because you're sharing a NameFinderME instance between threads.

Per the opennlp doc, most of the exposed library classes are not thread-safe: http://incubator.apache.org/opennlp/documentation/manual/opennlp.html#tools.namefind.recognition.api