Question

I am getting Invalid Format exception. I saw some people suggesting to remove tags.tagdict file from en-pos-maxent.bin file but I don't know how to do that. Can any one please explain that to me

    ava.io.FileInputStream inputStream2 = new java.io.FileInputStream("D://Documents/7090/opennlp-models/en-pos-maxent.bin");
    POSModel pModel = new POSModel(inputStream2);
    POSTaggerME posDetector = new POSTaggerME(pModel);
Was it helpful?

Solution 3

en-pos-maxent.bin is just a ZIP file, so you can umcompress it and re-compress without that file.

OTHER TIPS

Try this code without any change in en_pos_maxent.bin

System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
try { 
    AssetFileDescriptor fileDescriptor = 
    context.getAssets().openFd("en_pos_maxent.bin"); 
    FileInputStream inputStream = fileDescriptor.createInputStream();
    POSModel posModel = new POSModel(inputStream);
    posTaggerME = new POSTaggerME(posModel);
} catch (Exception e) {}

rename the en-pos-maxent.bin file to en-pos-maxent.zip. (If you are using windows you may have to un-hide file extensions. To do this go to control panel -> Apperance and personalization and then click on "folder options." In the view tab look for "hide extensions for known file types" and uncheck that box).

There are 3 files in it and they are:

  1. manifest.properties
  2. pos.model
  3. tags.tagdict

I have seen one post suggesting users delete tags.tagdict, but without any reasoning behind it. I have tried this also and it doesn't work unfortunately.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top