Search code examples
c#.netikvmopennlp

Create a POSModel object in C# using OpenNLP library


I am using the IKVM tool for using OpenNLP library in .NET with C#. When I try to create an Object of

string pos = "\\en-pos-maxent.bin";
modelInpStream = new java.io.FileInputStream("D:\\models"+ pos);
opennlp.tools.postag.POSModel pOSModel = new pennlp.tools.postag.POSModel(modelInpStream);

It throws this error:

InvalidFormatException

The profile data stream has an invalid format!

Can anybody tell me what is the problem in the above code?


Solution

  • I have found solution. actually problem is in en-pos-maxent.bin zip file.

    i have downloaded 1.5 models in which every model has only 2 contents. but en-pos-maxent.bin has 3 contents, so just removing tags.tagdict file form zip file my problem is solved.