21 Jan 10" />
开发者

parsing a text string for dates - not the standard convert problem!

开发者 https://www.devze.com 2022-12-18 04:11 出处:网络
Does anyone know of a library - ideally Python, that can have a stab at pulling dates out of text? \"Shall we go to the library today\"-> 21 Jan 10

Does anyone know of a library - ideally Python, that can have a stab at pulling dates out of text?

"Shall we go to the library today" -> 21 Jan 10 "Starting on the 1st of January" -> 1 Jan 1开发者_如何学C0 "Anytime between 3nd and 5th of Feb 2009" -> 3 Feb 09, 5 Feb 09

It's a tough problem and probably why I havn't found anything! Already using NLTK by the way if that helps.


Looks like this module is what you are looking for: parsedatetime


The PyParsing site has a little bonus script for parsing time expressions. I would say that is worth a look for you!

Edit: I see you already ended up there as I was typing my suggestion. Good luck to you!


Thanks for the contributions - in the end I followed up one of the comments, that led to pyparsing, which led to the beginnings of a solution. many thanks all.

Have posted the work in progress, two pyparsing snippets of code here http://pbjots.blogspot.com/2010/01/using-pyparsing-to-extract-dates-from.html in case they help anyone.

0

精彩评论

暂无评论...
验证码 换一张
取 消