iainbeeston / nickel

Nickel extracts date, time, and message information from naturally worded text.
MIT License
112 stars 17 forks source link

Parse duration #28

Open pie6k opened 9 years ago

pie6k commented 9 years ago

Is there any way to enable Nickel to understand something like

"Run with John next Friday at 5pm for 1 hour"

If no - any tips how it would be possible to add such feature as your code is a "little" over my head :)

jcutrell commented 9 years ago

I'd also like to see Nickel support duration. The chronic_duration gem does this decently well. Part of the issue I'm seeing is that if I say "for 30 minutes", Nickel parses that 30 as a day of the month, so Nickel's dates are incorrectly returning two dates. Perhaps there can be a confidence metric associated with the Nickel ZDate object? It would make sense to use the chronic_duration gem WITH Nickel if Nickel did not incorrectly parse the number as the day of the month.

jcutrell commented 9 years ago

In another scenario, Nickel parses the duration as the "start time":

n = Nickel.parse "I did 20 minutes of yoga today"
 => message: "I did minutes of yoga", occurrences: [#<Occurrence type: single, start_date: 20150824, start_time: 200000>]

Note that the start date is correct; start_time is showing up as 200000, which I'm not entirely sure of the meaning.