在OpenNLP 1.5.3中加载英文NER的位置模型

时间:2014-07-30 11:19:35

标签: java nlp opennlp

我正在使用 OpenNLP 1.5.3 ,我想在英文文本中为位置名称执行NER。为此,我从下一个URL下载了相应的模型(en-ner-location.bin):

http://opennlp.sourceforge.net/models-1.5/

问题在于,当我尝试使用此模型使用以下命令在文本中执行NER时:

./Opennlp/bin/opennlp TokenNameFinder en-ner-location.bin < Text.txt > Text.txt.ner_en_loc

我收到以下错误:

Loading Token Name Finder model ... failed
IO error while loading model file 'en-ner-location.bin'
Unexpected end of ZLIB input stream
java.io.EOFException: Unexpected end of ZLIB input stream
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:193)
    at java.io.DataInputStream.readFully(DataInputStream.java:195)
    at java.io.DataInputStream.readLong(DataInputStream.java:416)
    at java.io.DataInputStream.readDouble(DataInputStream.java:468)
    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.maxent.io.GISModelReader.constructModel(GISModelReader.java:75)
    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.<init>(BaseModel.java:181)
    at opennlp.tools.namefind.TokenNameFinderModel.<init>(TokenNameFinderModel.java:110)
    at opennlp.tools.cmdline.namefind.TokenNameFinderModelLoader.loadModel(TokenNameFinderModelLoader.java:41)
    at opennlp.tools.cmdline.namefind.TokenNameFinderModelLoader.loadModel(TokenNameFinderModelLoader.java:32)
    at opennlp.tools.cmdline.ModelLoader.load(ModelLoader.java:62)
    at opennlp.tools.cmdline.namefind.TokenNameFinderTool.run(TokenNameFinderTool.java:59)
    at opennlp.tools.cmdline.CLI.main(CLI.java:225)

我的命令是否有问题,或者这是OpenNLP 1.5.3中此模型的错误?

1 个答案:

答案 0 :(得分:0)

文件已损坏。我再次下载它,一切正常。