2

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);
4

3 回答 3

4

试试这个代码而不做任何改变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) {}
于 2017-12-10T04:06:38.280 回答
1

en-pos-maxent.bin文件重命名为en-pos-maxent.zip. (如果您使用的是 Windows,您可能必须取消隐藏文件扩展名。为此,请转到控制面板 -> 外观和个性化,然后单击“文件夹选项”。在视图选项卡中查找“隐藏已知文件类型的扩展名"并取消选中该框)。

其中有3个文件,它们是:

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

我看过一篇建议用户删除的帖子tags.tagdict,但背后没有任何理由。我也试过这个,不幸的是它不起作用。

于 2014-08-31T05:34:26.623 回答
0

en-pos-maxent.bin只是一个 ZIP 文件,因此您可以对其进行 umcompress 并在没有该文件的情况下重新压缩。

于 2014-02-12T17:46:02.963 回答