Building Chatbots in Python
Alan Nichol
Co-founder and CTO, Rasa
A restaurant_search
can be expressed many different ways:
request_booking
'|'
is equivalent to ORre.search(r"(hello|hey|hi)", "hey there!") is not None
True
re.search(r"(hello|hey|hi)", "which one?") is not None
True
\b
matches the beginning or end of a wordre.search(r"\b(hello|hey|hi)\b", "hey there!") is not None
True
re.search(r"\b(hello|hey|hi)\b", "which one?") is not None
False
pattern = re.compile('[A-Z]{1}[a-z]*')
message = """ Mary is a friend of mine, she studied at Oxford and now works at Google"""
pattern.findall(message)
['Mary', 'Oxford', 'Google']
Building Chatbots in Python