2017-02-24 3 views
0

TokenizerAnnotator, WordsToSentencesAnnotator, POSTaggerAnnotator 및 sutime을 사용하여 AnnotationPipeline을 만드는 경우 결과 주석에 TimexAnnotations가 첨부됩니다.StanfordCoreNLP 파이프 라인을 사용하는 날짜

"annotators"속성이 "tokenize, ssplit, pos, lemma, ner"로 설정된 StanfordCoreNLP 파이프 라인을 만드는 경우 관련 개별 ​​토큰이 DATE와 같이 NER 태그가 붙더라도 TimexAnnotations를 얻지 못합니다.

왜 이러한 차이가 있습니까? 내가이 명령을 실행하면

답변

0

는 :

java -Xmx8g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner -file data-example.txt -outputFormat text 

을 나는 날짜에 대한 TIMEX 주석을 얻는다. ner 어노 테이터는 기본적으로 SUTime을 적용해야합니다.

+0

토큰에 NamedEntityTag = DATE이 (가) 있으므로 Ner annotator는 확실히 SUTime을 적용하고 있습니다. 그러나 pipeline.annotate에서 반환 된 주석에는 TimexAnnotations가 없습니다. –

+0

명시 적으로 다음 코드는 null을 인쇄합니다. 속성 props = new Properties(); props.setProperty ("annotators", "tokenize, ssplit, pos, lemma, ner"); AnnotationPipeline pipeline = new StanfordCoreNLP (소품); 주석 주석 = 새 주석 ("날짜는 2017 년 4 월 1 일"); pipeline.annotate (annotation); System.out.println (annotation.get (TimeAnnotations.TimexAnnotations.class)); –

0

주석을 실행할 때 문서에서 모든 엔티티 멘션을 추출하고 DATE를 엔티티 언급으로 간주합니다. 다음은 몇 가지 샘플 코드입니다. 시간 표현식을 추출하고 TimexAnnotations.class 필드를 채우려는 경우 주석 처리 된 옵션을 추가했습니다.

package edu.stanford.nlp.examples; 

import edu.stanford.nlp.ling.*; 
import edu.stanford.nlp.util.*; 
import edu.stanford.nlp.time.TimeAnnotations; 

import edu.stanford.nlp.pipeline.*; 

import java.util.*; 

public class SUTimeExample { 

    public static void main(String[] args) { 
    Annotation document = 
     new Annotation("The date is 1 April 2017"); 
    Properties props = new Properties(); 
    //props.setProperty("customAnnotatorClass.time", "edu.stanford.nlp.time.TimeAnnotator"); 
    //props.setProperty("annotators", "tokenize,ssplit,pos,lemma,time"); 
    props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,entitymentions"); 
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props); 
    pipeline.annotate(document); 
    for (CoreMap entityMention : document.get(CoreAnnotations.MentionsAnnotation.class)) { 
     if (entityMention.get(CoreAnnotations.EntityTypeAnnotation.class).equals("DATE")) 
     System.out.println(entityMention); 
    } 
    } 
} 
관련 문제