3 ms·
Almost every data exploration tool requires a date range to work, and yet there's no standard language for expressing these. I want a parser that: - Undertands
by CGamesPlay 5y ago
Almost every data exploration tool requires a date range to work, and yet there's no standard language for expressing these. I want a parser that:
- Undertands simple ranges (e.g. "2022-04-01 to 2022-05-01").
- Understands relative ranges (e.g. "4 weeks ago to 2 weeks from now").
- Understands ranges to be expressed by omitting components (e.g. "2022" means "2022-01-01 to 2022-12-31").
- Has equivalent parsers for other human languages (e.g. switch to 'es_ES' and parse "hace 2 semanas").
The implementation of this would be programming-language specific, but the grammar of this language isn't even standardized, as far as I know.
- Lanzaa 4y agoSomething could be based on the "Rosie Pattern Language"[0]. There is already a parser for en_US/en_EU dates[1], which should be simple to extend to date ranges. Another option would be using Tree-sitter[2]. It would be overall similar to using the Rosie Pattern Language, but Tree-sitter seems to have a more active community. I wouldn't be surprised if one could write an automated Tree-sitter to Rosie Pattern Language translator. [0]: https://gitlab.com/rosie-pattern-language/rosie/-/blob/master/doc/raisondetre.md https://gitlab.com/rosie-pattern-language/rosie/-/blob/maste... [1]: https://gitlab.com/rosie-pattern-language/rosie/blob/master/rpl/date.rpl https://gitlab.com/rosie-pattern-language/rosie/blob/master/... [2]: https://tree-sitter.github.io/tree-sitter/ https://tree-sitter.github.io/tree-sitter/
- deleted 5y ago[deleted]
- teknopaul 5y agoI believe that iso dates officially support missing off any component so points 1 and 3 should be supported by any date parser. Time parsing from all natural language is going to be hard/impossible because there is so much jargon/ambiguity. How long is a jiffy? Is a moment a point in time or a short while in the future? Mañana has two meanings in Spanish.
- CGamesPlay 5y agoI'm looking for a rigid, localized, natural-language specification for time ranges, though. Not supporting some words or combinations of them is fine, as long as it's natural enough that a nontechnical user doesn't need to use a manual to figure out how to search dates. I'm sure this isn't a trivial problem, hence why there are no obvious solutions, but I'm not ready to believe that it's impossible.
- teknopaul 5y agoAnd of course SQL is a relevant standard, even if you don't implement all of it. BETWEEN Date1 AND Date2 is in the spec.