Natural language time parser

Question:

I’m trying to parse strings containing (natural language) times to hh:mm time objects? For example:

"ten past five"
"quarter to three"
"half past noon"
"15 past 3"
"13:35"
"ten fourteen am"

I’ve looked into Chronic for Ruby and Natty for Java (as well as some other libraries) but both seem to focus on parsing dates. Strings like “ten past five” are not parsed correctly by either.

Does anyone know of a library which suit my needs? Or should I maybe start working on my own parser?

Asked By: Bert

||

Answers:

parsedatetime looks promising. Credit.

Answered By: Achal Dave

I didn’t feel like extending parsedatetime, so I decided to use pyPEG, a parser interpreter framework for Python, to write a dedicated time parser. For whoever’s interested, the first basic version is now finished, and nicely parses Dutch time strings.

Answered By: Bert
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.