简体   繁体   中英

number comparison in IBM Watson Assistant

I am trying to build a BMI calculator inside Watson but it seems like Watson is not supporting number comparison when you use the "Multiple conditioned responses".

<? ($weight /  ($height * $height) ) < 18.5  ?>

This code will throw an error:

SpelParseException when evaluating dialog node ID [response_8_1624288200413]. Condition [<? ($weight / ($height * $height) ) < 18.5 ?>] could not be parsed. Check the syntax of the expression. SpEL syntax error: Expression [<? ($weight / ($height * $height) ) < 18.5 ?>] converted to [<? (context['weight'] / (context['height'] * context['height']) ) < 18.5 ?>] at position 0: EL1070E: Problem parsing left operand

Your example works for me. I can also confirm that IBM Watson Assistant can compare numbers and has other support for math expressions and number processing .

This is my response text:

This is: <? ($weight / ($height*$height)) < 18.5 ?>

I set values for weight and height in Manage Context in the "Try it". Depending on the values, it returns either

This is: true

or

This is: false

Have you set any values during your tests?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM