简体   繁体   中英

IBM Watson - Conversation Response Condition

I'm pretty new to Watson Conversation and Watson in generel, and I've come across a situation that I would like to handle in the Watson Conversation app, but I can't figure out.

Basically I want to add an "advanced" condition to a response so it will be possible to do eg:

Condition: if @sys-number==Integer

Response: @sys-number is an integer.

Condition if @sys-number==Double

Response: @sys-number is a double.

Currently I'm stuck, since I can get the @sys-number class by doing @sys-number.numeric_value.class, which evaluates to eg "class java.lang.Integer", but I cannot do the comparison in the condition field.

I've tried to do several different things, where the most obvious would be

if (@sys-number instanceof java.lang.Integer)

I know that this can be handled on the application side, but would like a solution Conversation side, if possible.

By essence the '@sys-number' entity is a string, because it belongs to the user's input. So if you want to test wether the user's input recognized @sys-number entity can be converted onto integer or a float you must try :

IF @sys-number AND input.text.find('\d+') 

IF @sys-number AND input.text.find('\d+[,\.]\d+')

If and only if none of the condition is triggered, the @sys-number comes from Alphabetic input

例如,使用正则表达式将查找整数。

/^[0-9]*$/

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