en-pos-maxent.bin
is just a ZIP file, so you can umcompress it and re-compress without that file.
The Profile data stream has an invalid format when using OpenNLP POSTagger
-
10-10-2022 - |
Pergunta
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);
Solução 3
Outras dicas
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:
manifest.properties
pos.model
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.