waltzofpearls / dateparser

Parse dates in commonly used string formats with Rust.
MIT License
38 stars 8 forks source link

Natural language support #48

Open Nukesor opened 3 months ago

Nukesor commented 3 months ago

Hey @waltzofpearls,

I'm currently using chrono-english, which is a library similar to dateparser. The chrono-english maintainer is pretty inactive though and I was about to rewrite his library, when I stumbled upon your library :grin: .

I like your architectural approach and I wanted to ask you, whether you could imagine to merge a parser for natural language, such as 3 weeks ago, in 2 months and 2 days, friday at 12pm. I'm currently using this for pueue and would really like to continue using this. There's however an issue with chrono-english and some backwards incompatible changes in chrono itself, which lead to compilation errors

My approach for this would be to use pest to create a parser for a well-known syntax. I would create a new module for natural language parsing and a generic trait and a dedicated parser for the english language that implements said trait, so other languages may be added in the future. Those could also be gated behind features.

How do you feel about this? If you think this is worthwhile and that you want to continue maintaining this crate for the forseeable future, I would go ahead and start working on this.

Edit: Current progress: https://github.com/Nukesor/dateparser/tree/natural-language

waltzofpearls commented 3 months ago

Hey @Nukesor, thanks for reaching out and proposing the idea of adding natural language support, then volunteering to work on it.

That's brilliant. I once thought about that at some point, especially when I saw python's dateparser lib, which supports parsing relative dates like what you described.

I like your proposed approach: using a separate module, building the parser with pest, using a trait for extensibility, and possibly using the features gate.

Feel free to go ahead and make a changeset for your feature. This repo is still being maintained. It's not hyperactive at the moment, but I always want to focus back on this and iterate on the parsing mechanism to optimize for speed.

Nukesor commented 1 month ago

Heyo @waltzofpearls .

Turns out, there's a pretty nice and maintained drop-in replacement for chrono-english around named interim.

So, I won't work on this any longer as it perfectly fits my own needs for now :)

Feel free to close this issue. However, if you're still interested in such functionality, you could think about just using interim as well^^