通过 Dialogflow REST 训练短语 API
Dialogflow Training Phrases through Dialogflow REST API
我创建了一个自定义实体 “toppings”,我有一个代理 Pizza。我正在使用 Dialogflow REST API 创建一个意图,我正在尝试放置多个训练短语。
但是在控制台中我无法获得所有这些训练短语。所有训练短语都合并到一行。
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts": [
{
"text": "I want a pizza with extra "
},
{
"text": "cheese",
"entityType":"@toppings",
"alias": "pizza",
"userDefined": "True"
},
{
"text" : "where is my pizza"
},
{
"text" : "get me a pizza"
}
]
}
]
TIA
发生这种情况是因为,您通过 Dialogflow API 创建的意图文件,在训练短语部分,您将所有用户表达式放在 field parts[] of the training Phrase 中,为此只有单个训练短语被创建,因此您的所有用户表达式都被组合成您在 dialogflow 控制台中看到的单个表达式。尝试在您的意图文件中创建多个训练短语,以便单独处理所有用户表达。
可以参考这段代码:
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts":[
{
"text": "I want a pizza with extra "
},
{
"text": "cheese",
"entityType":"@toppings",
"alias": "pizzas",
"userDefined": "True"
}
]
}
],
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts":[
{
"text": "order me a pizza"
}
]
}
],
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts":[
{
"text": "where is my pizzza "
}
]
}
]
我创建了一个自定义实体 “toppings”,我有一个代理 Pizza。我正在使用 Dialogflow REST API 创建一个意图,我正在尝试放置多个训练短语。 但是在控制台中我无法获得所有这些训练短语。所有训练短语都合并到一行。
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts": [
{
"text": "I want a pizza with extra "
},
{
"text": "cheese",
"entityType":"@toppings",
"alias": "pizza",
"userDefined": "True"
},
{
"text" : "where is my pizza"
},
{
"text" : "get me a pizza"
}
]
}
]
TIA
发生这种情况是因为,您通过 Dialogflow API 创建的意图文件,在训练短语部分,您将所有用户表达式放在 field parts[] of the training Phrase 中,为此只有单个训练短语被创建,因此您的所有用户表达式都被组合成您在 dialogflow 控制台中看到的单个表达式。尝试在您的意图文件中创建多个训练短语,以便单独处理所有用户表达。
可以参考这段代码:
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts":[
{
"text": "I want a pizza with extra "
},
{
"text": "cheese",
"entityType":"@toppings",
"alias": "pizzas",
"userDefined": "True"
}
]
}
],
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts":[
{
"text": "order me a pizza"
}
]
}
],
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts":[
{
"text": "where is my pizzza "
}
]
}
]