MikeHopcroft / ShortOrder

A natural language conversational agent for ordering and organizing items from a catalog.
MIT License
13 stars 7 forks source link

Modifiers added to last valid entity, upon entity recognition failure #45

Open SpaceKatt opened 5 years ago

SpaceKatt commented 5 years ago

If a customer enters a valid order and then enters an invalid order with a modifier, then short-order will add the modifier to the last valid entity. (Version 0.0.28)

$ node build/samples/repl_demo.js
Welcome to the ShortOrder REPL.
Type your order below.
A blank line exits.

Type .help for information on commands.

% could I please have a coffee

QTY ITEM                                     TOTAL
  1 Medium Coffee (1101)                      1.29
Subtotal                                      1.29
    Tax                                       0.12
Total                                         1.41

Got it. Can I get you anything else?

% another covfefe with two cream

QTY ITEM                                     TOTAL
  1 Medium Coffee (1101)                      1.29
      ADD 2 Cream (1194)
Subtotal                                      1.29
    Tax                                       0.12
Total                                         1.41

Not sure I got all that. Is that everything?
MikeHopcroft commented 5 years ago

Interesting issue. The code was originally designed for the scenario where the second utterance is something like "add two cream". It seems we really need to detect the target of the add, and if the target is invalid, just drop the order.

Right now, CartOps.updateCart() does a tree walk over the cart, attempting to determine where to add the modifier. So, say one orders a Surf 'n Turf combo with a coke, they should be able to say "no ice" and have it remove the ice from the coke.

I am planning to rework a bunch of this logic based on cases we've seen recently. I think I need an explicit preposition resolution algorithm, so that one can say "add cream to that" or "add cream to the first coffee" or "two coffees, one with cream and the other with sugar".

ianphil commented 5 years ago

If I can jump in here? I've thought a little about this problem. The Wordnet Database provides the concept of Synsets. These provide lexical grouping of synonyms and [alt]meanings. This could help to understand the choice that needs to be made. I was playing with the simple case of "no". @MikeHopcroft it's in Python :-)

NLTK - No no no