Stanford NER Tagger中序列预测的置信度。这是可能的?给定预测序列的可信度。
答案 0 :(得分:1)
这里有一些代码可以打印出k个(在示例10中)最可能的序列,并可以打印出序列概率。
import edu.stanford.nlp.ie.AbstractSequenceClassifier;
import edu.stanford.nlp.ie.crf.*;
import edu.stanford.nlp.io.IOUtils;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.sequences.DocumentReaderAndWriter;
import edu.stanford.nlp.util.Triple;
import java.io.*;
import java.util.List;
public class GetCRFProbsDemo {
public static void main(String[] args) throws ClassNotFoundException, IOException {
String serializedClassifier = "edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz";
AbstractSequenceClassifier<CoreLabel> classifier = CRFClassifier.getClassifier(serializedClassifier);
System.out.println("---");
System.out.println("Ten best entity labelings");
DocumentReaderAndWriter<CoreLabel> readerAndWriter = classifier.makePlainTextReaderAndWriter();
classifier.classifyAndWriteAnswersKBest(args[0], 10, readerAndWriter);
}
}