我正在尝试按照此处的How can I train my own NER model
教程: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
我收到以下错误:
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)
我使用了提供的培训和测试文件。知道这里出了什么问题吗?
答案 0 :(得分:0)
问题是斯坦福网站上提供的jane-austen-emma-ch2.tsv
文件有一个额外的制表符。删除后,它解决了问题。