AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

How to identify specific pattern string in a sentence
 
 

Hi!

I need to identify a string in a sentence which will be in specific pattern like

what is the status of my policy abc-def-12345

The String abc-def-12345 can be in anywhere in the sentence I don’t know how can I get the string.

Please help how to solve this

 

 
  [ # 1 ]

If you don’t expect any other words to be a combination of letters and numbers, try ~modelnumber. If you put an underscore before it, you can then store the value in a variable, which I’m guessing you’ll need. This bit of code should respond with only the policy number:

u: ( * _~modelnumber * ) ‘_0

 

 
  [ # 2 ]

if you know the string completely in advance (because it is users policy number) then you can, of course, just test for that in a pattern. Otherwise Oksana’s response about model numbers works if the number is a mix of letters and digits.

 

 
  [ # 3 ]

Sorry for the late reply,

Okay, I’ll try that. thanks, @Oksana Tkach and @Bruce Wilcox

 

 
  [ # 4 ]
Oksana Tkach - Aug 28, 2017:

If you don’t expect any other words to be a combination of letters and numbers, try ~modelnumber. If you put an underscore before it, you can then store the value in a variable, which I’m guessing you’ll need. This bit of code should respond with only the policy number:

u: ( * _~modelnumber * ) ‘_0

What if the string is like 1234-5678-90 ? How can I solve this?

 

 

 
  [ # 5 ]

Ultimately, you have to examine it by script yourself.  For any token whose canonical value is an unknown word,
you can burst it into temporary facts, and loop through the letters performing any test you want

 

 
  [ # 6 ]

Or if you want to get fancy you can use the Javascript engine embedded in CS and use a regex to match strings. Be aware that this is not the same as the standard pattern matching in CS in that you have to work harder to get positional information.

 

 
  login or register to react