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

Convert basic RiveScripts into Regex
 
 

I’d like to know how to convert basic rivescripts into regular expressions. I tried to make some regex examples, but some regex failed to capture the correct values:

example 1: “what color is my bright red car” (https://regex101.com/r/WT2Va1/1)

what color is [my|your|his|her] (bright red|blue|green|lemon chiffon) *
what color is(?: myyourhisher)?(?: bright redblue|g reenlemon chiffon)(?: (.+)) 

example 2: “he told me to say thanks” (https://regex101.com/r/q0ea4m/1)

[*] told me to say *
(?:(.+) )?
told me to say(?: (.+)) 

example 3: “i know what cars are!” (https://regex101.com/r/RKAd04/1)

[i|you] [know] what [is|are]!
(?:
|you )?(?:know )?what(?: (.+))(?: isare)?! 

I somehow corrected the first and second regexes, but the last regex captured the wrong answer.
Are there any tools that help tranform rivescript in to regex?

 

 
  [ # 1 ]

I don’t know of any tools that help transform rivescript in to regex automatically.

But,

in:
[i|you] [know] what * [is|are]!
(?:i |you )?(?:know )?what(?: (.+))(?: is| are)?! 


(?:i |you )?(?:know )?what(?: (.+?))(?: is| are)?! 
might be better. “(.+)” is greedy and will capture everything. I don’t think you ever get to the last optional group.
“(.+?)” will do a minimal capture if the last group exists.

 

 
  login or register to react