简体   繁体   English

Watson Assistant-如何获取特定实体的大小

[英]Watson Assistant - How to get size of specific entities

For example I have 3 different entities 例如我有3个不同的实体

@action = eat,run,walk
@person = Michael, John, Fred 
@emotion = angry,sad,happy

I want to count user entered action and person entities 我想计算用户输入的动作和人物实体

If bot recognizes
entities['action'].size() + entities['person'].size() > 2

Any other way to achieve this? 还有其他方法可以做到这一点吗?

To account for one of the entities not being recognized, you can use ternary operator <Expression> ? <what_to_do_when_true> : <what_to_do_when_false> 要说明未被识别的实体之一,可以使用三元运算符<Expression> ? <what_to_do_when_true> : <what_to_do_when_false> <Expression> ? <what_to_do_when_true> : <what_to_do_when_false> . <Expression> ? <what_to_do_when_true> : <what_to_do_when_false>

So, in your example the condition would look like this: ((entities['action'] != null ? entities['action'].size() : 0) + (entities['action'] != null ? entities['person'].size() : 0)) > 2 因此,在您的示例中,条件看起来像这样: ((entities['action'] != null ? entities['action'].size() : 0) + (entities['action'] != null ? entities['person'].size() : 0)) > 2

When one of the entity is not recognized ( null ), the value counted will be 0 . 如果无法识别其中一个实体( null ),则计数值为0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IBM Watson Assistant:如何使用系统实体sys-number仅获取少量数字 - IBM Watson Assistant: How to get just few numbers with System entities sys-number 如何让 Watson Assistant 正确响应 - How to get Watson Assistant to response correctly IBM Watson Assistant:我应该如何对实体进行分组? - IBM Watson Assistant: How should I group the entities? IBM Watson Assistant:如何获取v1 watson Assistant服务的IAM密钥 - IBM Watson Assistant: How to get IAM key for v1 watson assistant services Watson Assistant 提取多个模式实体 - Watson Assistant Extract multiple pattern entities 如何在MessageResponse Watson Assistant Java客户端中获取“动作”数据 - How to get “actions” data in MessageResponse Watson Assistant Java client IBM Watson Assistant:如何通过 API 获取意图列表? - IBM Watson Assistant: How to get list of intents by API? IBM Cloud Watson Assistant:如何获取工作空间的 ID - IBM Cloud Watson Assistant: How to get the ID of a workspace Watson Assistant Dialog Skill如何区分具有相同同义词的两个实体值? - How can Watson Assistant Dialog Skill distinguish between two entities values with the same synonyms? Watson Assistant Slots:如何允许用户使用非字典实体重新输入数据? - Watson Assistant Slots: how to allow the user to re-enter data using non-dictionary entities?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM