OpenNlp icon indicating copy to clipboard operation
OpenNlp copied to clipboard

Name entity recognition not working correct for second call

Open juergenr opened this issue 8 years ago • 0 comments

When calling nameFinder.GetNames(models, "in 2005"); the second time, the tags are missing or the whole tagging is corrupted. The first time is working fine, the second using an total different input is working in most cases - but not the same or some similar sentence!

A dirty work-a-round is to recreate the Beam in the Find method of the MaximumEntropyNameFinder.

MaximumEntropyNameFinder.cs:
public virtual string[] Find(string[] tokens, IDictionary previousTags)
{
       //Dirty hack to fix an error for a repeated call 
       mBeam = new NameBeamSearch(this, mBeamSize, mContextGenerator, mModel, mBeamSize); 

       mBestSequence = mBeam.BestSequence(tokens, new object[]{previousTags});
       return mBestSequence.Outcomes.ToArray();
}

May be you can correct the issue, I do not really understand what went wrong.

juergenr avatar Sep 12 '16 19:09 juergenr