更新:下面提到的stackoverflow给出了另一种解决方案,即导入json并用正确格式的数据替换文本。我现在试图看看如何适应给定的格式,它看起来像这样:
{
"text" : "usersentence",
"entities" : [
{
"entity" : "intent",
"value" : "\"valueofintent\"",
"start" : lenghtstart,
"end" : lengthend
}
]
}
我们有一个 csv/json 文件,其中包含我们创建的数据集。我们正在尝试将其导入 wit.ai,而无需手动执行。我在网上找到了 2 个资源来解释解决方案,但我在实现其中一个时遇到了困难。
找到初始链接:How do I use wit.ai with existing rows of data?
上面的链接将我带到了这个:https://github.com/wit-ai/wit-api-only-tutorial/blob/master/README.md
我不明白如何用我自己的数据链接替换他使用的/samples。另外,我找不到他提到的 post/samples API 的任何信息。
我找到的第二个链接。仍然无法实现数据导入:https://chunksofco.de/wit-ai-explained-part-3-building-a-bot-with-sails-js-b4b801a2f7a5
最佳答案
您只需关注HTTP API Reference即可在 wit.ai 文档中。
要将训练数据添加到您的应用中,您应该使用 API 引用中的 POST/samples
方法。
例如以下curl请求:
$ 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"
}
]
}]'
将带有 flight_request 意图和 with$location 实体的“我想飞往 sfo”句子添加到训练数据中。
您还可以使用上述表单将所有训练数据添加到 json 文件 train_data.json
中并使用:
$ curl -XPOST 'https://api.wit.ai/samples?v=20170307' \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d @train_data.json
关于wit.ai - 将数据导入wit.ai,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44617187/