1

When I use SUTime's API, I provide text and receive a list of CoreMap objects, each detailing the attributes of a time expression in the text. I wish to take such a CoreMap and convert it into a Date or Calendar object, for easier handling and manipulations.

Is there any such method in the SUTime API? Anywhere else for that matter?

Is there a reverse method for building a CoreMap out of a Date or Calendar object?

Yuval
  • 7,987
  • 12
  • 40
  • 54

1 Answers1

1

To get a Calendar object out of a CoreMap cm extracted by SUTime, you can try:

Calendar calendar = cm.get(TimeAnnotations.TimexAnnotation.class).getDate(); (see https://github.com/stanfordnlp/CoreNLP/blob/master/src/edu/stanford/nlp/time/Timex.java)

Note that not all time expressions recognized by SUTime will resolve to a point in time or a Calendar object (so there maybe some exceptions).

Angel Chang
  • 364
  • 1
  • 1