2013-11-09 2 views
0

http://nlp.stanford.edu/downloads/corenlp.shtml의 지침에 따라 스탠포드 CoreNLP에 새 주석자를 추가하려고합니다.스탠포드 CoreNLP에 새 주석 자 추가

"또한 StanfordCoreNLP.java의 코드를 변경하지 않고 반사하여 새 주석 자를 추가 할 수있는 능력을 가지고 StanfordCoreNLP 새로운 주석 자 추가. 새로운 주석 자를 만들 클래스 edu.stanford.nlp.pipeline.Annotator을 확장하고을 정의하려면 생성자를 서명 (String, Properties)으로 변환 한 다음 customAnnotatorClass. FOO=BAR 속성을 파이프 라인을 만드는 데 사용 된 속성에 추가합니다. 그러면 FOO가 어노 테이터 목록에 추가되면 BAR 클래스가 만들어집니다. 만들고 속성 파일을 전달하십시오. "

새 어노 테이터에 대한 새 클래스를 만들었지 만 전달할 속성 파일을 넣을 수 없습니다. 새로운 주석 자만 파이프 라인에 넣었습니다.

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

도와 주실만한 예제 코드가 있습니까?

답변

2

원한다면 광산을 소유 할 수 있습니다. 흥미로운 내용은 // 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; 
} 
+0

어노 테이터를 어떻게 만들었습니까? – Tariq

+0

Stanford CoreNLP에 대한 사용자 정의 어노 테이터를 만드는 과정/단계를 자세히 설명해 주시겠습니까? 감사합니다 – Tariq

+0

4 년 전에 저에게 물어 본 적이 있다면 도움을 줄 수 있었을 것입니다. 하지만 내 코드는 여전히 온라인 상태입니다. https://svn.ipd.kit.edu/trac/AliceNLP/browser/ivan/trunk/src/main/java/edu/kit/ipd/alicenlp/ivan/analyzers/StaticDynamicClassifier를 확인하고 싶을 것입니다. 자바 –