斯坦福NER正在运行

时间:2015-03-10 23:22:42

标签: java stanford-nlp

我正在使用Stanford-NER,当我使用它的演示或@ChristopherManning提供的序列化代码时,我收到以下错误:

import edu.stanford.nlp.ie.NERClassifierCombiner;
import edu.stanford.nlp.io.IOUtils;
import edu.stanford.nlp.ling.CoreLabel;
import java.io.IOException;
import java.util.List;

public class Ner {

  public static void main(String[] args) throws IOException {
    String serializedClassifier = "/local/stanford-ner-2015-01-30/classifiers/english.all.3class.distsim.crf.ser.gz";
    String serializedClassifier2 = "/local/stanford-ner-2015-01-30/classifiers/english.muc.7class.distsim.crf.ser.gz";

    if (args.length > 0) {
      serializedClassifier = args[0];
    }

    NERClassifierCombiner classifier = new NERClassifierCombiner(false, false, 
            serializedClassifier, serializedClassifier2);

    String fileContents = IOUtils.slurpFile("input.txt");
    List<List<CoreLabel>> out = classifier.classify(fileContents);

    int i = 0;
    for (List<CoreLabel> lcl : out) {
      i++;
      int j = 0;
      for (CoreLabel cl : lcl) {
        j++;
        System.out.printf("%d:%d: %s%n", i, j,
                cl.toShorterString("Text", "CharacterOffsetBegin", "CharacterOffsetEnd", "NamedEntityTag"));
      }
    }
  }

}

错误是:

 java.lang.ClassCastException: java.util.ArrayList cannot be cast to      [Ledu.stanford.nlp.util.Index

0 个答案:

没有答案