Better response personalization

You'll notice that the function picks one template at random for any particular bot intent, so to say. While this is for simplicity here, in practice, you can train an ML model to pick a response that's personalized to a user.

A simple personalization to make is to adapt with the talking/typing of the user's style. For example, one user might be formal with, Hello, how are you today?, while another might be more informal with, Yo.

Therefore, Hello gets Goodbye! in response while Yo! gets Bye bye or even TTYL in the same conversation.

For now, let's go ahead and check the bot response for the sentences that we have already seen:

for text in ["hey","i am looking for italian food","not for me", "ok, this is good"]: ...

Get Natural Language Processing with Python Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.