ibm-watson - Watson 助手 JSON 编辑器中的变量模式
问题描述
我在对话中为特定变量创建了一个模式。
类型:模式^[A-Za-z]{1,}$
我希望该变量的值仅是一个词,仅此而已。我只是不知道在 JSON 编辑器中的何处插入它。
{
"output": {
"text": {
"values": [
"Nice to meet you $firstname. How can I assist you mate?"
],
"selection_policy": "sequential"
}
},
"context": {
"firstname": "<? input.text.substring(0, 1).toUpperCase() + input.text.substring(1) ?>"
}
}
解决方案
如果我理解正确,我认为您想要的是使用您的表达式创建一个基于模式的实体https://cloud.ibm.com/docs/services/assistant?topic=assistant-entities#entities-dictionary-overview
Watson Assistant 将识别您的模式的出现并将它们存储在“实体”数组中。然后,您可以使用“@myentitiy”语法在对话节点中构建条件,或者直接从“实体”数组访问它们。如果您只想第一次出现,请使用entities.get(0)
推荐阅读
- amcharts - 如何在 amcharts v4 中单击时突出显示单个条
- reactjs - 在 React 中显示来自 json api 的列表
- python - 如何使用变形网格(可逆)扭曲文档图像
- javascript - 在电子邮件正文中发送 html 模板
- css - 使用 css sprite 动画时防止重绘
- webpack - 将 Laravel 混合输出到多个位置
- jquery - 使用 angular4 中的 mydatepicker 在输入框中设置日期
- webpack - 如何从入口文件中的 mini-css-extract-plugin 获取对 css 文件的引用
- vba - Copy paste range of cells for every row called xxxx
- angularjs - AngularJs - 具有多个模块的应用程序