UnsupportedOperationException

UnsupportedOperationException

本文介绍了斯坦福 NLP - UnsupportedOperationException:参数数组长度不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从这里遵循 How can I train my own NER model 教程:https://nlp.stanford.edu/software/crf-faq.shtml#b

I am trying to follow the How can I train my own NER model tutorial from here: https://nlp.stanford.edu/software/crf-faq.shtml#b

当我运行 test 命令来测试模型性能时:java -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier ner-model.ser.gz -testFile jane-austen-emma-ch2.tsv

When I run the test command to test the model performance:java -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier ner-model.ser.gz -testFile jane-austen-emma-ch2.tsv

我收到以下错误:

Invoked on Thu May 10 15:40:41 IST 2018 with arguments: -loadClassifier ner-model.ser.gz -testFile jane-austen-emma-ch2.tsv
testFile=jane-austen-emma-ch2.tsv
loadClassifier=ner-model.ser.gz
Loading classifier from ner-model.ser.gz ... done [0.2 sec].
Error on line 1: CHAPTER        O
Exception in thread "main" java.lang.UnsupportedOperationException:
Argument array lengths differ: [class edu.stanford.nlp.ling.CoreAnnotations$TextAnnotation, class edu.stanford.nlp.ling.CoreAnnotations$AnswerAnnotation] vs. [CHAPTER, , O]
    at edu.stanford.nlp.ling.CoreLabel.initFromStrings(CoreLabel.java:263)
    at edu.stanford.nlp.ling.CoreLabel.<init>(CoreLabel.java:150)
    ...
    ...
    at edu.stanford.nlp.ie.AbstractSequenceClassifier.classifyAndWriteAnswers(AbstractSequenceClassifier.java:1189)
   at edu.stanford.nlp.ie.AbstractSequenceClassifier.classifyAndWriteAnswers(AbstractSequenceClassifier.java:1133)
   at edu.stanford.nlp.ie.AbstractSequenceClassifier.classifyAndWriteAnswers(AbstractSequenceClassifier.java:1087)
   at edu.stanford.nlp.ie.crf.CRFClassifier.main(CRFClassifier.java:3033)

我使用了提供的训练和测试文件.知道这里出了什么问题吗?

I have used the provided training and test files. Any idea what's going wrong here?

推荐答案

问题是斯坦福网站上提供的 jane-austen-emma-ch2.tsv 文件有一个额外的制表符.一旦我删除了它,它就解决了这个问题.

Well the issue was that the jane-austen-emma-ch2.tsv file provided on Stanford site had an extra tab character. Once I removed that, it fixed the issue.

这篇关于斯坦福 NLP - UnsupportedOperationException:参数数组长度不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 19:26