Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Natural language generator for dates (Java)

Tags:

java

date

nlp

I'm building a system that needs to provide a commentary on things in natural English. One thing that is of use is to be able to express dates in a casual format. What I'm looking for is essentially the inverse of Chronic, Natty, or the task described in this question: Natural Language date and time parser for java.

Is this too out-there to have been done? Should I try and roll my own simple hardwired piece for the date ranges that make sense to me? Or is there some clever way to reverse existing parsers to spit out (even garbled) sentences describing dates?

EDIT - To clarify, although any kind of output is interesting and useful, I'm particularly interested in varied/creative output generation. i.e. "Next week", "seven days from now", "next Thursday" and "late next week" all for the same date.

like image 271
mtrc Avatar asked May 02 '12 18:05

mtrc


1 Answers

There isn't much out there. Personally I'd love to see a variant of SimpleDateFormatter called RelativeDateFormatter that would let one create their own variations of relative date formats. Here is what I found:

  • A simple Relative Date class.
  • A relative date formatter (so someone did make one already!).
  • Pretty time also looks like it fits the bill - and its in a maven repo somewhere, if thats something you find desirable...

Just an aside, I noticed this post about why relative date formats suck. Providing only relative dates can be a mistake: if the information is going to be saved at a later date, the relative date could be useless. In a website I made I provided a mouseover with the absolute date, and CSS rules to print the absolute date. I guess the thing to keep in mind: consider how/when the dates will be viewed. If they're anything other than "NOW" then you might want to consider including the absolute date as well.

like image 141
dsummersl Avatar answered Oct 04 '22 09:10

dsummersl