comtravo / ctparse

Parse natural language time expressions in python
https://www.comtravo.com
MIT License
131 stars 23 forks source link

Month and Year not joined #86

Closed sebastianmika closed 2 years ago

sebastianmika commented 4 years ago

Description

There seems to be a rule missing that can merge a month and a year:

Example: list(ctparse_gen('June 2020')) Expected: 2020-06-X X:X (X/X) Actual:

X-06-X X:X (X/X) s=-5.902 p=(103, 111, 'ruleYear', 'ruleNamedMonth')
2020-X-X X:X (X/X) s=-5.902 p=(103, 111, 'ruleYear', 'ruleNamedMonth')

and some more, but nothing that combines the month and the year into a single resolution.

What seems to be missing is a rule like

@rule(predicate('isMonth'), predicate('isYear'))                                                                                                                                     
def ruleMonthYear(ts, m, y):                                                                                                                                                         
    return Time(year=y.year, month=m.month)