Inkrementální vyplňování slotů a negace

Building Chatbots in Python

Alan Nichol

Co-founder and CTO, Rasa

Inkrementální filtry

Building Chatbots in Python

Základní paměť

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)
Building Chatbots in Python

Negace

"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?"

Building Chatbots in Python

Negované entity

  • předpokládáme, že „not" nebo „n't" těsně před entitou znamená, že ji uživatel chce vyloučit
  • běžné entity jsou zelené, negované entity jsou fialové
Building Chatbots in Python

Zachycení negací

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

Pojďme si procvičit!

Building Chatbots in Python

Preparing Video For Download...