2017-03-08 4 views
0

core-nlpの 'SUTime'機能を使用しようとしていました。私がしようとすると、core-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.” 

のためのオンラインデモからこれを使用しようとすると以下は

<Token text="next month" Temporal Value="THIS P1M OFFSET P1M" Timex="null" Timex type="DATE" Start offset="5" End Offset="15" /> 

コードです( '一時的な値' ESP):

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()); 
0123それは、その結果、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)); 
     } 
    } 
    } 
} 
関連する問題