AI Zone Admin Forum Add your forum

Chatbot Conference London On Oct 3th Erwin will be moderating on the Chatbots conference in London. Why don't you meet him there? As a Chatbots.org visitor, you'll get a discount as well: Why don't we meet there? get a discount

We do experience some trouble with our forms and some details page. We'll fix this ASAP. Sorry for the inconvenience!
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