duckling icon indicating copy to clipboard operation
duckling copied to clipboard

"before the end of the month" incorrectly parsed

Open figelwump opened this issue 6 years ago • 5 comments

Currently a phrase like "before the end of the month" gives an interval as expected, but the end date is not the last day of the month.

Examples:

curl -XPOST http://0.0.0.0:8000/parse --data 'locale=en_US&text=before the end of the month' 
[
    {
        "body": "before the end of the month",
        "dim": "time",
        "end": 27,
        "latent": false,
        "start": 0,
        "value": {
            "to": {
                "grain": "day",
                "value": "2018-11-21T00:00:00.000-08:00"
            },
            "type": "interval",
            "values": [
                {
                    "to": {
                        "grain": "day",
                        "value": "2018-11-21T00:00:00.000-08:00"
                    },
                    "type": "interval"
                }
            ]
        }
    }
]
curl -XPOST http://0.0.0.0:8000/parse --data 'locale=en_US&text=before end of dec'
[
    {
        "body": "before end of dec",
        "dim": "time",
        "end": 17,
        "latent": false,
        "start": 0,
        "value": {
            "to": {
                "grain": "day",
                "value": "2018-12-21T00:00:00.000-08:00"
            },
            "type": "interval",
            "values": [
                {
                    "to": {
                        "grain": "day",
                        "value": "2018-12-21T00:00:00.000-08:00"
                    },
                    "type": "interval"
                },
                {
                    "to": {
                        "grain": "day",
                        "value": "2019-12-21T00:00:00.000-08:00"
                    },
                    "type": "interval"
                },
                {
                    "to": {
                        "grain": "day",
                        "value": "2020-12-21T00:00:00.000-08:00"
                    },
                    "type": "interval"
                }
            ]
        }
    }
]

figelwump avatar Nov 01 '18 19:11 figelwump

Thanks for reporting @figelwump! Any chance you can give it a shot?

patapizza avatar Nov 07 '18 05:11 patapizza

I can take a stab at it! Pointers on where to start would be great.

figelwump avatar Nov 15 '18 22:11 figelwump

@figelwump: Great! https://github.com/facebook/duckling/blob/master/Duckling/Time/EN/Rules.hs#L1354-L1395

patapizza avatar Nov 17 '18 09:11 patapizza

I think that this issue probably lives closer to here. Since those linked rules @patapizza probably would match on "end of the month", and not "at the beginning", and in the rule I've linked we then/else on the presence of "by".

Without "by", we intersect on 21 - maybe this explains the dates @figelwump is seeing in the results?

xtianjohns avatar Nov 26 '18 17:11 xtianjohns

Was this ever resolved? I still see the issue

eitantorf avatar May 30 '22 09:05 eitantorf