0

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

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

data_henrik
  • 16,724
  • 2
  • 28
  • 49
george jiang
  • 105
  • 9
  • Is the word "serial" always in front of that id or can it be anywhere? – data_henrik May 04 '18 at 08:37
  • serial can be serial number too, I tried to use this to extract ," input.text.extract('[0-9a-zA-Z]+$', 0) ?>", but it only works when there is no more words after serial XXXX. when I asked 'is serial number XXXX active? it does not work any more. – george jiang May 04 '18 at 09:21
  • if serial or serial number always in front of that id, do you have any solution? Thanks – george jiang May 04 '18 at 09:25

3 Answers3

0

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.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
0

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.

chughts
  • 4,210
  • 2
  • 14
  • 27
  • Thank you chughts, I tried entiry pattern, but it seems that the regular expression does not work, I am trying to use ^[a-zA-Z0-9]*$, but it can not recognize serial number such as SFOX2148PKJK,0050600 or 5VHGCF1? is the regular expression different with others? – george jiang May 07 '18 at 06:43
0

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.

george jiang
  • 105
  • 9