naturaltime
A simple natural language time parser for node.js using a naive bayesian classifier.
installation
npm install naturaltime
usage
var naturaltime = ; var five_minutes_ago = ;var in_five_minutes = ;var a_year_ago = ; // specify the start datevar a_year_and_a_week_ago = ; // create a parservar parser = naturaltime;var parsed = parser;// => {units: 'weeks', amount: 2, relative: 'past'}var date = parser;
limitations
- the string you give
naturaltime
must have a decimal number in it - number matching is naive - if there are two numbers in your string, the first one will be extracted and used, not necessarily correct. So, just give us one number
naturaltime
is not guaranteed to do things right. If you find a case that doesn't work like you expect, open an issue or fork the repo and fix it :)
internationalization
naturaltime
currently only understands US English. All that is needed for
more language support is a training set for each new language. If you know a
foreign language, please fork this repo and add it!