For example I have 3 different entities
@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>
.
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
When one of the entity is not recognized (null
), the value counted will be 0
.