Demonstration

asciinema recording

Obtain the docker image

1
docker pull rasa/duckling

Create duckling-parse script

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
export TTY

input="$(urlencode)"

set -m

(
unbuffer docker \
    run \
    --name duckling-container \
    --rm \
    --network=host \
    --entrypoint= \
    rasa/duckling:latest \
    duckling-example-exe -p 8000 --no-access-log --no-error-log
) &>/dev/null &

sleep 2

/usr/bin/curl -XPOST http://0.0.0.0:8000/parse --data "locale=en_GB&text=$input" | jq .

unbuffer real-docker container stop duckling-container &>/dev/null & disown

Try it out

1
echo tomorrow at eight | duckling-parse
[
  {
    "body": "tomorrow at eight",
    "start": 0,
    "value": {
      "values": [
        {
          "value": "2020-05-26T08:00:00.000-07:00",
          "grain": "hour",
          "type": "value"
        },
        {
          "value": "2020-05-26T20:00:00.000-07:00",
          "grain": "hour",
          "type": "value"
        }
      ],
      "value": "2020-05-26T08:00:00.000-07:00",
      "grain": "hour",
      "type": "value"
    },
    "end": 17,
    "dim": "time",
    "latent": false
  }
]

Get a value out of the parse tree

1
echo "3 cups of sugar" | duckling-parse | jq -r '.[0].value.value'
3
Thoughts
I think it would be cool to be able to learn these backbone tools.

Perhaps one day in the future you could spin up an OS which runs lots of conversational agents.

In a simulated facebook or something.

Then being able to reach in there and tweak the language of the agents somehow would be fun.

For example, you could run some kind of marketing simulation with a bunch of bots.

Facebook gives these bots different adverts depending on their conversation, but then you could tweak the duckling parser or something to make it so when they say X, they really mean Y, and just run these experiments.