目标: - 我想在Java中的dialogflow v2 Beta API的dialogfow中插入训练短语。
for ex: 训练短语: - 我想要披萨。 请订购披萨
动作和参数: 参数名称:Topping, ENTITY:@Topping, 价值:$ Topping
我目前的代码: -
List<TrainingPhrase> trainingPhrases = new ArrayList<>();
for (String trainingPhrase : trainingPhrasesParts) {
for (String parm : parameters) {
for (String enti : entity_type) {
trainingPhrases.add(
TrainingPhrase.newBuilder().addParts(
Part.newBuilder().setText(trainingPhrase).setText(response_value).setAlias(parm).setEntityType(enti).build())
.build());
}}
}
// Build the intent
Intent intent = Intent.newBuilder()
.setDisplayName(displayName)
.addMessages(message)
.addAllTrainingPhrases(*trainingPhrases*)
.build();
这导致我在.addAllTrainingPhrases( trainingPhrases )中使用JSON:
[parts {
text: " pizza"
entity_type: "@Topping"
alias: "topping"
}
]
"parts": [
{
"text": "I want "
},
{
"text": "pizza",
"entityType": "Topping",
"alias": "topping"
}
]