2017-03-08 3 views
0

코어 -nlp에서 'SUTime'기능을 사용하려고했습니다. 내가하려고 할 때,코어 -nlp의 SUTime Timex3 값이 GUI 출력과 다릅니다

<TIMEX3 range="(2017-02-01,2017-02-28,P1M)" tid="t1" type="DATE" value="2017-02">next month</TIMEX3> 

을하지만 (: 2017년 1월 1일를 참조 날짜) 나는 'sampleInput'결과

From next month, we will have meeting on every friday, from 3:00 pm to 4:00 pm.” 

의 온라인 데모에서 이것을 사용하려고하면

List<CoreMap> timexAnnsAll = document.get(TimeAnnotations.TimexAnnotations.class); 
       for (CoreMap cm : timexAnnsAll) { 
        try { 
         List<CoreLabel> tokens = cm.get(CoreAnnotations.TokensAnnotation.class); 

         Temporal temporal = cm.get(TimeExpression.Annotation.class).getTemporal(); 


         System.out.println("Token text : " + cm.toString()); 
         System.out.println("Temporal Value : " + temporal.toString()); 
         System.out.println("Timex : " + temporal.getTimexValue()); 
         System.out.println("Timex type : " + temporal.getTimexType().name()); 
: 아래
<Token text="next month" Temporal Value="THIS P1M OFFSET P1M" Timex="null" Timex type="DATE" Start offset="5" End Offset="15" /> 

코드입니다 : ('임시 값'ESP) SUTime API를 통해 동일한 입력을 실행, 그것은 결과

답변

0

문제는 문서 날짜가 설정되어 있지 않다는 것입니다.

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("From next month, we will have meeting on every friday, from 3:00 pm to 4:00 pm."); 
    document.set(CoreAnnotations.DocDateAnnotation.class, "2017-03-01"); 
    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); 
     System.out.println(entityMention.get(TimeAnnotations.TimexAnnotation.class)); 
     } 
    } 
    } 
}