我一直在尝试使用POS模型进行POS标记,但在加载模型时,我得到以下异常,这对于maxent和perceptron模型都会发生:
java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.util.zip.ZipInputStream.read(Unknown Source)
at java.io.DataInputStream.readFully(Unknown Source)
at java.io.DataInputStream.readLong(Unknown Source)
at java.io.DataInputStream.readDouble(Unknown Source)
at opennlp.model.BinaryFileDataReader.readDouble(BinaryFileDataReader.java:53)
at opennlp.model.AbstractModelReader.readDouble(AbstractModelReader.java:75)
at opennlp.model.AbstractModelReader.getParameters(AbstractModelReader.java:146)
at opennlp.perceptron.PerceptronModelReader.constructModel(PerceptronModelReader.java:69)
at opennlp.model.GenericModelReader.constructModel(GenericModelReader.java:59)
at opennlp.model.AbstractModelReader.getModel(AbstractModelReader.java:87)
at opennlp.tools.util.model.GenericModelSerializer.create(GenericModelSerializer.java:35)
at opennlp.tools.util.model.GenericModelSerializer.create(GenericModelSerializer.java:31)
at opennlp.tools.util.model.BaseModel.loadModel(BaseModel.java:231)
at opennlp.tools.util.model.BaseModel.(BaseModel.java:190)
at opennlp.tools.postag.POSModel.(POSModel.java:86)
at nlpcheck.NlpPOC.POSTag(NlpPOC.java:54)
at nlpcheck.NlpPOC.main(NlpPOC.java:86)
我已经尝试加载tokenizaton模型(en-token.bin)并且它的加载和工作正常。 以下是我用来加载模型的java片段:
InputStream is = new FileInputStream(MODEL_PATH);
POSModel model = new POSModel(is);
我从http://www.opennlp.org/models-1.5/下载了模型(en-pos-perceptron.bin,en-pos-maxent.bin)。
答案 0 :(得分:0)
事实证明,上面提到的网站上托管的模型文件已损坏,我正在尝试使用相同模型文件的GATE(文本工程的通用架构),因此我复制它们并将它们放在构建路径上它奏效了。