Building Chatbots in Python
Alan Nichol
Co-founder and CTO, Rasa

def respond(message, params):
# update params with entities in message
# run query
# pick response
return response, params
# initialise params
params = {}
# message comes in
response, params = respond(message, params)
"kde bych měl jít na večeři?"
"ne, sushi nemám rád"
"co třeba Sally's Sushi Place?"
"dobře, co Joe's Steakhouse?"

doc = nlp('not sushi, maybe pizza?')indices = [1, 4]ents, negated_ents = [], []start = 0 for i in indices: phrase = "{}".format(doc[start:i]) if "not" in phrase or "n't" in phrase: negated_ents.append(doc[i]) else: ents.append(doc[i]) start = i
Building Chatbots in Python