何博士您好,
我在进行实体识别,调用已经训练好的分词器模型、词性标注模型时候,报NullPointerException。
我浏览了github相关issue何论坛,进行了可能解决方案的试错,但是不理想。后来我跟源码,发现LinearModel类中的ByteArray经过处理后的大小没有最终的特征权重parameter的元素多,导致的后边继续获取元素为空。。。。。。我觉得我没找到问题的根本原因,所以特来请教,麻烦您了。
下边是我的代码:
以下是异常信息:
Exception in thread “main” java.lang.NullPointerException
at com.hankcs.hanlp.corpus.io.ByteArrayFileStream.ensureAvailableBytes(ByteArrayFileStream.java:82)
at com.hankcs.hanlp.corpus.io.ByteArrayStream.nextInt(ByteArrayStream.java:56)
at com.hankcs.hanlp.model.perceptron.feature.FeatureMap.loadTagSet(FeatureMap.java:99)
at com.hankcs.hanlp.model.perceptron.feature.ImmutableFeatureMDatMap.load(ImmutableFeatureMDatMap.java:92)
at com.hankcs.hanlp.model.perceptron.model.LinearModel.load(LinearModel.java:421)
at com.hankcs.hanlp.model.crf.LogLinearModel.load(LogLinearModel.java:58)
at com.hankcs.hanlp.model.perceptron.model.LinearModel.load(LinearModel.java:388)
at com.hankcs.hanlp.model.crf.LogLinearModel.(LogLinearModel.java:83)
at com.hankcs.hanlp.model.crf.CRFTagger.(CRFTagger.java:41)
at com.hankcs.hanlp.model.crf.CRFSegmenter.(CRFSegmenter.java:47)
at com.wf.ner.Demo.loadCrfModel(Demo.java:80)
at com.wf.ner.Demo.main(Demo.java:51)
Process finished with exit code 1