0

I'm using Facebook Duckling to parse some text but the results include some odd dimensions:

String text = "Tomorrow, February 28";
String result = Duckling.parseText(text);

Result:
 [
  {
    "body": "Tomorrow, February 28",
    "start": 0,
    "value": {
      "values": [
        {
          "value": "2022-02-28T00:00:00.000-08:00",
          "grain": "day",
          "type": "value"
        }
      ],
      "value": "2022-02-28T00:00:00.000-08:00",
      "grain": "day",
      "type": "value"
    },
    "end": 21,
    "dim": "time",
    "latent": false
  },
  {
    "body": "28'",
    "start": 19,
    "value": {
      "value": 28,
      "type": "value",
      "minute": 28,
      "unit": "minute",
      "normalized": {
        "value": 1680,
        "unit": "second"
      }
    },
    "end": 22,
    "dim": "duration",
    "latent": false
  },
  {
    "body": "28'",
    "start": 19,
    "value": {
      "value": 28,
      "type": "value",
      "unit": "foot"
    },
    "end": 22,
    "dim": "distance",
    "latent": false
  }
]

This result is odd since from the context of the query the text "28" is clearly referring to the day of month but Duckling also returns data as if it were referring to the Distance dimension.

Is there a way to make Duckling context aware and have it only return results matching the full query? Passing "dimensions" as argument is not ideal since I don't know the dimensions in advance.

Thanks

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
Bradford Griggs
  • 439
  • 2
  • 15
  • Why is this tagged "haskell"? And why can't you filter the results to only full matches yourself? It sure looks like they give you all the data you need to do that. – Daniel Wagner Feb 27 '22 at 23:26
  • @DanielWagner I guess you could but I was wondering if there was some parameter to make it context aware so that it only returns context aware results. – Bradford Griggs Feb 28 '22 at 00:21
  • 1
    @DanielWagner I noticed there was a bug in my code as it was parsing the text as: `28'` instead of: `28` - this is why it thought there was `unit` dimension. When I removed the `'` at the end, it does not return such out of context results - as I expected. The [Quickstart](https://github.com/facebook/duckling#quickstart) gives example with `'` at the end: `curl -XPOST http://0.0.0.0:8000/parse --data 'locale=en_GB&text=tomorrow at eight'` -- which is why I added it. I now removed it and it only returns one dimension as expected. Thanks for your help. – Bradford Griggs Feb 28 '22 at 00:28

0 Answers0