facebook / duckling

Language, engine, and tooling for expressing, testing, and evaluating composable language rules on input strings.
Other
4.05k stars 723 forks source link

Time/ES proximo <weekday> returns more than one result #620

Closed clobotorre closed 3 years ago

clobotorre commented 3 years ago

I'm running duckling this way:

stack exec duckling-example-exe

After that, if I send this request:

curl -XPOST http://0.0.0.0:8000/parse --data 'locale=es_ES&text=el proximo viernes'

I get, in the values array the next three fridays:

[{"body":"viernes","start":11,"value":{"values":[{"value":"2021-05-21T00:00:00.000-07:00","grain":"day","type":"value"},{"value":"2021-05-28T00:00:00.000-07:00","grain":"day","type":"value"},{"value":"2021-06-04T00:00:00.000-07:00","grain":"day","type":"value"}],"value":"2021-05-21T00:00:00.000-07:00","grain":"day","type":"value"},"end":18,"dim":"time","latent":false}]

I cannot test if in English it has the same response, because of this issue https://github.com/facebook/duckling/issues/204

What I was expecting is just one single friday (the very next one) in the values array. How can I achieve that?

chessai commented 3 years ago

Piping through jq for easier-to-read output (I recommend this when pasting for future issues!):

[
  {
    "body": "viernes",
    "start": 11,
    "value": {
      "values": [
        {
          "value": "2021-05-21T00:00:00.000-07:00",
          "grain": "day",
          "type": "value"
        },
        {
          "value": "2021-05-28T00:00:00.000-07:00",
          "grain": "day",
          "type": "value"
        },
        {
          "value": "2021-06-04T00:00:00.000-07:00",
          "grain": "day",
          "type": "value"
        }
      ],
      "value": "2021-05-21T00:00:00.000-07:00",
      "grain": "day",
      "type": "value"
    },
    "end": 18,
    "dim": "time",
    "latent": false
  }
]

As you can see, after the array, is the actual value and grain. The values array contains the three next fridays (as likely candidates for what you want), but the actual return value is the most recent one.

clobotorre commented 3 years ago

Now that I can use requests in en_GB (thanks to LANG env. variable), I see that in English 'next friday' (or any other weekday) results in one single value in the values array (Sorry for the readability. I dont know how to paste the json in the beauty way yo do)

curl -XPOST http://0.0.0.0:8000/parse --data 'locale=en_GB&text="next friday"' | jq

[ { "body": "next friday", "start": 1, "value": { "values": [ { "value": "2021-05-28T00:00:00.000-07:00", "grain": "day", "type": "value" } ], "value": "2021-05-28T00:00:00.000-07:00", "grain": "day", "type": "value" }, "end": 12, "dim": "time", "latent": false } ]

So, Is there any way to obtain same result (one single value in the values array instead of three of them) when the request is in Spanish?

curl -XPOST http://0.0.0.0:8000/parse --data 'locale=es_ES&text="el proximo viernes"' | jq

[ { "body": "viernes", "start": 12, "value": { "values": [ { "value": "2021-05-21T00:00:00.000-07:00", "grain": "day", "type": "value" }, { "value": "2021-05-28T00:00:00.000-07:00", "grain": "day", "type": "value" }, { "value": "2021-06-04T00:00:00.000-07:00", "grain": "day", "type": "value" } ], "value": "2021-05-21T00:00:00.000-07:00", "grain": "day", "type": "value" }, "end": 19, "dim": "time", "latent": false } ]