Creating a retrieval-based chatbot
The implementation in this section is inspired by ELIZA (https://web.njit.edu/~ronkowit/eliza.html), an early chatbot, and one of the first programs capable of attempting the Turing test. It simulated a psychotherapist in an initial psychiatric interview to demonstrate the superficiality of the communication between man and machine. The client performed the conversation using pattern matching and substitution methodology.
First, we need to set a list with possible patterns and the relevant responses using the code in the chatbot.ipynb
notebook:
from nltk.chat.util import Chat, reflections
# Pairs of patterns and responses.
pairs = (
(
r"I need (.*)",
(
"Why do you need %1?",
&...