简体   繁体   中英

How to extract special information from Watson Assistant (Conversation)?

I have the user input "What is the hostname of serial GX0211229342?" . The serial can be a numeric or alphanumeric mix (eg 7842344 or H52WBD1 etc).

How can I extract GX0211229342 from the sentence and set it into context in Watson assistant (Watson Conversation)?

Your case is tricky because if the ID is only letters it could be any part of the sentence. Using the $ , you have told the regex processor to look for the pattern at the end of the sentence. Hence, it only works for those cases.

What you could do is to make use of a non-capturing group provided by the RE2 syntax . There are some examples of non-capturing group here on SO . Basically, search for something like the following (not tested):

(?:serial)(?:number)?[0-9a-zA-Z]+

The first ("serial") would be detected and ignored, the "number" is optional and would be ignored, then comes the alphanumeric.

If the serial number can be defined by 1 or 2, any number of regular expressions then you have the option of creating a serial number entity based on those regular expressions.

The conversation service will be able to identify the serial numbers based on the entity pattern matching.

I figure it out, using Watson entity pattern, and the regular expression should be this: ([0-9]+[a-zA-Z]+|[a-zA-Z]+[0-9]+)[0-9a-zA-Z]* it will be used to extract alphanumeric from input. and one more pattern is [0-9]+ it was used to extract numbers. Thank you all help.

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