matthewmueller / date

Date() for humans
http://matthewmueller.github.io/date/
1.48k stars 88 forks source link

NLP fix #2: arithmetics support, complete CFG features (suppressed now) #78

Closed kengz closed 8 years ago

kengz commented 8 years ago

This fixes issues #70 , #62 , #21

I've removed all lodash dependencies, and wrote my own under subdash.

Also I've finished the CFG implementation, which I call the Human Language for Time. I plan to attach the mathematical proof on the arithmetics and theories behind it soon.

This PR doesn't fix as many problems since there's still several small but pesky issues to resolve, which basically are the inconsistencies between my CFG and the original datejs.

For example, 'tomorrow' will be treated as the next day, defaulted to 9am. Also, I have to implement leap year, and proper carries for days across different months, as they have different number of days.

That's it for now!

kengz commented 8 years ago

@matthewmueller Owh forgot to mentioned one thing, it can also take any extra string in a natural sentence, and extract the time. For example if the input string is remind me to do laundry 2 hours later, it will automatically extract the substring with time.

For this, the CFG is suppressed as I mentioned, so what it does it do some preprocessing on the string (extract 2 hours later), and pass it to the original datejs parser.

Moreover, it can parse normal forms of date string, and e.g. '13 May 2011 01:30 UTC'.

The time extraction from arbitrary sentence is a pretty handle feature I think.

matthewmueller commented 8 years ago

ahh sorry to leave you hanging on this @kengz! this looks great. thanks for your hard work. i'm going to merge this. let me know if you want me to release or if there's more to come before i should release.

regarding:

basically are the inconsistencies between my CFG and the original datejs.

i'm not sure if this is helpful or not, but i think it's usually pretty obvious what the date should be when you think about it, like "tomorrow morning" => some where around 9 or 10 the next day. so i wouldn't worry so much about breaking tests or existing implementation if you think the result will be more expected for folks.

kengz commented 8 years ago

I'll work on it a lil today, but my guess is the next update won't come through until at least next week. I'll let u know tonight if I can finish it? Otherwise assume I can't.

matthewmueller commented 8 years ago

sure, no rush. loving these fixes :-)

matthewmueller commented 7 years ago

hey @kengz, what's the state of this?

kengz commented 7 years ago

oh shoot, my github graph wasn't green for a long time, until recently. Nice timing.

Let's see what's left from last time: