1

when I use this code for extracting the date

dateutil.parser.parse('today is 21 jan 2016')

It throws an error -> ValueError: unknown string format

is there any way to extract dates and time from a sentence???

K Akhil
  • 27
  • 6
  • Possible duplicate of [Extracting date from a string in Python](http://stackoverflow.com/questions/3276180/extracting-date-from-a-string-in-python) – LinkBerest Dec 24 '16 at 05:07

1 Answers1

1

There is! (Python is amazing)

dateutil.parser.parse("today is 21 jan 2016", fuzzy=True)

S van Balen
  • 288
  • 2
  • 11
  • Thank You sir, but I want to extract multile dates such as here in this string – K Akhil Dec 28 '16 at 04:42
  • import dateutil.parser as dparser print(dparser.parse("today is 21 jan 2016 and tomarrow is 22 jan 2016", fuzzy=True)) – K Akhil Dec 28 '16 at 04:42
  • Dateurl.parser is gonna help you parse a sentence fragment containing a date. Your next problem is to find those fragments from a text, a more complicated problem called (named) entity recognition. You might find answers to that question here: http://stackoverflow.com/questions/10340540/using-the-nltk-to-recognise-dates-as-named-entities and here: http://stackoverflow.com/questions/19994396/best-way-to-identify-and-extract-dates-from-text-python – S van Balen Dec 28 '16 at 08:51