2

Update : The stackoverflow mentionned below gave another solution, namely to import the json and replace the text with the data in the right format. I am now trying to see how I can fit the format given, which looks something like this :

{
      "text" : "usersentence",
      "entities" : [
        {
          "entity" : "intent",
          "value" : "\"valueofintent\"",
          "start" : lenghtstart,
          "end" : lengthend
        }
      ]
}

We have a csv/json file containing a dataset we created. We are trying to import it into wit.ai without having to do it manually. I found 2 ressources online explaining a solution, but I am stuck while implementing either.

Initial link found : How do I use wit.ai with existing rows of data?

The above link sent me to this one : https://github.com/wit-ai/wit-api-only-tutorial/blob/master/README.md

I can't understand how to replace the /samples he used with my own links to data. Also I can't find any info on the post/samples API he is mentionning.

Second link I found. Still unable to implement the data import: https://chunksofco.de/wit-ai-explained-part-3-building-a-bot-with-sails-js-b4b801a2f7a5

Ali Zarezade
  • 871
  • 9
  • 22
Maude
  • 512
  • 3
  • 8
  • 23

1 Answers1

5

You can simply follow the HTTP API Reference in wit.ai docs.

To add train data to your app, you should use POST /samples method in the API reference.

For example the following curl request:

$ TOKEN=your-wit-app-token
$ curl -XPOST 'https://api.wit.ai/samples?v=20170307' \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '[{
        "text": "I want to fly to sfo",
        "entities": [
          {
            "entity": "intent",
            "value": "flight_request"
          },
          {
            "entity": "wit$location",
            "start": 17,
            "end": 20,
            "value": "sfo"
          }
        ]
      }]'

add "I want to fly to sfo" sentence with flight_request intent and with$location entity to the training data. You can also add all of you training data in a json file train_data.json with the above form and use:

$ curl -XPOST 'https://api.wit.ai/samples?v=20170307' \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d @train_data.json
Ali Zarezade
  • 871
  • 9
  • 22