akoumjian / datefinder

Find dates inside text using Python and get back datetime objects
http://datefinder.readthedocs.org/en/latest/
MIT License
634 stars 166 forks source link

Problems with strict parameter when set to True #127

Open juancotrino opened 4 years ago

juancotrino commented 4 years ago

Hello. I'm trying to use this function 'datefinder.find_dates("P_CHIRPS.v2.0_mm-day-1_daily_2020.01.28.tif", source=True, strict=True)', the parameter strict is set to True cause otherwise the function will consider the '2.0' as a date (tried setting strict=False), but with strict=True I get nothing. Thanks for the help.

alwhelan22 commented 3 years ago

Same. strict=True is returning nothing

hmoravec commented 3 years ago

PR https://github.com/akoumjian/datefinder/pull/109 should fix this.

hmoravec commented 3 years ago

I ended up using dateparser library where the strict parsing works as expected.

alwhelan22 commented 3 years ago

The dateparser library doesn't work with full strings such as My birthday is August 12, 1994, where this does. I just want to be able to use the strict parameter correctly

hmoravec commented 3 years ago

@alwhelan22 dateparser works with full strings.

alwhelan22 commented 3 years ago

But it picks up false positives as well:

from dateparser.search import search_dates

search_dates("My birthday is August 12 1994, and then hers in 6 months", settings={'STRICT_PARSING': True})
[('August 12 1994, and', datetime.datetime(1994, 8, 12, 0, 0)),
 ('in 6 months', datetime.datetime(1995, 2, 12, 0, 0))]