Skip to content

Easy dates parser that leverages on the power of n-gramify & http://www.datejs.com to parse dates that other parsers would fail. The concept is simple, instead on Regex, tokenize string into 'reducing ngrams' & extract!

mugendi/parse-dates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extract dates from text

Easy dates parser that leverages on the power of n-gramify, datejs & dehumanize-date to parse dates that other parsers would fail.

The concept is simple, instead on Regex, we tokenize the string into 'reducing ngrams' & then extract dates!

datejs does the initial parsing & then we use dehumanize-date to confirm parsed tokens & format them.

var parse_date = require ( 'parse-dates' )

var s=" Peter was born in 5th january 1994 will be 44 years old next week. "
var parsed=parse_date(s)

console.log(JSON.stringify(parsed,0,4));

Output:

{
    "dates": [
        "1994-01-05T00:00:00.000Z"
    ],
    "string": {
        "in": " Peter was born in 5th january 1994 and will be 44 years old next week. ",
        "out": " Peter was born in 1994-01-05T00:00:00.000Z and will be 44 years old next week. ",
        "annotated": " Peter was born in {DATE: 1994-01-05T00:00:00.000Z} and will be 44 years old next week. "
    }
}                                                

About

Easy dates parser that leverages on the power of n-gramify & http://www.datejs.com to parse dates that other parsers would fail. The concept is simple, instead on Regex, tokenize string into 'reducing ngrams' & extract!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published