1   import edu.stanford.nlp.ling.CoreAnnotations;
2   import edu.stanford.nlp.ling.CoreLabel;
3   import edu.stanford.nlp.pipeline.Annotation;
4   import edu.stanford.nlp.pipeline.StanfordCoreNLP;
5   import edu.stanford.nlp.semgraph.SemanticGraph;
6   import edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations;
7   import edu.stanford.nlp.util.CoreMap;
8   import eu.fbk.dh.tint.verb.VerbAnnotations;
9   import eu.fbk.fcw.udpipe.api.UDPipeAnnotations;
10  import eu.fbk.utils.corenlp.outputters.JSONOutputter;
11  import org.slf4j.Logger;
12  import org.slf4j.LoggerFactory;
13  
14  import java.util.Properties;
15  
16  /**
17   * Created by alessio on 21/04/17.
18   */
19  
20  public class VerbTest {
21  
22      private static final Logger LOGGER = LoggerFactory.getLogger(VerbTest.class);
23  
24      public static void main(String[] args) {
25          try {
26              Properties properties = new Properties();
27              properties.setProperty("annotators", "ita_toksent, udpipe, ita_verb");
28              properties.setProperty("customAnnotatorClass.udpipe", "eu.fbk.fcw.udpipe.api.UDPipeAnnotator");
29              properties.setProperty("customAnnotatorClass.ita_toksent",
30                      "eu.fbk.dh.tint.tokenizer.annotators.ItalianTokenizerAnnotator");
31              properties.setProperty("customAnnotatorClass.ita_verb",
32                      "eu.fbk.dh.tint.verb.VerbAnnotator");
33  
34              properties.setProperty("udpipe.server", "gardner");
35              properties.setProperty("udpipe.port", "50020");
36              properties.setProperty("udpipe.keepOriginal", "1");
37  
38  //        properties.setProperty("udpipe.model", "/Users/alessio/Desktop/model");
39              StanfordCoreNLP pipeline = new StanfordCoreNLP(properties);
40  
41              Annotation annotation = new Annotation("Il caporale alpino Giampietro Civati caduto in combattimento il 5 dicembre 1944, come racconta Silvestri, ha scritto questo mirabile testamento: «sono figlio d’Italia, d’anni 21, non di Graziani e nemmeno di Badoglio, ma sono italiano e seguo la via che salverà l’onore d’Italia».");
42              pipeline.annotate(annotation);
43              String out = JSONOutputter.jsonPrint(annotation);
44              System.out.println(out);
45  //            for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
46  //                System.out.println(sentence.get(VerbAnnotations.VerbsAnnotation.class));
47  //            }
48  
49          } catch (Exception e) {
50              e.printStackTrace();
51          }
52      }
53  }