1
是否可以根據一組依賴於另一個上下文值的值的條件來設置上下文變量的值?我試圖將NLU(自然語言理解)服務與對話服務集成在一起,並希望根據NLU返回的值設置一些上下文變量。例如我正在以下實體從NLU:基於Watson對話服務中上下文變量的處理條件
{
...
"context": {
...
"nlu_response": {
"entities": [{
"type": "Person",
"relevance": 0.5,
"count": 1,
"text": "Jon Doe",
"emotion": {
"anger": 0.082378,
"disgust": 0.033499,
"fear": 0.072588,
"joy": 0.100971,
"sadness": 0.147584
},
"sentiment": {
"score": 0.409803
}
},
{
"type": "Person",
"relevance": 0.5,
"count": 1,
"text": "Jane Doe",
"emotion": {
"anger": 0.140151,
"disgust": 0.091598,
"fear": 0.059244,
"joy": 0.046762,
"sadness": 0.165763
},
"sentiment": {
"score": 0
}
}]
}
}
}
,並希望建立一個上下文變量EntityPerson_1用的「喬恩Doe的」僅當有類型爲實體對象值的值= 「人」。 換句話說是這樣的可能在響應節點:
{
...
"context": {
...
"EntityPerson_1": <? context.nlu_response.entities.size()>0 && context.nlu_response.entities.get(0).type.contains('Person')?context.nlu_response.entities.get(0).text:'' ?>
}
}