在斯坦福CoreNLP添加一个新的注释 [英] Adding a new annotator in Stanford CoreNLP

查看:234
本文介绍了在斯坦福CoreNLP添加一个新的注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图按照 HTTP的说明斯坦福CoreNLP添加一个新的注释:// nlp.stanford.edu/downloads/corenlp.shtml

添加新的注释
StanfordCoreNLP 也有反射而不会改变在 StanfordCoreNLP.java 的code以添加新的标注的能力。要创建一个新的注释,扩展该类edu.stanford.nlp.pipeline.Annotator并定义签名(字符串,属性)构造函数。接着,添加属性customAnnotatorClass。 FOO = BAR 来用于创建管道的属性。如果FOO然后加入注解的列表,类BAR将被创建,名称为用来创建它和属性文件传递。

"Adding a new annotator StanfordCoreNLP also has the capacity to add a new annotator by reflection without altering the code in StanfordCoreNLP.java. To create a new annotator, extend the class edu.stanford.nlp.pipeline.Annotator and define a constructor with the signature (String, Properties). Then, add the property customAnnotatorClass.FOO=BAR to the properties used to create the pipeline. If FOO is then added to the list of annotators, the class BAR will be created, with the name used to create it and the properties file passed in. "

我已经创建了我的新标注一个新的类,但我不能把属性文件,将通过英寸
我只把新的注释酝酿中。

I have created a new class for my new annotator, but i cannot put the properties file that would pass in. I have only put the new annotator in the pipeline.

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

有没有例如code来帮助我?

Is there any example code to help me?

推荐答案

您可以有我的,如果你喜欢。有趣的东西开始于 //添加自己的注释财产

You can have mine, if you like. The interesting stuff starts at // 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;
}

这篇关于在斯坦福CoreNLP添加一个新的注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆