neilgupta / Sherlock

Natural-language event parser for Javascript
https://sherlock.neil.gg
MIT License
532 stars 32 forks source link

Allow for general time related terms (ex: lunch time) #22

Closed Olian04 closed 6 years ago

Olian04 commented 7 years ago

Try to enter There will be a meeting tomorrow after lunch on the demo page

neilgupta commented 7 years ago

Ah, right now it’s interpreting the time as “after tomorrow.” What would be the expected output of this sentence? We could alias “lunch” to 12pm, but “after lunch” would still be any range from 8/17/2017 12pm - 1/1/3000 12am without an end time. Similarly, “before lunch” would give us an end time but no start time, so I don’t see that being very helpful. Another problem is that the standard time for breakfast, lunch, and dinner could vary a lot between people and cultures, I’m not sure.

Having said that, it’s fairly trivial to alias breakfast to 9am, lunch to 12pm, and dinner to 6pm if that solves your problem.

Olian04 commented 7 years ago

How about if there isn't a defined time span, the duration is set to 0? Aka: After lunch would result in a start time of 12 o'clock and an end time of 12 o'clock.

neilgupta commented 6 years ago

This effectively makes lunch an alias for noon. I'd rather not hardcode that into Sherlock because meal times are often culture-specific, but this could easily be added via Watson's preprocessor. Something like the following code should get what you want:

preprocess: function(str) {
    str = str.replace('lunch', '12pm');
    str = str.replace('dinner', '6pm');
    return [str, {}];
}
neilgupta commented 6 years ago

Closing this issue since I think Watson solves the problem sufficiently. Let me know if you disagree!