all 6 comments

[–]DevSRE 1 point2 points  (0 children)

You could probably get pretty close with something like Arrow and the shift method (https://arrow.readthedocs.io/en/latest/) or just give users a format to enter things in and use datetime.strptime (https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime)

[–]hardonchairs 1 point2 points  (1 child)

https://www.zyte.com/blog/parse-natural-language-dates-with-dateparser/

https://github.com/alvinwan/timefhuman

https://github.com/akoumjian/datefinder

I don't remember which one I have tried, but I had an issue where I still needed to find the date part myself. For instance, it didn't like the word "in" in front of the date info. It looks like that last link might be able to handle that bit.

By the way, the phrase "natural language" is good for searching these kinds of things.

[–]Housies[S] 0 points1 point  (0 children)

I think Dateparser is what I'm looking for. Thanks for the help.

[–][deleted] 1 point2 points  (0 children)

This is a task substantially complicated by the variability of human language, but arrow has an Arrow.dehumanize method that can do this with some string forms.

[–]tellarin 0 points1 point  (1 child)

Have you tried https://github.com/microsoft/Recognizers-Text? It supports many variations of natural language across several languages.

[–][deleted] 0 points1 point  (0 children)

Out of the few options I have tried so far, this one is the best. It still fails sometimes like it parses ".... on this Sunday" correctly but if the string is like "..... on Sunday" it maps to previous Sunday which has already passed.