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..

Check for match on variable value
 
 

Hello,

How can I pattern match on the value of a variable? For example I have variables for $users_fname and $users_lname that may be populated with any text strings and I want to match on those values.

If $users_fname=Helen and $user_lname=Turner I want the following to match but I don’t want a different name to match:

My name is Helen Turner and I live on the moon. (match)

My name is Fred Smith and I live on the moon. (not a match)

Thank you.

 

 

 

 
  [ # 1 ]

The simplest pattern is:

( name is $users_fname? $users_lname? )

The question mark after the variable converts the test from mere existence of a value in that variable to a dynamic match on the value of the variable.

Note there are some limitations with multiple word values - see the section in the Pattern Redux document.

 

 
  [ # 2 ]

Great, thanks Andy!

 

 
  [ # 3 ]

Clever, Andy, thank you for sharing.  This is a new pattern have not used yet.

Names…. They are difficult….

Many people names are also found as nouns and verbs.  Liberty, Hope, Faith, Patience, Trinity, Lily, Forest, Rose, Paris, Hudson….  So, if you refer to just the first name, be careful. You might want to check for the presence of other qualifying patterns.

Also, when you test, check using the name without capitalization.  Lots of people put in their name without the first letter capitalized.

I keep a master list of male and female names in some concepts. As well as names that might not be actually be names. So, if someone gives a name, I see if it is unusual in any way and might require some confirmation.

For example, if I see the word Paris or any city and I expect a name, I will clarify this.
Or something that is not a name, I will clarify this.

This is the kind of stuff you see when you review the transcript logs of the users.

Good luck!

 

 

 
  login or register to react