在Stanford CoreNLP中添加新的注释器

我正在尝试根据http://nlp.stanford.edu/downloads/corenlp.shtml中的说明在Stanford CoreNLP中添加一个新的注释器。

“添加新的注释器StanfordCoreNLP还能够通过reflection添加新的注释器而无需更改StanfordCoreNLP.java的代码。要创建新的注释器,请扩展类edu.stanford.nlp.pipeline.Annotator并使用以下方法定义构造函数。 signature(String,Properties)。然后,将属性customAnnotatorClass。FOO FOO=BAR到用于创建管道的属性。如果FOO随后被添加到注释器列表中,将创建类BAR,其名称用于创建它和传入的属性文件。“

我已经为我的新注释器创建了一个新类,但我不能放入传入的属性文件。我只将新的注释器放在管道中。

 props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref, regexner, color"); props.setProperty("customAnnotatorClass.color", "myPackage.myPipeline"); 

有没有示例代码可以帮助我?

如果你愿意,你可以拥有我的。 有趣的东西从// adding our own annotator property

 /** Annotates a document with our customized pipeline. * @param text A text to process * @return The annotated text */ private Annotation annotateText(String text) { Annotation doc = new Annotation(text); StanfordCoreNLP pipeline; // creates a StanfordCoreNLP object, with POS tagging, lemmatization, // NER, parsing, and coreference resolution Properties props = new Properties(); // alternative: wsj-bidirectional try { props.put( "pos.model", "edu/stanford/nlp/models/pos-tagger/wsj-bidirectional/wsj-0-18-bidirectional-distsim.tagger"); } catch (Exception e) { e.printStackTrace(); } // adding our own annotator property props.put("customAnnotatorClass.sdclassifier", "edu.kit.ipd.alicenlp.ivan.analyzers.StaticDynamicClassifier"); // configure pipeline props.put( "annotators", "tokenize, ssplit, pos, lemma, ner, parse, sdclassifier"); pipeline = new StanfordCoreNLP(props); pipeline.annotate(doc); return doc; }